-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed readonly access Migrated to release .NET 8 Split Vogen into separate project Added TransparentValueObjects as an alternative - WIP Fixed ServiceProvider Too Many warning, thanks Npgsql
- Loading branch information
Showing
152 changed files
with
1,164 additions
and
757 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...Site.NexusMods.Server.ValueObjects.TVO/BUTR.Site.NexusMods.Server.ValueObjects.TVO.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<RootNamespace>BUTR.Site.NexusMods.Server.Models</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" /> | ||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.5.0" /> | ||
<PackageReference Include="TransparentValueObjects" Version="1.0.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\BUTR.Site.NexusMods.Shared\BUTR.Site.NexusMods.Shared.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
3 changes: 3 additions & 0 deletions
3
...ds.Server.ValueObjects.TVO/BUTR.Site.NexusMods.Server.ValueObjects.TVO.csproj.DotSettings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=models/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=utils/@EntryIndexedValue">False</s:Boolean></wpf:ResourceDictionary> |
9 changes: 9 additions & 0 deletions
9
src/BUTR.Site.NexusMods.Server.ValueObjects.TVO/Extensions/OpenApiExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace BUTR.Site.NexusMods.Server.Models; | ||
|
||
public static class OpenApiExtensions | ||
{ | ||
public static void ValueObjectFilter(this SwaggerGenOptions opt) | ||
{ | ||
opt.SchemaFilter<TransparentValueObjectSchemaFilter>(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/BUTR.Site.NexusMods.Server.ValueObjects.TVO/Models/ApplicationRole.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace BUTR.Site.NexusMods.Server.Models; | ||
|
||
using TType = ApplicationRole; | ||
using TValueType = String; | ||
|
||
[ValueObject<TValueType>] | ||
public readonly partial struct ApplicationRole : IAugmentWith<DefaultValueAugment, JsonAugment, EfCoreAugment> | ||
{ | ||
public static readonly TType Anonymous = From(ApplicationRoles.Anonymous); | ||
public static readonly TType User = From(ApplicationRoles.User); | ||
public static readonly TType Moderator = From(ApplicationRoles.Moderator); | ||
public static readonly TType Administrator = From(ApplicationRoles.Administrator); | ||
|
||
public static TType DefaultValue => Anonymous; | ||
} | ||
|
||
public static class ApplicationRoleExtension | ||
{ | ||
public static PropertyBuilder<TType> HasValueObjectConversion(this PropertyBuilder<TType> propertyBuilder) => propertyBuilder | ||
.HasConversion<TType.EfCoreValueConverter, TType.EfCoreValueComparer>(); | ||
} |
16 changes: 16 additions & 0 deletions
16
src/BUTR.Site.NexusMods.Server.ValueObjects.TVO/Models/CrashReportFileId.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace BUTR.Site.NexusMods.Server.Models; | ||
|
||
using TType = CrashReportFileId; | ||
using TValueType = String; | ||
|
||
[ValueObject<TValueType>] | ||
public readonly partial struct CrashReportFileId : IAugmentWith<DefaultValueAugment, JsonAugment, EfCoreAugment> | ||
{ | ||
public static TType DefaultValue => From(string.Empty); | ||
} | ||
|
||
public static class CrashReportFileIdExtension | ||
{ | ||
public static PropertyBuilder<TType> HasValueObjectConversion(this PropertyBuilder<TType> propertyBuilder) => propertyBuilder | ||
.HasConversion<TType.EfCoreValueConverter, TType.EfCoreValueComparer>(); | ||
} |
18 changes: 18 additions & 0 deletions
18
src/BUTR.Site.NexusMods.Server.ValueObjects.TVO/Models/CrashReportId.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace BUTR.Site.NexusMods.Server.Models; | ||
|
||
using TType = CrashReportId; | ||
using TValueType = Guid; | ||
|
||
[ValueObject<TValueType>] | ||
public readonly partial struct CrashReportId : IAugmentWith<DefaultValueAugment, JsonAugment, EfCoreAugment> | ||
{ | ||
public static TType DefaultValue => From(Guid.Empty); | ||
|
||
public static TType NewRandomValue(Random? random) => From(Guid.NewGuid()); | ||
} | ||
|
||
public static class CrashReportIdExtension | ||
{ | ||
public static PropertyBuilder<TType> HasValueObjectConversion(this PropertyBuilder<TType> propertyBuilder) => propertyBuilder | ||
.HasConversion<TType.EfCoreValueConverter, TType.EfCoreValueComparer>(); | ||
} |
18 changes: 18 additions & 0 deletions
18
src/BUTR.Site.NexusMods.Server.ValueObjects.TVO/Models/CrashReportUrl.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace BUTR.Site.NexusMods.Server.Models; | ||
|
||
using TType = CrashReportUrl; | ||
using TValueType = String; | ||
|
||
[ValueObject<TValueType>] | ||
public readonly partial struct CrashReportUrl : IAugmentWith<DefaultValueAugment, JsonAugment, EfCoreAugment> | ||
{ | ||
public static TType DefaultValue => From(string.Empty); | ||
|
||
public static TType From(Uri uri) => From(uri.ToString()); | ||
} | ||
|
||
public static class CrashReportUrlExtension | ||
{ | ||
public static PropertyBuilder<TType> HasValueObjectConversion(this PropertyBuilder<TType> propertyBuilder) => propertyBuilder | ||
.HasConversion<TType.EfCoreValueConverter, TType.EfCoreValueComparer>(); | ||
} |
16 changes: 16 additions & 0 deletions
16
src/BUTR.Site.NexusMods.Server.ValueObjects.TVO/Models/CrashReportVersion.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace BUTR.Site.NexusMods.Server.Models; | ||
|
||
using TType = CrashReportVersion; | ||
using TValueType = Byte; | ||
|
||
[ValueObject<TValueType>] | ||
public readonly partial struct CrashReportVersion : IAugmentWith<DefaultValueAugment, JsonAugment, EfCoreAugment> | ||
{ | ||
public static TType DefaultValue => From(0); | ||
} | ||
|
||
public static class CrashReportVersionExtension | ||
{ | ||
public static PropertyBuilder<TType> HasValueObjectConversion(this PropertyBuilder<TType> propertyBuilder) => propertyBuilder | ||
.HasConversion<TType.EfCoreValueConverter, TType.EfCoreValueComparer>(); | ||
} |
16 changes: 16 additions & 0 deletions
16
src/BUTR.Site.NexusMods.Server.ValueObjects.TVO/Models/ExceptionTypeId.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace BUTR.Site.NexusMods.Server.Models; | ||
|
||
using TType = ExceptionTypeId; | ||
using TValueType = String; | ||
|
||
[ValueObject<TValueType>] | ||
public readonly partial struct ExceptionTypeId : IAugmentWith<DefaultValueAugment, JsonAugment, EfCoreAugment> | ||
{ | ||
public static TType DefaultValue => From(string.Empty); | ||
} | ||
|
||
public static class ExceptionTypeIdExtension | ||
{ | ||
public static PropertyBuilder<TType> HasValueObjectConversion(this PropertyBuilder<TType> propertyBuilder) => propertyBuilder | ||
.HasConversion<TType.EfCoreValueConverter, TType.EfCoreValueComparer>(); | ||
} |
16 changes: 16 additions & 0 deletions
16
src/BUTR.Site.NexusMods.Server.ValueObjects.TVO/Models/GameVersion.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace BUTR.Site.NexusMods.Server.Models; | ||
|
||
using TType = GameVersion; | ||
using TValueType = String; | ||
|
||
[ValueObject<TValueType>] | ||
public readonly partial struct GameVersion : IAugmentWith<DefaultValueAugment, JsonAugment, EfCoreAugment> | ||
{ | ||
public static TType DefaultValue => From(string.Empty); | ||
} | ||
|
||
public static class GameVersionExtension | ||
{ | ||
public static PropertyBuilder<TType> HasValueObjectConversion(this PropertyBuilder<TType> propertyBuilder) => propertyBuilder | ||
.HasConversion<TType.EfCoreValueConverter, TType.EfCoreValueComparer>(); | ||
} |
9 changes: 9 additions & 0 deletions
9
src/BUTR.Site.NexusMods.Server.ValueObjects.TVO/Models/IValueObjectFrom.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace BUTR.Site.NexusMods.Server.Models; | ||
|
||
internal interface IValueObjectFrom<TValueType, TInnerValue> | ||
where TValueType : IValueObjectFrom<TValueType, TInnerValue> | ||
{ | ||
static abstract explicit operator TValueType(TInnerValue value); | ||
static abstract explicit operator TInnerValue(TValueType value); | ||
static abstract TValueType From(TInnerValue value); | ||
} |
16 changes: 16 additions & 0 deletions
16
src/BUTR.Site.NexusMods.Server.ValueObjects.TVO/Models/ModuleId.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace BUTR.Site.NexusMods.Server.Models; | ||
|
||
using TType = ModuleId; | ||
using TValueType = String; | ||
|
||
[ValueObject<TValueType>] | ||
public readonly partial struct ModuleId : IAugmentWith<DefaultValueAugment, JsonAugment, EfCoreAugment> | ||
{ | ||
public static TType DefaultValue => From(string.Empty); | ||
} | ||
|
||
public static class ModuleIdExtension | ||
{ | ||
public static PropertyBuilder<TType> HasValueObjectConversion(this PropertyBuilder<TType> propertyBuilder) => propertyBuilder | ||
.HasConversion<TType.EfCoreValueConverter, TType.EfCoreValueComparer>(); | ||
} |
16 changes: 16 additions & 0 deletions
16
src/BUTR.Site.NexusMods.Server.ValueObjects.TVO/Models/ModuleVersion.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace BUTR.Site.NexusMods.Server.Models; | ||
|
||
using TType = ModuleVersion; | ||
using TValueType = String; | ||
|
||
[ValueObject<TValueType>] | ||
public readonly partial struct ModuleVersion : IAugmentWith<DefaultValueAugment, JsonAugment, EfCoreAugment> | ||
{ | ||
public static TType DefaultValue => From(string.Empty); | ||
} | ||
|
||
public static class ModuleVersionExtension | ||
{ | ||
public static PropertyBuilder<TType> HasValueObjectConversion(this PropertyBuilder<TType> propertyBuilder) => propertyBuilder | ||
.HasConversion<TType.EfCoreValueConverter, TType.EfCoreValueComparer>(); | ||
} |
19 changes: 19 additions & 0 deletions
19
src/BUTR.Site.NexusMods.Server.ValueObjects.TVO/Models/NexusModsApiKey.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace BUTR.Site.NexusMods.Server.Models; | ||
|
||
using TType = NexusModsApiKey; | ||
using TValueType = String; | ||
|
||
[TypeConverter(type: typeof(TransparentValueObjectTypeConverter<TType, TValueType>))] | ||
[ValueObject<TValueType>] | ||
public readonly partial struct NexusModsApiKey : IAugmentWith<DefaultValueAugment, JsonAugment, EfCoreAugment>, IValueObjectFrom<TType, TValueType> | ||
{ | ||
public static readonly TType None = From(string.Empty); | ||
|
||
public static TType DefaultValue => None; | ||
} | ||
|
||
public static class NexusModsApiKeyExtension | ||
{ | ||
public static PropertyBuilder<TType> HasValueObjectConversion(this PropertyBuilder<TType> propertyBuilder) => propertyBuilder | ||
.HasConversion<TType.EfCoreValueConverter, TType.EfCoreValueComparer>(); | ||
} |
41 changes: 41 additions & 0 deletions
41
src/BUTR.Site.NexusMods.Server.ValueObjects.TVO/Models/NexusModsArticleId.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
namespace BUTR.Site.NexusMods.Server.Models; | ||
|
||
using TType = NexusModsArticleId; | ||
using TValueType = Int32; | ||
|
||
[ValueObject<TValueType>] | ||
public readonly partial struct NexusModsArticleId : IAugmentWith<DefaultValueAugment, JsonAugment, EfCoreAugment> | ||
{ | ||
public static readonly TType None = From(0); | ||
|
||
public static TType DefaultValue => None; | ||
|
||
public static bool TryParse(string articleIdRaw, out TType articleId) | ||
{ | ||
var result = TValueType.TryParse(articleIdRaw, out var articleIdVal); | ||
articleId = result ? From(articleIdVal) : DefaultValue; | ||
return result; | ||
} | ||
|
||
public static bool TryParseUrl(string? urlRaw, out TType articleId) | ||
{ | ||
articleId = From(0); | ||
|
||
if (!Uri.TryCreate(urlRaw, UriKind.Absolute, out var url)) | ||
return false; | ||
|
||
if (!url.Host.EndsWith("nexusmods.com")) | ||
return false; | ||
|
||
if (url.LocalPath.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) is not [_, _, var articleIdRaw, ..]) | ||
return false; | ||
|
||
return TryParse(articleIdRaw, out articleId); | ||
} | ||
} | ||
|
||
public static class NexusModsArticleIdExtension | ||
{ | ||
public static PropertyBuilder<TType> HasValueObjectConversion(this PropertyBuilder<TType> propertyBuilder) => propertyBuilder | ||
.HasConversion<TType.EfCoreValueConverter, TType.EfCoreValueComparer>(); | ||
} |
16 changes: 16 additions & 0 deletions
16
src/BUTR.Site.NexusMods.Server.ValueObjects.TVO/Models/NexusModsFileId.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace BUTR.Site.NexusMods.Server.Models; | ||
|
||
using TType = NexusModsFileId; | ||
using TValueType = Int32; | ||
|
||
[ValueObject<TValueType>] | ||
public readonly partial struct NexusModsFileId : IAugmentWith<DefaultValueAugment, JsonAugment, EfCoreAugment> | ||
{ | ||
public static TType DefaultValue => From(0); | ||
} | ||
|
||
public static class NexusModsFileIdExtension | ||
{ | ||
public static PropertyBuilder<TType> HasValueObjectConversion(this PropertyBuilder<TType> propertyBuilder) => propertyBuilder | ||
.HasConversion<TType.EfCoreValueConverter, TType.EfCoreValueComparer>(); | ||
} |
Oops, something went wrong.