Skip to content

Commit b4527f5

Browse files
committed
Cleanup
1 parent a1b94b1 commit b4527f5

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<Copyright>(c) $([System.DateTime]::Now.Year), Pawel Gerr. All rights reserved.</Copyright>
5-
<VersionPrefix>6.0.0</VersionPrefix>
5+
<VersionPrefix>6.0.1</VersionPrefix>
66
<Authors>Pawel Gerr</Authors>
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<PackageProjectUrl>https://github.com/PawelGerr/Thinktecture.Runtime.Extensions</PackageProjectUrl>

src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ public static class ComparerAccessor
1212
public static class Methods
1313
{
1414
public const string CREATE_INVALID_ITEM = "CreateInvalidItem";
15+
public const string VALIDATE_FACTORY_ARGUMENTS = "ValidateFactoryArguments";
1516
}
1617
}

src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/ValueObjects/ValueObjectCodeGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ private void GenerateValidateMethod(bool allowNullKeyMemberInput, bool allowNull
451451
if (_state.FactoryValidationReturnType is not null)
452452
_sb.Append("var ").Append(_FACTORY_ARGUMENTS_VALIDATION_RESULT).Append(" = ");
453453

454-
_sb.Append(@"ValidateFactoryArguments(ref validationResult");
454+
_sb.Append(Constants.Methods.VALIDATE_FACTORY_ARGUMENTS).Append("(ref validationResult");
455455

456456
_sb.RenderArguments(fieldsAndProperties, "ref ", true);
457457

@@ -491,7 +491,7 @@ private void GenerateValidateFactoryArguments()
491491
if (_state.FactoryValidationReturnType is not null)
492492
_sb.Append("private ");
493493

494-
_sb.Append("static partial ").Append(_state.FactoryValidationReturnType ?? "void").Append(" ValidateFactoryArguments(ref global::System.ComponentModel.DataAnnotations.ValidationResult? validationResult");
494+
_sb.Append("static partial ").Append(_state.FactoryValidationReturnType ?? "void").Append(" ").Append(Constants.Methods.VALIDATE_FACTORY_ARGUMENTS).Append("(ref global::System.ComponentModel.DataAnnotations.ValidationResult? validationResult");
495495

496496
_sb.RenderArgumentsWithType(fieldsAndProperties, "ref ", leadingComma: true);
497497

src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/ValueObjects/ValueObjectSourceGeneratorState.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public sealed class ValueObjectSourceGeneratorState : ITypeInformation, IEquatab
77
{
88
public string TypeFullyQualified { get; }
99
public string TypeFullyQualifiedNullable { get; }
10-
public string TypeFullyQualifiedNullAnnotated { get; }
10+
public string TypeFullyQualifiedNullAnnotated => IsReferenceType ? TypeFullyQualifiedNullable : TypeFullyQualified;
1111
public string TypeMinimallyQualified { get; }
1212

1313
public string? Namespace { get; }
@@ -39,16 +39,17 @@ public ValueObjectSourceGeneratorState(
3939
Namespace = type.ContainingNamespace?.IsGlobalNamespace == true ? null : type.ContainingNamespace?.ToString();
4040
TypeFullyQualified = type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
4141
TypeFullyQualifiedNullable = $"{TypeFullyQualified}?";
42-
TypeFullyQualifiedNullAnnotated = type.IsReferenceType ? TypeFullyQualifiedNullable : TypeFullyQualified;
4342
TypeMinimallyQualified = type.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat);
4443
IsReferenceType = type.IsReferenceType;
4544
AssignableInstanceFieldsAndProperties = type.GetAssignableFieldsAndPropertiesAndCheckForReadOnly(factory, true, true, cancellationToken).ToList();
4645
EqualityMembers = GetEqualityMembers();
4746

48-
var factoryValidationReturnType = type.GetMembers()
49-
.OfType<IMethodSymbol>()
50-
.FirstOrDefault(m => m.IsStatic && m.ReturnType.SpecialType != SpecialType.System_Void && m.Name == "ValidateFactoryArguments")?
51-
.ReturnType;
47+
var members = type.GetMembers();
48+
var factoryValidationReturnType = members.IsDefaultOrEmpty
49+
? null
50+
: members.OfType<IMethodSymbol>()
51+
.FirstOrDefault(m => m.IsStatic && m.ReturnType.SpecialType != SpecialType.System_Void && m.Name == Constants.Methods.VALIDATE_FACTORY_ARGUMENTS)?
52+
.ReturnType;
5253

5354
if (factoryValidationReturnType is not null)
5455
{

0 commit comments

Comments
 (0)