Skip to content

Commit 18b373c

Browse files
authored
Merge pull request #6 from TheArchitectDev/fix/1.0.3-GeneratedMarkerAndBugFix
1.0.3: Added "Generated" marker to types and fixed a bug.
2 parents 149623f + 715500d commit 18b373c

13 files changed

+27
-15
lines changed

DomainModeling.Generator/DummyBuilderGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ namespace {containingNamespace}
271271
/// That way, if the constructor changes, only the builder needs to be adjusted, rather than lots of test methods.
272272
/// </para>
273273
/// </summary>
274-
public partial class {typeName}
274+
/* Generated */ public partial class {typeName}
275275
{{
276276
#nullable disable
277277

DomainModeling.Generator/IdentityGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ namespace {containingNamespace}
309309
{(existingComponents.HasFlags(IdTypeComponents.NewtonsoftJsonConverter) ? "*/" : "")}
310310
311311
{(hasSourceGeneratedAttribute ? "" : "[SourceGenerated]")}
312-
{accessibility.ToCodeString()} readonly{(entityTypeName is null ? " partial" : "")} struct {idTypeName} : {Constants.IdentityInterfaceTypeName}<{underlyingTypeFullyQualifiedName}>, IEquatable<{idTypeName}>, IComparable<{idTypeName}>
312+
{(entityTypeName is null ? "/* Generated */ " : "")}{accessibility.ToCodeString()} readonly{(entityTypeName is null ? " partial" : "")} struct {idTypeName} : {Constants.IdentityInterfaceTypeName}<{underlyingTypeFullyQualifiedName}>, IEquatable<{idTypeName}>, IComparable<{idTypeName}>
313313
{{
314314
{(existingComponents.HasFlags(IdTypeComponents.Value) ? "/*" : "")}
315315
{nonNullStringSummary}

DomainModeling.Generator/SourceGeneratedAttributeAnalyzer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ private static bool FilterSyntaxNode(SyntaxNode node, CancellationToken cancella
4848
var hasMissingPartialKeyword = !tds.Modifiers.Any(SyntaxKind.PartialKeyword);
4949

5050
string? expectedTypeName = null;
51-
if (type.IsOrImplementsInterface(type => type.Arity == 1 && type.IsType(Constants.IdentityInterfaceTypeName, Constants.DomainModelingNamespace), out _))
52-
expectedTypeName = tds is StructDeclarationSyntax ? null : "struct"; // Expect a struct
53-
else if (type.IsOrInheritsClass(type => type.Arity == 1 && type.IsType(Constants.WrapperValueObjectTypeName, Constants.DomainModelingNamespace), out _))
51+
if (type.IsOrInheritsClass(type => type.Arity == 1 && type.IsType(Constants.WrapperValueObjectTypeName, Constants.DomainModelingNamespace), out _))
5452
expectedTypeName = tds is ClassDeclarationSyntax ? null : "class"; // Expect a class
5553
else if (type.IsOrInheritsClass(type => type.Arity == 0 && type.IsType(Constants.ValueObjectTypeName, Constants.DomainModelingNamespace), out _))
5654
expectedTypeName = tds is ClassDeclarationSyntax ? null : "class"; // Expect a class
5755
else if (type.IsOrInheritsClass(type => type.Arity == 2 && type.IsType(Constants.DummyBuilderTypeName, Constants.DomainModelingNamespace), out _))
5856
expectedTypeName = tds is ClassDeclarationSyntax ? null : "class"; // Expect a class
57+
else if (type.IsOrImplementsInterface(type => type.Arity == 1 && type.IsType(Constants.IdentityInterfaceTypeName, Constants.DomainModelingNamespace), out _))
58+
expectedTypeName = tds is StructDeclarationSyntax ? null : "struct"; // Expect a struct
5959
else
6060
expectedTypeName = "*"; // No suitable inheritance found for source generation
6161

DomainModeling.Generator/ValueObjectGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ namespace {containingNamespace}
252252
[Serializable]
253253
{(existingComponents.HasFlags(ValueObjectTypeComponents.SerializableAttribute) ? "*/" : "")}
254254
255-
{type.DeclaredAccessibility.ToCodeString()} sealed partial {(isRecord ? "record" : "class")} {typeName} : IEquatable<{typeName}>{(isComparable ? "" : "/*")}, IComparable<{typeName}>{(isComparable ? "" : "*/")}
255+
/* Generated */ {type.DeclaredAccessibility.ToCodeString()} sealed partial {(isRecord ? "record" : "class")} {typeName} : IEquatable<{typeName}>{(isComparable ? "" : "/*")}, IComparable<{typeName}>{(isComparable ? "" : "*/")}
256256
{{
257257
{(isRecord || existingComponents.HasFlags(ValueObjectTypeComponents.StringComparison) ? "/*" : "")}
258258
{(dataMembers.Any(member => member.Type.IsType<string>())

DomainModeling.Generator/WrapperValueObjectGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ namespace {containingNamespace}
222222
[Newtonsoft.Json.JsonConverter(typeof({typeName}.NewtonsoftJsonConverter))]
223223
{(existingComponents.HasFlags(WrapperValueObjectTypeComponents.NewtonsoftJsonConverter) ? "*/" : "")}
224224
225-
{type.DeclaredAccessibility.ToCodeString()} sealed partial class {typeName} : IEquatable<{typeName}>{(isComparable ? "" : "/*")}, IComparable<{typeName}>{(isComparable ? "" : "*/")}
225+
/* Generated */ {type.DeclaredAccessibility.ToCodeString()} sealed partial class {typeName} : IEquatable<{typeName}>{(isComparable ? "" : "/*")}, IComparable<{typeName}>{(isComparable ? "" : "*/")}
226226
{{
227227
{(existingComponents.HasFlags(WrapperValueObjectTypeComponents.StringComparison) ? "/*" : "")}
228228
{(underlyingType.IsType<string>() ? "" : @"protected sealed override StringComparison StringComparison => throw new NotSupportedException(""This operation applies to string-based value objects only."");")}

DomainModeling.Tests/Comparisons/DictionaryComparerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public void DictionaryEquals_WithSameKeys_ShouldReturnExpectedResultBasedOnValue
133133
{
134134
var left = new Dictionary<int, string>() { [1] = leftValue };
135135
var right = new Dictionary<int, string>() { [1] = rightValue };
136-
136+
137137
var result = DictionaryComparer.DictionaryEquals(left, right);
138138

139139
Assert.Equal(expectedResult, result);

DomainModeling.Tests/DummyBuilderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public sealed class TestEntity : Entity<TestEntityId, string>
6262
public DateTimeOffset ModificationDateTime { get; }
6363
public ushort Count { get; }
6464
public Money Amount { get; }
65-
65+
6666
/// <summary>
6767
/// The type's simplest non-default constructor should be used by the builder.
6868
/// </summary>

DomainModeling.Tests/Entities/EntityTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class EntityTests
1212
public void DefaultId_WithClassId_ShouldEquateAsExpected(int? value, bool expectedResult)
1313
{
1414
var instance = new ClassIdEntity(value is null ? null : new ConcreteId() { Value = value.Value, });
15-
15+
1616
Assert.Equal(expectedResult, instance.HasDefaultId());
1717
}
1818

@@ -176,7 +176,7 @@ public void GetHashCode_WithInterfaceId_ShouldEquateAsExpected(int? value, bool
176176
{
177177
var one = new InterfaceIdEntity(value is null ? null : new ConcreteId() { Value = value.Value, });
178178
var two = new InterfaceIdEntity(value is null ? null : new ConcreteId() { Value = value.Value, });
179-
179+
180180
Assert.Equal(expectedResult, one.GetHashCode().Equals(two.GetHashCode()));
181181
}
182182

DomainModeling.Tests/IdentityTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ public void DeserializeWithNewtonsoftJson_WithDecimal_ShouldReturnExpectedResult
451451
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
452452

453453
Assert.Equal(value, Newtonsoft.Json.JsonConvert.DeserializeObject<DecimalId?>(json)?.Value);
454-
454+
455455
if (json != "null")
456456
Assert.Equal((decimal)value, System.Text.Json.JsonSerializer.Deserialize<DecimalId>(json).Value);
457457
}

DomainModeling.Tests/ValueObjectTests.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,11 @@ public ManualValueObject(int id)
968968
// Use a namespace, since our source generators dislike nested types
969969
namespace ValueObjectTestTypes
970970
{
971+
[SourceGenerated]
972+
public sealed partial class ValueObjectWithIIdentity : ValueObject, IIdentity<int>
973+
{
974+
}
975+
971976
[SourceGenerated]
972977
public sealed partial class IntValue : ValueObject
973978
{
@@ -1102,12 +1107,12 @@ public sealed override int GetHashCode()
11021107
{
11031108
return typeof(FullySelfImplementedValueObject).GetHashCode();
11041109
}
1105-
1110+
11061111
public sealed override bool Equals([AllowNull] object other)
11071112
{
11081113
return other is FullySelfImplementedValueObject otherValue && this.Equals(otherValue);
11091114
}
1110-
1115+
11111116
public bool Equals([AllowNull] FullySelfImplementedValueObject other)
11121117
{
11131118
if (other is null) return false;

0 commit comments

Comments
 (0)