Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/nox.type.abstractions #259

Merged
merged 5 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Nox.Generator.sln
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nox.Secrets.Azure", "Nox.Se
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nox.Secrets.Hashicorp", "Nox.Secrets.Hashicorp\Nox.Secrets.Hashicorp.csproj", "{0B3974A4-121C-486B-964F-9037DAD3C5E8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nox.Types.Abstractions", "Nox.Types.Abstractions\Nox.Types.Abstractions.csproj", "{15E06324-A80A-4CC5-A1DA-524A7FE847C4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -192,6 +194,10 @@ Global
{0B3974A4-121C-486B-964F-9037DAD3C5E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B3974A4-121C-486B-964F-9037DAD3C5E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B3974A4-121C-486B-964F-9037DAD3C5E8}.Release|Any CPU.Build.0 = Release|Any CPU
{15E06324-A80A-4CC5-A1DA-524A7FE847C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{15E06324-A80A-4CC5-A1DA-524A7FE847C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{15E06324-A80A-4CC5-A1DA-524A7FE847C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{15E06324-A80A-4CC5-A1DA-524A7FE847C4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -221,6 +227,7 @@ Global
{9C5DF8EC-0F0C-4FF0-86CC-3BE5181E6292} = {2B151195-53F6-45CD-84D5-F1E18CDFF1B0}
{D017DD5E-2DE1-462A-A891-CAB16C8BF940} = {2B151195-53F6-45CD-84D5-F1E18CDFF1B0}
{0B3974A4-121C-486B-964F-9037DAD3C5E8} = {2B151195-53F6-45CD-84D5-F1E18CDFF1B0}
{15E06324-A80A-4CC5-A1DA-524A7FE847C4} = {110C16ED-A11D-4B5A-ABB2-0E0F4692C77A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0E72B357-9E1E-43B5-9868-8D2B74CB2AF0}
Expand Down
1 change: 1 addition & 0 deletions src/Nox.Generator/Application/DtoGenerator/DtoGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.CodeAnalysis;
using Nox.Solution;
using Nox.Types;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.CodeAnalysis;
using Nox.Generator.Common;
using Nox.Solution;
using Nox.Types;

namespace Nox.Generator.Application.EventGenerator;

Expand Down
2 changes: 1 addition & 1 deletion src/Nox.Generator/Nox.Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
#if DEBUG
if (!Debugger.IsAttached)
{
// Debugger.Launch();
// Debugger.Launch();
}
#endif
// var compilation = context.CompilationProvider.Select((ctx,token) => ctx.GlobalNamespace);
Expand Down
5 changes: 4 additions & 1 deletion src/Nox.Generator/Nox.Generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
<PackageReference Include="YamlDotNet" Version="13.1.1" PrivateAssets="all" GeneratePathProperty="true" />
<PackageReference Include="Humanizer.Core" Version="2.14.1" PrivateAssets="all" GeneratePathProperty="true" />
<PackageReference Include="FluentValidation" Version="11.6.0" PrivateAssets="all" GeneratePathProperty="true" />
<PackageReference Include="System.Text.Json" Version="7.0.3" PrivateAssets="all" GeneratePathProperty="true" />

</ItemGroup>

<ItemGroup>
Expand All @@ -64,8 +66,9 @@
<TargetPathWithTargetPlatformMoniker Include="$(PKGYamlDotNet)\lib\netstandard2.0\YamlDotNet.dll" IncludeRuntimeDependency="false" />
<TargetPathWithTargetPlatformMoniker Include="$(PKGHumanizer_Core)\lib\netstandard2.0\Humanizer.dll" IncludeRuntimeDependency="false" />
<TargetPathWithTargetPlatformMoniker Include="$(PKGFluentValidation)\lib\netstandard2.0\FluentValidation.dll" IncludeRuntimeDependency="false" />
<TargetPathWithTargetPlatformMoniker Include="$(PKGSystem_Text_Json)\lib\netstandard2.0\System.Text.Json.dll" IncludeRuntimeDependency="false" />
<TargetPathWithTargetPlatformMoniker Include="..\..\src\Nox.Solution\bin\$(Configuration)\netstandard2.0\Nox.Solution.dll" IncludeRuntimeDependency="false" />
<TargetPathWithTargetPlatformMoniker Include="..\..\src\Nox.Types\bin\$(Configuration)\netstandard2.0\Nox.Types.dll" IncludeRuntimeDependency="false" />
<TargetPathWithTargetPlatformMoniker Include="..\..\src\Nox.Types.Abstractions\bin\$(Configuration)\netstandard2.0\Nox.Types.Abstractions.dll" IncludeRuntimeDependency="false" />
</ItemGroup>
</Target>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using Nox.Generator.Common;
using Nox.Solution;
using Nox.Types;
using Nox.Types.Extensions;
using System;
using System.Diagnostics;
using System.Linq;

using static Nox.Generator.Common.BaseGenerator;
Expand Down Expand Up @@ -99,7 +101,8 @@ private static void GenerateRelationshipProperty(CodeBuilder code, EntityRelatio

private static void GenerateProperty(CodeBuilder code, NoxSimpleTypeDefinition attribute, bool forceRequired = false)
{
var fields = GetType(attribute.Type);

var fields = GetNoxTypeInformation(attribute.Type);

foreach (var field in fields)
{
Expand All @@ -113,32 +116,11 @@ private static void GenerateProperty(CodeBuilder code, NoxSimpleTypeDefinition a
}
}

// TODO: refactor the structure
private static Tuple<string, string>[] GetType(NoxType type)
{
// TODO: add other types
return type switch
{
NoxType.Text => GetSimpleTypeDefinition(new Text()),
NoxType.Number => GetSimpleTypeDefinition(new Number()),

NoxType.Money => GetMoneyDefinition(),

_ => new[] { new Tuple<string, string>(string.Empty, "string") },
};
}

private static Tuple<string, string>[] GetSimpleTypeDefinition<T, TValueObject>(ValueObject<T, TValueObject> instance) where TValueObject : ValueObject<T, TValueObject>, new()
{
return new[] { new Tuple<string, string>(string.Empty, instance.GetUnderlyingType().ToString()) };
}

private static Tuple<string, string>[] GetMoneyDefinition()
private static Tuple<string, string>[] GetNoxTypeInformation(NoxType noxType)
{
var money = new Money();
return new[] {
new Tuple<string, string>(nameof(money.Amount), money.Amount.GetType().ToString()),
new Tuple<string, string>(nameof(money.CurrencyCode), money.CurrencyCode.GetType().ToString())
};
return noxType.GetComponents()
.Select( kv => new Tuple<string,string>(kv.Key, kv.Value.Name))
.ToArray();

}
}
10 changes: 7 additions & 3 deletions src/Nox.Lib/Nox.Lib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,23 @@
<Pack>true</Pack>
<PackagePath>analyzers\dotnet\cs</PackagePath>
</Content>
<Content Include="..\..\src\Nox.Generator\bin\$(Configuration)\netstandard2.0\Nox.Types.dll">
<Content Include="..\..\src\Nox.Generator\bin\$(Configuration)\netstandard2.0\Nox.Types.Abstractions.dll">
<Pack>true</Pack>
<PackagePath>analyzers\dotnet\cs</PackagePath>
</Content>
<Content Include="..\..\src\Nox.Generator\bin\$(Configuration)\netstandard2.0\FluentValidation.dll">
<Pack>true</Pack>
<PackagePath>analyzers\dotnet\cs</PackagePath>
</Content>
<Content Include="..\..\src\Nox.Generator\bin\$(Configuration)\netstandard2.0\Humanizer.dll">
<Content Include="..\..\src\Nox.Generator\bin\$(Configuration)\netstandard2.0\Humanizer.dll">
<Pack>true</Pack>
<PackagePath>analyzers\dotnet\cs</PackagePath>
</Content>
<Content Include="..\..\src\Nox.Generator\bin\$(Configuration)\netstandard2.0\System.Text.Json.dll">
<Pack>true</Pack>
<PackagePath>analyzers\dotnet\cs</PackagePath>
</Content>
<Content Include="$(OutputPath)\Nox.Types.dll">
<Content Include="$(OutputPath)\Nox.Types.dll">
<Pack>true</Pack>
<PackagePath>lib\$(TargetFramework)</PackagePath>
</Content>
Expand Down
2 changes: 1 addition & 1 deletion src/Nox.Solution/Models/Application/Application.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;
using System.Collections.Generic;

namespace Nox.Solution;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Nox.Solution.Schema;
using Nox.Types.Schema;
using Nox.Types;


namespace Nox.Solution;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;
using Nox.Types;

namespace Nox.Solution;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution;

Expand Down
2 changes: 1 addition & 1 deletion src/Nox.Solution/Models/Domain/Domain.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;
using System.Collections.Generic;

namespace Nox.Solution;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Nox.Solution.Schema;
using Nox.Types;
using Nox.Types.Schema;
using System.Collections.Generic;

namespace Nox.Solution;
Expand Down
3 changes: 2 additions & 1 deletion src/Nox.Solution/Models/Domain/Entities/Entity.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Nox.Solution.Schema;
using Nox.Types;
using Nox.Types.Schema;
using System.Collections.Generic;
using Humanizer;
using Nox.Solution.Events;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Nox.Solution.Schema;
using Nox.Types;
using Nox.Types.Schema;

namespace Nox.Solution.Events;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;
using System.Collections.Generic;

namespace Nox.Solution;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Nox.Solution.Schema;
using Nox.Types;
using Nox.Types.Schema;

namespace Nox.Solution;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


using Nox.Solution.Schema;
using Nox.Types;
using Nox.Types.Schema;

namespace Nox.Solution;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;
using YamlDotNet.Serialization;

namespace Nox.Solution;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution;
[GenerateJsonSchema]
Expand Down
2 changes: 1 addition & 1 deletion src/Nox.Solution/Models/Environment/Environment.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;
using System.Collections.Generic;

namespace Nox.Solution
Expand Down
2 changes: 1 addition & 1 deletion src/Nox.Solution/Models/Infrastructure/Base/ServerBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;
using System.Collections.Generic;
using static Humanizer.In;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Nox.Solution.Schema;
using Nox.Types.Schema;

namespace Nox.Solution;

Expand Down
Loading