Skip to content

Commit

Permalink
using statements were missing in DomainPrimitives generated file
Browse files Browse the repository at this point in the history
  • Loading branch information
Temo Nikolaishvili committed Apr 4, 2024
1 parent 9f370a7 commit 9edeec5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Product>Domain Primitives</Product>
<Company>ALTA Software llc.</Company>
<Copyright>Copyright © 2024 ALTA Software llc.</Copyright>
<Version>2.2.0</Version>
<Version>2.2.1</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
8 changes: 1 addition & 7 deletions src/AltaSoft.DomainPrimitives.Generator/Executor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ private static void Process(GeneratorData data, string ctorCode, DomainPrimitive
}

var builder = new SourceCodeBuilder();
var usings = new List<string>(3) { "System", "System.Numerics", "System.Diagnostics", "System.Runtime.CompilerServices" };
var usings = new List<string>(3) { "System", "System.Numerics", "System.Diagnostics", "System.Runtime.CompilerServices", "AltaSoft.DomainPrimitives" };

if (data.ParentSymbols.Count > 0)
{
Expand Down Expand Up @@ -438,19 +438,13 @@ private static void Process(GeneratorData data, string ctorCode, DomainPrimitive
usings.Add("System.Xml");
usings.Add("System.Xml.Schema");
usings.Add("System.Xml.Serialization");
usings.Add("AltaSoft.DomainPrimitives");
}

var needsMathOperators = data.GenerateAdditionOperators || data.GenerateDivisionOperators ||
data.GenerateMultiplyOperators || data.GenerateSubtractionOperators || data.GenerateModulusOperator;

var isByteOrShort = data.ParentSymbols.Count == 0 && data.UnderlyingType.IsByteOrShort();

if ((needsMathOperators && isByteOrShort) || data.UnderlyingType is DomainPrimitiveUnderlyingType.DateOnly or DomainPrimitiveUnderlyingType.TimeOnly)
{
usings.Add("AltaSoft.DomainPrimitives");
}

builder.AppendSourceHeader("AltaSoft DomainPrimitives Generator");

builder.AppendUsings(usings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ internal static void AddSwaggerOptions(string assemblyName, List<GeneratorData>
usings.Add("Swashbuckle.AspNetCore.SwaggerGen");
usings.Add("Microsoft.OpenApi.Models");
usings.Add("Microsoft.OpenApi.Any");
usings.Add("AltaSoft.DomainPrimitives");
builder.AppendUsings(usings);

builder.AppendLine("[assembly: AltaSoft.DomainPrimitives.DomainPrimitiveAssemblyAttribute]");
Expand Down

0 comments on commit 9edeec5

Please sign in to comment.