From 023667e20b9fb1c64f916c7bd271db158afe274e Mon Sep 17 00:00:00 2001 From: Pawel Gerr Date: Tue, 20 Aug 2024 07:57:33 +0200 Subject: [PATCH] Adding sealed/readonly on class/struct is not necessary anymore, source gen takes this over --- .../BoundaryWithJsonConverter.cs | 2 +- .../ProductCategoryWithJsonConverter.cs | 2 +- .../ProductGroupWithJsonConverter.cs | 2 +- .../ProductTypeWithJsonConverter.cs | 2 +- .../BoundaryWithJsonConverter.cs | 2 +- .../ProductCategoryWithJsonConverter.cs | 2 +- .../ProductGroupWithJsonConverter.cs | 2 +- .../ProductTypeWithJsonConverter.cs | 2 +- .../Database/Description.cs | 2 +- .../Database/DescriptionStruct.cs | 2 +- .../Database/Name.cs | 2 +- .../Database/NameStruct.cs | 2 +- .../Database/TestSmartEnum_Class_IntBased.cs | 2 +- .../TestSmartEnum_Class_StringBased.cs | 2 +- .../Database/TestSmartEnum_Struct_IntBased.cs | 2 +- .../TestSmartEnum_Struct_StringBased.cs | 2 +- .../BoundaryWithMessagePackFormatter.cs | 2 +- .../ProductNameWithMessagePackFormatter.cs | 2 +- .../ProductTypeWithMessagePackFormatter.cs | 2 +- .../SmartEnums/EnumWithBaseClass.cs | 2 +- .../SmartEnums/ProductCategory.cs | 2 +- ...roductCategoryWithCaseSensitiveComparer.cs | 2 +- .../SmartEnums/ProductGroup.cs | 2 +- .../SmartEnums/ProductGroupStruct.cs | 2 +- .../SmartEnums/ProductType.cs | 2 +- .../SmartEnums/SalesCsvImporterType.cs | 2 +- .../ValueObjects/Amount.cs | 2 +- .../ValueObjects/AmountClass.cs | 2 +- .../ValueObjects/Boundary.cs | 2 +- .../ValueObjects/BoundaryWithFactories.cs | 2 +- ...ValueObjectWithCustomEqualityComparison.cs | 2 +- .../ValueObjects/EndDate.cs | 2 +- .../ValueObjects/OtherProductName.cs | 2 +- .../ValueObjects/ProductName.cs | 2 +- .../ValueObjects/ProductNameStruct.cs | 2 +- .../ProductNameWithCaseSensitiveComparer.cs | 2 +- ...tectureRuntimeExtensionsCodeFixProvider.cs | 9 +- .../ThinktectureRuntimeExtensionsAnalyzer.cs | 22 +- .../CodeAnalysis/DiagnosticsDescriptors.cs | 2 - .../SmartEnums/EnumSourceGeneratorState.cs | 8 +- .../SmartEnums/SmartEnumCodeGenerator.cs | 7 +- .../SmartEnums/SmartEnumSourceGenerator.cs | 13 +- .../ComplexValueObjectCodeGenerator.cs | 2 +- .../KeyedValueObjectCodeGenerator.cs | 2 +- .../ValueObjectWithMultipleProperties.cs | 2 +- .../TestClasses/IntBasedEnumWithFormatter.cs | 2 +- .../StringBasedEnumWithFormatter.cs | 2 +- ...ValueObject_Complex_Class_WithFormatter.cs | 2 +- ...alueObject_Complex_Struct_WithFormatter.cs | 2 +- .../ValueObjectWithMultipleProperties.cs | 2 +- .../ValueObjectWithMultipleProperties.cs | 2 +- .../TTRESG001_FieldMustBeReadOnly.cs | 40 +- .../TTRESG002_EnumItemMustBePublic.cs | 12 +- .../TTRESG003_PropertyMustBeReadOnly.cs | 68 ++-- .../TTRESG004_TypeMustBeClassOrStruct.cs | 18 +- .../TTRESG006_TypeMustBePartial.cs | 36 +- ...007_InvalidSignatureOfCreateInvalidItem.cs | 24 +- ...TTRESG009_EnumConstructorsMustBePrivate.cs | 12 +- ...TRESG010_NonValidatableEnumsMustBeClass.cs | 4 +- .../TTRESG011_StructMustBeReadOnly.cs | 187 ---------- ...TTRESG012_EnumKeyPropertyNameNotAllowed.cs | 4 +- ...G014_InnerEnumOnFirstLevelMustBePrivate.cs | 8 +- ...15_InnerEnumOnNonFirstLevelMustBePublic.cs | 6 +- .../TTRESG016_TypeCannotBeNestedClass.cs | 2 +- .../TTRESG017_KeyMemberShouldNotBeNullable.cs | 12 +- ...33_EnumsAndValueObjectsMustNotBeGeneric.cs | 12 +- .../TTRESG034_BaseClassFieldMustBeReadOnly.cs | 72 ++-- ...RESG035_BaseClassPropertyMustBeReadOnly.cs | 124 +++---- .../TTRESG036_EnumKeyShouldNotBeNullable.cs | 12 +- ...037_EnumWithoutDerivedTypesMustBeSealed.cs | 120 ++---- .../TTRESG038_ValueObjectMustBeSealed.cs | 132 ------- ...RESG041_ComparerTypeMustMatchMemberType.cs | 8 +- .../TTRESG042_InitAccessortMustBePrivate.cs | 60 +-- .../TTRESG043_PrimaryConstructorNotAllowed.cs | 12 +- ...4_CustomKeyMemberImplementationNotFound.cs | 4 +- ...stomKeyMemberImplementationTypeMismatch.cs | 8 +- .../TTRESG100_EnumerationHasNoItems.cs | 4 +- ...1_StaticPropertiesAreNotConsideredItems.cs | 4 +- .../EnumSourceGeneratorTests.cs | 348 +++++++++++++++++- .../JsonSmartEnumSourceGeneratorTests.cs | 2 +- .../JsonValueObjectSourceGeneratorTests.cs | 8 +- ...essagePackSmartEnumSourceGeneratorTests.cs | 4 +- ...sagePackValueObjectSourceGeneratorTests.cs | 4 +- ...onsoftJsonSmartEnumSourceGeneratorTests.cs | 6 +- ...softJsonValueObjectSourceGeneratorTests.cs | 4 +- .../ValueObjectSourceGeneratorTests.cs | 58 +-- .../Verifiers/CodeFixVerifier.cs | 2 +- .../TestEnums/EmptyEnum.cs | 2 +- .../TestEnums/EnumWithDuplicateKey.cs | 2 +- .../TestEnums/EnumWithFactory.cs | 2 +- .../TestEnums/IntegerEnum.cs | 2 +- .../TestEnums/KeylessTestEnum.cs | 2 +- .../TestEnums/KeylessTestEnumWithFactory.cs | 2 +- .../TestEnums/StructIntegerEnum.cs | 2 +- .../TestEnums/StructIntegerEnumWithZero.cs | 2 +- .../TestEnums/StructStringEnum.cs | 2 +- .../TestEnums/TestEnum.cs | 2 +- .../TestEnums/TestEnumCaseSensitive.cs | 2 +- .../TestEnums/TestEnumWithCustomError.cs | 2 +- .../TestEnumWithInvalidCreateInvalidItem.cs | 2 +- .../TestEnums/TestEnumWithRenamedKeyMember.cs | 2 +- .../TestEnumWithReservedIdentifier.cs | 2 +- .../TestSmartEnum_Class_DecimalBased.cs | 2 +- .../TestEnums/TestSmartEnum_Class_IntBased.cs | 2 +- .../TestSmartEnum_Class_StringBased.cs | 2 +- .../TestSmartEnum_Struct_IntBased.cs | 2 +- .../TestSmartEnum_Struct_StringBased.cs | 2 +- .../TestEnums/ValidIntegerEnum.cs | 2 +- .../TestEnums/ValidTestEnum.cs | 2 +- .../ValidatableTestEnumCaseSensitive.cs | 2 +- ...ValidatableTestEnumWithRenamedKeyMember.cs | 2 +- .../TestValueObjects/Boundary.cs | 2 +- .../BoundaryWithCustomError.cs | 2 +- .../BoundaryWithCustomFactoryNames.cs | 2 +- .../TestValueObjects/BoundaryWithFactories.cs | 2 +- ...aryWithFactoryAndExplicitImplementation.cs | 2 +- .../TestValueObjects/BoundaryWithStrings.cs | 2 +- .../ComplexValueObjectWithPublicCtor.cs | 2 +- ...mplexValueObjectWithReservedIdentifiers.cs | 2 +- .../DecimalBasedStructValueObject.cs | 2 +- .../IntBasedReferenceValueObject.cs | 2 +- ...erenceValueObjectWithCustomFactoryNames.cs | 2 +- .../IntBasedStructValueObject.cs | 2 +- .../KeyedValueObjectWithPublicCtor.cs | 2 +- ...impleValueObjectWithReservedIdentifiers.cs | 2 +- .../StringBasedReferenceValueObject.cs | 2 +- ...asedReferenceValueObjectWithCustomError.cs | 2 +- ...thEmptyStringInFactoryMethodsYieldsNull.cs | 2 +- ...bjectWithNullInFactoryMethodsYieldsNull.cs | 2 +- .../StringBasedStructValueObject.cs | 2 +- .../StructValueObjectWithoutMembers.cs | 2 +- .../TestValueObjects/TestValueObjectByte.cs | 22 +- .../TestValueObject_Complex_Class.cs | 2 +- .../TestValueObject_Complex_Struct.cs | 2 +- .../ValueObjectWithInitProperties.cs | 2 +- 135 files changed, 810 insertions(+), 898 deletions(-) delete mode 100644 test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG011_StructMustBeReadOnly.cs delete mode 100644 test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG038_ValueObjectMustBeSealed.cs diff --git a/samples/Newtonsoft.Json.AspNetCore.Samples/BoundaryWithJsonConverter.cs b/samples/Newtonsoft.Json.AspNetCore.Samples/BoundaryWithJsonConverter.cs index 24e34a6b..79f8dd08 100644 --- a/samples/Newtonsoft.Json.AspNetCore.Samples/BoundaryWithJsonConverter.cs +++ b/samples/Newtonsoft.Json.AspNetCore.Samples/BoundaryWithJsonConverter.cs @@ -1,7 +1,7 @@ namespace Thinktecture; [ComplexValueObject] -public sealed partial class BoundaryWithJsonConverter +public partial class BoundaryWithJsonConverter { public decimal Lower { get; } public decimal Upper { get; } diff --git a/samples/Newtonsoft.Json.AspNetCore.Samples/ProductCategoryWithJsonConverter.cs b/samples/Newtonsoft.Json.AspNetCore.Samples/ProductCategoryWithJsonConverter.cs index 552a1841..789df60e 100644 --- a/samples/Newtonsoft.Json.AspNetCore.Samples/ProductCategoryWithJsonConverter.cs +++ b/samples/Newtonsoft.Json.AspNetCore.Samples/ProductCategoryWithJsonConverter.cs @@ -1,7 +1,7 @@ namespace Thinktecture; [SmartEnum(IsValidatable = true)] -public sealed partial class ProductCategoryWithJsonConverter +public partial class ProductCategoryWithJsonConverter { public static readonly ProductCategoryWithJsonConverter Fruits = new("Fruits"); public static readonly ProductCategoryWithJsonConverter Dairy = new("Dairy"); diff --git a/samples/Newtonsoft.Json.AspNetCore.Samples/ProductGroupWithJsonConverter.cs b/samples/Newtonsoft.Json.AspNetCore.Samples/ProductGroupWithJsonConverter.cs index 18ed6e2f..f83456ab 100644 --- a/samples/Newtonsoft.Json.AspNetCore.Samples/ProductGroupWithJsonConverter.cs +++ b/samples/Newtonsoft.Json.AspNetCore.Samples/ProductGroupWithJsonConverter.cs @@ -3,7 +3,7 @@ namespace Thinktecture; [SmartEnum(IsValidatable = true)] -public sealed partial class ProductGroupWithJsonConverter +public partial class ProductGroupWithJsonConverter { public static readonly ProductGroupWithJsonConverter Apple = new(1, "Apple", ProductCategory.Fruits); public static readonly ProductGroupWithJsonConverter Orange = new(2, "Orange", ProductCategory.Fruits); diff --git a/samples/Newtonsoft.Json.AspNetCore.Samples/ProductTypeWithJsonConverter.cs b/samples/Newtonsoft.Json.AspNetCore.Samples/ProductTypeWithJsonConverter.cs index 801fdd93..64a48ae2 100644 --- a/samples/Newtonsoft.Json.AspNetCore.Samples/ProductTypeWithJsonConverter.cs +++ b/samples/Newtonsoft.Json.AspNetCore.Samples/ProductTypeWithJsonConverter.cs @@ -1,7 +1,7 @@ namespace Thinktecture; [SmartEnum] -public sealed partial class ProductTypeWithJsonConverter +public partial class ProductTypeWithJsonConverter { public static readonly ProductTypeWithJsonConverter Groceries = new("Groceries"); public static readonly ProductTypeWithJsonConverter Housewares = new("Housewares"); diff --git a/samples/Thinktecture.Runtime.Extensions.AspNetCore.Samples/BoundaryWithJsonConverter.cs b/samples/Thinktecture.Runtime.Extensions.AspNetCore.Samples/BoundaryWithJsonConverter.cs index 24e34a6b..79f8dd08 100644 --- a/samples/Thinktecture.Runtime.Extensions.AspNetCore.Samples/BoundaryWithJsonConverter.cs +++ b/samples/Thinktecture.Runtime.Extensions.AspNetCore.Samples/BoundaryWithJsonConverter.cs @@ -1,7 +1,7 @@ namespace Thinktecture; [ComplexValueObject] -public sealed partial class BoundaryWithJsonConverter +public partial class BoundaryWithJsonConverter { public decimal Lower { get; } public decimal Upper { get; } diff --git a/samples/Thinktecture.Runtime.Extensions.AspNetCore.Samples/ProductCategoryWithJsonConverter.cs b/samples/Thinktecture.Runtime.Extensions.AspNetCore.Samples/ProductCategoryWithJsonConverter.cs index 552a1841..789df60e 100644 --- a/samples/Thinktecture.Runtime.Extensions.AspNetCore.Samples/ProductCategoryWithJsonConverter.cs +++ b/samples/Thinktecture.Runtime.Extensions.AspNetCore.Samples/ProductCategoryWithJsonConverter.cs @@ -1,7 +1,7 @@ namespace Thinktecture; [SmartEnum(IsValidatable = true)] -public sealed partial class ProductCategoryWithJsonConverter +public partial class ProductCategoryWithJsonConverter { public static readonly ProductCategoryWithJsonConverter Fruits = new("Fruits"); public static readonly ProductCategoryWithJsonConverter Dairy = new("Dairy"); diff --git a/samples/Thinktecture.Runtime.Extensions.AspNetCore.Samples/ProductGroupWithJsonConverter.cs b/samples/Thinktecture.Runtime.Extensions.AspNetCore.Samples/ProductGroupWithJsonConverter.cs index 172dc704..2cfb7a46 100644 --- a/samples/Thinktecture.Runtime.Extensions.AspNetCore.Samples/ProductGroupWithJsonConverter.cs +++ b/samples/Thinktecture.Runtime.Extensions.AspNetCore.Samples/ProductGroupWithJsonConverter.cs @@ -3,7 +3,7 @@ namespace Thinktecture; [SmartEnum(IsValidatable = true)] -public sealed partial class ProductGroupWithJsonConverter +public partial class ProductGroupWithJsonConverter { public static readonly ProductGroupWithJsonConverter Apple = new(1, "Apple", ProductCategory.Fruits); public static readonly ProductGroupWithJsonConverter Orange = new(2, "Orange", ProductCategory.Fruits); diff --git a/samples/Thinktecture.Runtime.Extensions.AspNetCore.Samples/ProductTypeWithJsonConverter.cs b/samples/Thinktecture.Runtime.Extensions.AspNetCore.Samples/ProductTypeWithJsonConverter.cs index 801fdd93..64a48ae2 100644 --- a/samples/Thinktecture.Runtime.Extensions.AspNetCore.Samples/ProductTypeWithJsonConverter.cs +++ b/samples/Thinktecture.Runtime.Extensions.AspNetCore.Samples/ProductTypeWithJsonConverter.cs @@ -1,7 +1,7 @@ namespace Thinktecture; [SmartEnum] -public sealed partial class ProductTypeWithJsonConverter +public partial class ProductTypeWithJsonConverter { public static readonly ProductTypeWithJsonConverter Groceries = new("Groceries"); public static readonly ProductTypeWithJsonConverter Housewares = new("Housewares"); diff --git a/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/Description.cs b/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/Description.cs index 5d9bfe1b..056e5824 100644 --- a/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/Description.cs +++ b/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/Description.cs @@ -3,7 +3,7 @@ namespace Thinktecture.Database; [ValueObject] -public sealed partial class Description +public partial class Description { static partial void ValidateFactoryArguments(ref ValidationError? validationError, ref string value) { diff --git a/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/DescriptionStruct.cs b/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/DescriptionStruct.cs index 291c3e63..98de8cda 100644 --- a/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/DescriptionStruct.cs +++ b/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/DescriptionStruct.cs @@ -3,7 +3,7 @@ namespace Thinktecture.Database; [ValueObject] -public readonly partial struct DescriptionStruct +public partial struct DescriptionStruct { static partial void ValidateFactoryArguments(ref ValidationError? validationError, ref string value) { diff --git a/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/Name.cs b/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/Name.cs index 08b8ca50..dd79e430 100644 --- a/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/Name.cs +++ b/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/Name.cs @@ -3,7 +3,7 @@ namespace Thinktecture.Database; [ValueObject] -public sealed partial class Name +public partial class Name { static partial void ValidateFactoryArguments(ref ValidationError? validationError, ref string value) { diff --git a/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/NameStruct.cs b/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/NameStruct.cs index ed774a87..3c7b5b20 100644 --- a/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/NameStruct.cs +++ b/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/NameStruct.cs @@ -3,7 +3,7 @@ namespace Thinktecture.Database; [ValueObject] -public readonly partial struct NameStruct +public partial struct NameStruct { static partial void ValidateFactoryArguments(ref ValidationError? validationError, ref string value) { diff --git a/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/TestSmartEnum_Class_IntBased.cs b/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/TestSmartEnum_Class_IntBased.cs index a27cfe7e..dd95f39d 100644 --- a/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/TestSmartEnum_Class_IntBased.cs +++ b/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/TestSmartEnum_Class_IntBased.cs @@ -2,7 +2,7 @@ namespace Thinktecture.Database; // ReSharper disable InconsistentNaming [SmartEnum] -public sealed partial class TestSmartEnum_Class_IntBased +public partial class TestSmartEnum_Class_IntBased { public static readonly TestSmartEnum_Class_IntBased Value1 = new(0); public static readonly TestSmartEnum_Class_IntBased Value2 = new(1); diff --git a/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/TestSmartEnum_Class_StringBased.cs b/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/TestSmartEnum_Class_StringBased.cs index fa42e161..b11e3a9b 100644 --- a/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/TestSmartEnum_Class_StringBased.cs +++ b/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/TestSmartEnum_Class_StringBased.cs @@ -2,7 +2,7 @@ namespace Thinktecture.Database; // ReSharper disable InconsistentNaming [SmartEnum] -public sealed partial class TestSmartEnum_Class_StringBased +public partial class TestSmartEnum_Class_StringBased { public static readonly TestSmartEnum_Class_StringBased Value1 = new("Value1"); public static readonly TestSmartEnum_Class_StringBased Value2 = new("Value2"); diff --git a/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/TestSmartEnum_Struct_IntBased.cs b/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/TestSmartEnum_Struct_IntBased.cs index 20679966..230de9b2 100644 --- a/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/TestSmartEnum_Struct_IntBased.cs +++ b/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/TestSmartEnum_Struct_IntBased.cs @@ -2,7 +2,7 @@ namespace Thinktecture.Database; // ReSharper disable InconsistentNaming [SmartEnum(IsValidatable = true)] -public readonly partial struct TestSmartEnum_Struct_IntBased +public partial struct TestSmartEnum_Struct_IntBased { public static readonly TestSmartEnum_Struct_IntBased Value1 = new(0); public static readonly TestSmartEnum_Struct_IntBased Value2 = new(1); diff --git a/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/TestSmartEnum_Struct_StringBased.cs b/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/TestSmartEnum_Struct_StringBased.cs index 532a4646..eb7470df 100644 --- a/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/TestSmartEnum_Struct_StringBased.cs +++ b/samples/Thinktecture.Runtime.Extensions.Benchmarking/Database/TestSmartEnum_Struct_StringBased.cs @@ -2,7 +2,7 @@ namespace Thinktecture.Database; // ReSharper disable InconsistentNaming [SmartEnum(IsValidatable = true)] -public readonly partial struct TestSmartEnum_Struct_StringBased +public partial struct TestSmartEnum_Struct_StringBased { public static readonly TestSmartEnum_Struct_StringBased Value1 = new("Value1"); public static readonly TestSmartEnum_Struct_StringBased Value2 = new("Value2"); diff --git a/samples/Thinktecture.Runtime.Extensions.MessagePack.Samples/BoundaryWithMessagePackFormatter.cs b/samples/Thinktecture.Runtime.Extensions.MessagePack.Samples/BoundaryWithMessagePackFormatter.cs index abd33d8a..0b8561b7 100644 --- a/samples/Thinktecture.Runtime.Extensions.MessagePack.Samples/BoundaryWithMessagePackFormatter.cs +++ b/samples/Thinktecture.Runtime.Extensions.MessagePack.Samples/BoundaryWithMessagePackFormatter.cs @@ -1,7 +1,7 @@ namespace Thinktecture; [ComplexValueObject] -public sealed partial class BoundaryWithMessagePackFormatter +public partial class BoundaryWithMessagePackFormatter { public decimal Lower { get; } public decimal Upper { get; } diff --git a/samples/Thinktecture.Runtime.Extensions.MessagePack.Samples/ProductNameWithMessagePackFormatter.cs b/samples/Thinktecture.Runtime.Extensions.MessagePack.Samples/ProductNameWithMessagePackFormatter.cs index 7d786d48..0da66d29 100644 --- a/samples/Thinktecture.Runtime.Extensions.MessagePack.Samples/ProductNameWithMessagePackFormatter.cs +++ b/samples/Thinktecture.Runtime.Extensions.MessagePack.Samples/ProductNameWithMessagePackFormatter.cs @@ -3,7 +3,7 @@ namespace Thinktecture; [ValueObject(NullInFactoryMethodsYieldsNull = true)] -public sealed partial class ProductNameWithMessagePackFormatter +public partial class ProductNameWithMessagePackFormatter { static partial void ValidateFactoryArguments(ref ValidationError? validationError, ref string value) { diff --git a/samples/Thinktecture.Runtime.Extensions.MessagePack.Samples/ProductTypeWithMessagePackFormatter.cs b/samples/Thinktecture.Runtime.Extensions.MessagePack.Samples/ProductTypeWithMessagePackFormatter.cs index 4d6ea4d1..a25ae97c 100644 --- a/samples/Thinktecture.Runtime.Extensions.MessagePack.Samples/ProductTypeWithMessagePackFormatter.cs +++ b/samples/Thinktecture.Runtime.Extensions.MessagePack.Samples/ProductTypeWithMessagePackFormatter.cs @@ -1,7 +1,7 @@ namespace Thinktecture; [SmartEnum] -public sealed partial class ProductTypeWithMessagePackFormatter +public partial class ProductTypeWithMessagePackFormatter { public static readonly ProductTypeWithMessagePackFormatter Groceries = new("Groceries"); public static readonly ProductTypeWithMessagePackFormatter Housewares = new("Housewares"); diff --git a/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/EnumWithBaseClass.cs b/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/EnumWithBaseClass.cs index e0a8359d..5cdc7079 100644 --- a/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/EnumWithBaseClass.cs +++ b/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/EnumWithBaseClass.cs @@ -1,7 +1,7 @@ namespace Thinktecture.SmartEnums; [SmartEnum] -public sealed partial class EnumWithBaseClass : SomeBaseClass +public partial class EnumWithBaseClass : SomeBaseClass { public static readonly EnumWithBaseClass Item1 = new("item 1", 42); } diff --git a/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductCategory.cs b/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductCategory.cs index 79110d34..ede4a159 100644 --- a/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductCategory.cs +++ b/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductCategory.cs @@ -2,7 +2,7 @@ namespace Thinktecture.SmartEnums; [SmartEnum(IsValidatable = true, KeyMemberName = "Name")] -public sealed partial class ProductCategory +public partial class ProductCategory { public static readonly ProductCategory Fruits = new("Fruits"); public static readonly ProductCategory Dairy = new("Dairy"); diff --git a/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductCategoryWithCaseSensitiveComparer.cs b/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductCategoryWithCaseSensitiveComparer.cs index 43c0954c..f0e1e418 100644 --- a/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductCategoryWithCaseSensitiveComparer.cs +++ b/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductCategoryWithCaseSensitiveComparer.cs @@ -3,7 +3,7 @@ namespace Thinktecture.SmartEnums; [SmartEnum] [ValueObjectKeyMemberComparer] [ValueObjectKeyMemberEqualityComparer] -public sealed partial class ProductCategoryWithCaseSensitiveComparer +public partial class ProductCategoryWithCaseSensitiveComparer { public static readonly ProductCategoryWithCaseSensitiveComparer FruitsLowerCased = new("fruits"); public static readonly ProductCategoryWithCaseSensitiveComparer FruitsUpperCased = new("FRUITS"); diff --git a/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductGroup.cs b/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductGroup.cs index 03f39ada..91de2730 100644 --- a/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductGroup.cs +++ b/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductGroup.cs @@ -3,7 +3,7 @@ namespace Thinktecture.SmartEnums; [SmartEnum(IsValidatable = true, ComparisonOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, SkipToString = true)] -public sealed partial class ProductGroup +public partial class ProductGroup { public static readonly ProductGroup Apple = new(1, "Apple", ProductCategory.Fruits); public static readonly ProductGroup Orange = new(2, "Orange", ProductCategory.Fruits); diff --git a/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductGroupStruct.cs b/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductGroupStruct.cs index a67abcc4..6fb247da 100644 --- a/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductGroupStruct.cs +++ b/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductGroupStruct.cs @@ -4,7 +4,7 @@ namespace Thinktecture.SmartEnums; ComparisonOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, SwitchMethods = SwitchMapMethodsGeneration.DefaultWithPartialOverloads, MapMethods = SwitchMapMethodsGeneration.DefaultWithPartialOverloads)] -public readonly partial struct ProductGroupStruct +public partial struct ProductGroupStruct { public static readonly ProductGroupStruct Apple = new(1); public static readonly ProductGroupStruct Orange = new(2); diff --git a/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductType.cs b/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductType.cs index 267351c9..855f3501 100644 --- a/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductType.cs +++ b/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductType.cs @@ -3,7 +3,7 @@ namespace Thinktecture.SmartEnums; [SmartEnum(SwitchMethods = SwitchMapMethodsGeneration.DefaultWithPartialOverloads, MapMethods = SwitchMapMethodsGeneration.DefaultWithPartialOverloads)] [ValueObjectValidationError] -public sealed partial class ProductType +public partial class ProductType { public static readonly ProductType Groceries = new("Groceries"); public static readonly ProductType Housewares = new("Housewares"); diff --git a/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/SalesCsvImporterType.cs b/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/SalesCsvImporterType.cs index 1359d751..4c77e3e8 100644 --- a/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/SalesCsvImporterType.cs +++ b/samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/SalesCsvImporterType.cs @@ -4,7 +4,7 @@ namespace Thinktecture.SmartEnums; [SmartEnum] -public sealed partial class SalesCsvImporterType +public partial class SalesCsvImporterType { public static readonly SalesCsvImporterType Daily = new(articleIdIndex: 0, volumeIndex: 2, GetDateTimeForDaily); public static readonly SalesCsvImporterType Monthly = new(articleIdIndex: 2, volumeIndex: 0, GetDateTimeForMonthly); diff --git a/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/Amount.cs b/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/Amount.cs index 9c0c0ee8..82c2f43b 100644 --- a/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/Amount.cs +++ b/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/Amount.cs @@ -6,7 +6,7 @@ namespace Thinktecture.ValueObjects; SubtractionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, MultiplyOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, DivisionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads)] -public readonly partial struct Amount +public partial struct Amount { static partial void ValidateFactoryArguments(ref ValidationError? validationError, ref decimal value) { diff --git a/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/AmountClass.cs b/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/AmountClass.cs index 2a17111e..7ad58cf6 100644 --- a/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/AmountClass.cs +++ b/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/AmountClass.cs @@ -5,7 +5,7 @@ namespace Thinktecture.ValueObjects; SubtractionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, MultiplyOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, DivisionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads)] -public sealed partial class AmountClass +public partial class AmountClass { static partial void ValidateFactoryArguments(ref ValidationError? validationError, ref int value) { diff --git a/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/Boundary.cs b/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/Boundary.cs index f6c15e93..30fa2078 100644 --- a/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/Boundary.cs +++ b/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/Boundary.cs @@ -2,7 +2,7 @@ namespace Thinktecture.ValueObjects; [ComplexValueObject] [ValueObjectValidationError] -public sealed partial class Boundary +public partial class Boundary { public decimal Lower { get; } public decimal Upper { get; } diff --git a/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/BoundaryWithFactories.cs b/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/BoundaryWithFactories.cs index 7026fc81..d0260554 100644 --- a/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/BoundaryWithFactories.cs +++ b/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/BoundaryWithFactories.cs @@ -5,7 +5,7 @@ namespace Thinktecture.ValueObjects; [ComplexValueObject] [ValueObjectFactory(UseForSerialization = SerializationFrameworks.All)] [ValueObjectFactory>] -public sealed partial class BoundaryWithFactories +public partial class BoundaryWithFactories { public decimal Lower { get; } public decimal Upper { get; } diff --git a/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/ComplexValueObjectWithCustomEqualityComparison.cs b/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/ComplexValueObjectWithCustomEqualityComparison.cs index f4e7c3d3..acf554b5 100644 --- a/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/ComplexValueObjectWithCustomEqualityComparison.cs +++ b/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/ComplexValueObjectWithCustomEqualityComparison.cs @@ -1,7 +1,7 @@ namespace Thinktecture.ValueObjects; [ComplexValueObject(SkipToString = true)] -public sealed partial class ComplexValueObjectWithCustomEqualityComparison +public partial class ComplexValueObjectWithCustomEqualityComparison { [ValueObjectMemberEqualityComparer] public string Identifier { get; } diff --git a/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/EndDate.cs b/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/EndDate.cs index 9ac2c76f..2db17c3e 100644 --- a/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/EndDate.cs +++ b/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/EndDate.cs @@ -6,7 +6,7 @@ namespace Thinktecture.ValueObjects; KeyMemberName = "Date", // Source Generator needs to know the name we've chosen DefaultInstancePropertyName = "Infinite", // "EndDate.Infinite" represent an open-ended end date EqualityComparisonOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads)] // for comparison with DateOnly without implicit cast -public readonly partial struct EndDate +public partial struct EndDate { private readonly DateOnly? _date; diff --git a/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/OtherProductName.cs b/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/OtherProductName.cs index 57722d6f..eb2d0597 100644 --- a/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/OtherProductName.cs +++ b/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/OtherProductName.cs @@ -3,7 +3,7 @@ namespace Thinktecture.ValueObjects; [ValueObject(EmptyStringInFactoryMethodsYieldsNull = true)] -public sealed partial class OtherProductName +public partial class OtherProductName { static partial void ValidateFactoryArguments(ref ValidationError? validationError, ref string value) { diff --git a/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/ProductName.cs b/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/ProductName.cs index 09b1334d..9c0f7ff9 100644 --- a/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/ProductName.cs +++ b/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/ProductName.cs @@ -3,7 +3,7 @@ namespace Thinktecture.ValueObjects; [ValueObject(NullInFactoryMethodsYieldsNull = true)] -public sealed partial class ProductName +public partial class ProductName { static partial void ValidateFactoryArguments(ref ValidationError? validationError, ref string value) { diff --git a/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/ProductNameStruct.cs b/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/ProductNameStruct.cs index a9f74545..5af8d280 100644 --- a/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/ProductNameStruct.cs +++ b/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/ProductNameStruct.cs @@ -3,7 +3,7 @@ namespace Thinktecture.ValueObjects; [ValueObject(DefaultInstancePropertyName = "None")] -public readonly partial struct ProductNameStruct +public partial struct ProductNameStruct { static partial void ValidateFactoryArguments(ref ValidationError? validationError, ref string value) { diff --git a/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/ProductNameWithCaseSensitiveComparer.cs b/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/ProductNameWithCaseSensitiveComparer.cs index dcdd7351..82bbf2dc 100644 --- a/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/ProductNameWithCaseSensitiveComparer.cs +++ b/samples/Thinktecture.Runtime.Extensions.Samples/ValueObjects/ProductNameWithCaseSensitiveComparer.cs @@ -3,6 +3,6 @@ namespace Thinktecture.ValueObjects; [ValueObject] [ValueObjectKeyMemberComparer] [ValueObjectKeyMemberEqualityComparer] -public sealed partial class ProductNameWithCaseSensitiveComparer +public partial class ProductNameWithCaseSensitiveComparer { } diff --git a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/CodeFixes/ThinktectureRuntimeExtensionsCodeFixProvider.cs b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/CodeFixes/ThinktectureRuntimeExtensionsCodeFixProvider.cs index a05829f4..bdda96ad 100644 --- a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/CodeFixes/ThinktectureRuntimeExtensionsCodeFixProvider.cs +++ b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/CodeFixes/ThinktectureRuntimeExtensionsCodeFixProvider.cs @@ -9,7 +9,6 @@ namespace Thinktecture.CodeAnalysis.CodeFixes; public sealed class ThinktectureRuntimeExtensionsCodeFixProvider : CodeFixProvider { private const string _MAKE_PARTIAL = "Make the type partial"; - private const string _MAKE_STRUCT_READONLY = "Make the type read-only"; private const string _MAKE_MEMBER_PUBLIC = "Make the member public"; private const string _MAKE_FIELD_READONLY = "Make the field read-only"; private const string _REMOVE_PROPERTY_SETTER = "Remove property setter"; @@ -21,7 +20,6 @@ public sealed class ThinktectureRuntimeExtensionsCodeFixProvider : CodeFixProvid /// public override ImmutableArray FixableDiagnosticIds { get; } = ImmutableArray.Create(DiagnosticsDescriptors.TypeMustBePartial.Id, - DiagnosticsDescriptors.StructMustBeReadOnly.Id, DiagnosticsDescriptors.EnumItemMustBePublic.Id, DiagnosticsDescriptors.FieldMustBeReadOnly.Id, DiagnosticsDescriptors.PropertyMustBeReadOnly.Id, @@ -29,7 +27,6 @@ public sealed class ThinktectureRuntimeExtensionsCodeFixProvider : CodeFixProvid DiagnosticsDescriptors.InnerEnumOnFirstLevelMustBePrivate.Id, DiagnosticsDescriptors.InnerEnumOnNonFirstLevelMustBePublic.Id, DiagnosticsDescriptors.EnumWithoutDerivedTypesMustBeSealed.Id, - DiagnosticsDescriptors.ValueObjectMustBeSealed.Id, DiagnosticsDescriptors.InitAccessorMustBePrivate.Id); /// @@ -55,10 +52,6 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) { context.RegisterCodeFix(CodeAction.Create(_MAKE_PARTIAL, _ => AddTypeModifierAsync(context.Document, root, GetCodeFixesContext().TypeDeclaration, SyntaxKind.PartialKeyword), _MAKE_PARTIAL), diagnostic); } - else if (diagnostic.Id == DiagnosticsDescriptors.StructMustBeReadOnly.Id) - { - context.RegisterCodeFix(CodeAction.Create(_MAKE_STRUCT_READONLY, _ => AddTypeModifierAsync(context.Document, root, GetCodeFixesContext().TypeDeclaration, SyntaxKind.ReadOnlyKeyword), _MAKE_STRUCT_READONLY), diagnostic); - } else if (diagnostic.Id == DiagnosticsDescriptors.FieldMustBeReadOnly.Id) { context.RegisterCodeFix(CodeAction.Create(_MAKE_FIELD_READONLY, _ => AddTypeModifierAsync(context.Document, root, GetCodeFixesContext().FieldDeclaration, SyntaxKind.ReadOnlyKeyword), _MAKE_FIELD_READONLY), diagnostic); @@ -87,7 +80,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) { context.RegisterCodeFix(CodeAction.Create(_MAKE_TYPE_PUBLIC, _ => ChangeAccessibilityAsync(context.Document, root, GetCodeFixesContext().TypeDeclaration, SyntaxKind.PublicKeyword), _MAKE_TYPE_PUBLIC), diagnostic); } - else if (diagnostic.Id == DiagnosticsDescriptors.EnumWithoutDerivedTypesMustBeSealed.Id || diagnostic.Id == DiagnosticsDescriptors.ValueObjectMustBeSealed.Id) + else if (diagnostic.Id == DiagnosticsDescriptors.EnumWithoutDerivedTypesMustBeSealed.Id) { context.RegisterCodeFix(CodeAction.Create(_SEAL_CLASS, _ => AddTypeModifierAsync(context.Document, root, GetCodeFixesContext().TypeDeclaration, SyntaxKind.SealedKeyword), _SEAL_CLASS), diagnostic); } diff --git a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/Diagnostics/ThinktectureRuntimeExtensionsAnalyzer.cs b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/Diagnostics/ThinktectureRuntimeExtensionsAnalyzer.cs index 443c321c..6685d1fb 100644 --- a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/Diagnostics/ThinktectureRuntimeExtensionsAnalyzer.cs +++ b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/Diagnostics/ThinktectureRuntimeExtensionsAnalyzer.cs @@ -15,7 +15,6 @@ public sealed class ThinktectureRuntimeExtensionsAnalyzer : DiagnosticAnalyzer /// public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Create(DiagnosticsDescriptors.TypeMustBePartial, - DiagnosticsDescriptors.StructMustBeReadOnly, DiagnosticsDescriptors.TypeMustBeClassOrStruct, DiagnosticsDescriptors.NonValidatableEnumsMustBeClass, DiagnosticsDescriptors.EnumConstructorsMustBePrivate, @@ -36,7 +35,6 @@ public sealed class ThinktectureRuntimeExtensionsAnalyzer : DiagnosticAnalyzer DiagnosticsDescriptors.BaseClassPropertyMustBeReadOnly, DiagnosticsDescriptors.EnumKeyShouldNotBeNullable, DiagnosticsDescriptors.EnumWithoutDerivedTypesMustBeSealed, - DiagnosticsDescriptors.ValueObjectMustBeSealed, DiagnosticsDescriptors.ComparerTypeMustMatchMemberType, DiagnosticsDescriptors.ErrorDuringCodeAnalysis, DiagnosticsDescriptors.InitAccessorMustBePrivate, @@ -304,7 +302,6 @@ private static void ValidateCustomKeyMemberImplementation( EnsureNoPrimaryConstructor(context, type); TypeMustBePartial(context, type); TypeMustNotBeGeneric(context, type, locationOfFirstDeclaration, "Value Object"); - StructMustBeReadOnly(context, type, locationOfFirstDeclaration); var nonIgnoredItems = type.GetNonIgnoredMembers(); var assignableMembers = type.GetAssignableFieldsAndPropertiesAndCheckForReadOnly(nonIgnoredItems, factory, false, true, context.CancellationToken, context) @@ -320,9 +317,6 @@ private static void ValidateCustomKeyMemberImplementation( baseClass = baseClass.BaseType; } - if (type is { IsSealed: false, IsAbstract: false }) - ReportDiagnostic(context, DiagnosticsDescriptors.ValueObjectMustBeSealed, locationOfFirstDeclaration, type); - return assignableMembers; } @@ -389,7 +383,6 @@ private static void ValidateEnum( ConstructorsMustBePrivate(context, enumType); TypeMustBePartial(context, enumType); TypeMustNotBeGeneric(context, enumType, locationOfFirstDeclaration, "Enumeration"); - StructMustBeReadOnly(context, enumType, locationOfFirstDeclaration); var nonIgnoredMembers = enumType.GetNonIgnoredMembers(); var items = enumType.GetEnumItems(nonIgnoredMembers); @@ -411,10 +404,7 @@ private static void ValidateEnum( baseClass = baseClass.BaseType; } - var derivedTypes = ValidateDerivedTypes(context, enumType); - - if (enumType is { IsSealed: false, IsAbstract: false } && derivedTypes.Count == 0) - ReportDiagnostic(context, DiagnosticsDescriptors.EnumWithoutDerivedTypesMustBeSealed, locationOfFirstDeclaration, enumType); + ValidateDerivedTypes(context, enumType); EnumKeyMemberNameMustNotBeItem(context, attribute, locationOfFirstDeclaration); @@ -476,7 +466,7 @@ private static void Check_ItemLike_StaticProperties( } } - private static IReadOnlyList<(INamedTypeSymbol Type, int Level)> ValidateDerivedTypes(OperationAnalysisContext context, INamedTypeSymbol enumType) + private static void ValidateDerivedTypes(OperationAnalysisContext context, INamedTypeSymbol enumType) { var derivedTypes = enumType.FindDerivedInnerEnums(); var typesToLeaveOpen = ImmutableArray.Create(); @@ -506,8 +496,6 @@ private static void Check_ItemLike_StaticProperties( if (!derivedType.Type.IsSealed && !derivedType.Type.IsAbstract && !typesToLeaveOpen.Contains(derivedType.Type, SymbolEqualityComparer.Default)) ReportDiagnostic(context, DiagnosticsDescriptors.EnumWithoutDerivedTypesMustBeSealed, GetDerivedTypeLocation(context, derivedType.Type), derivedType.Type); } - - return derivedTypes; } private static Location GetDerivedTypeLocation(OperationAnalysisContext context, INamedTypeSymbol derivedType) @@ -580,12 +568,6 @@ private static void TypeMustBePartial(OperationAnalysisContext context, INamedTy } } - private static void StructMustBeReadOnly(OperationAnalysisContext context, INamedTypeSymbol type, Location location) - { - if (type is { IsValueType: true, IsReadOnly: false }) - ReportDiagnostic(context, DiagnosticsDescriptors.StructMustBeReadOnly, location, type); - } - private static void ConstructorsMustBePrivate(OperationAnalysisContext context, INamedTypeSymbol type) { if (type.Constructors.IsDefaultOrEmpty) diff --git a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/DiagnosticsDescriptors.cs b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/DiagnosticsDescriptors.cs index 3725f98e..f63a89ad 100644 --- a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/DiagnosticsDescriptors.cs +++ b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/DiagnosticsDescriptors.cs @@ -13,7 +13,6 @@ internal static class DiagnosticsDescriptors public static readonly DiagnosticDescriptor AbstractEnumNeedsCreateInvalidItemImplementation = new("TTRESG008", $"An abstract class needs an implementation of the method '{Constants.Methods.CREATE_INVALID_ITEM}'", $"An abstract class needs an implementation of the method '{Constants.Methods.CREATE_INVALID_ITEM}', the signature should be 'private static {{0}} {Constants.Methods.CREATE_INVALID_ITEM}({{1}} key)'", nameof(ThinktectureRuntimeExtensionsAnalyzer), DiagnosticSeverity.Error, true); public static readonly DiagnosticDescriptor EnumConstructorsMustBePrivate = new("TTRESG009", "An enumeration must have private constructors only", "All constructors of the enumeration '{0}' must be private", nameof(ThinktectureRuntimeExtensionsAnalyzer), DiagnosticSeverity.Error, true); public static readonly DiagnosticDescriptor NonValidatableEnumsMustBeClass = new("TTRESG010", "An non-validatable enumeration must be a class", "A non-validatable enum must be a class", nameof(ThinktectureRuntimeExtensionsAnalyzer), DiagnosticSeverity.Error, true); - public static readonly DiagnosticDescriptor StructMustBeReadOnly = new("TTRESG011", "A struct must be readonly", "A struct must be readonly", nameof(ThinktectureRuntimeExtensionsAnalyzer), DiagnosticSeverity.Error, true); public static readonly DiagnosticDescriptor EnumKeyMemberNameNotAllowed = new("TTRESG012", "Provided key member name is not allowed", "Provided key member name '{0}' is not allowed", nameof(ThinktectureRuntimeExtensionsAnalyzer), DiagnosticSeverity.Error, true); public static readonly DiagnosticDescriptor InnerEnumOnFirstLevelMustBePrivate = new("TTRESG014", "First-level inner enumerations must be private", "Derived inner enumeration '{0}' on first-level must be private", nameof(ThinktectureRuntimeExtensionsAnalyzer), DiagnosticSeverity.Error, true); public static readonly DiagnosticDescriptor InnerEnumOnNonFirstLevelMustBePublic = new("TTRESG015", "Non-first-level inner enumerations must be public", "Derived inner enumeration '{0}' on non-first-level must be public", nameof(ThinktectureRuntimeExtensionsAnalyzer), DiagnosticSeverity.Error, true); @@ -24,7 +23,6 @@ internal static class DiagnosticsDescriptors public static readonly DiagnosticDescriptor BaseClassPropertyMustBeReadOnly = new("TTRESG035", "Property of the base class must be read-only", "The property '{0}' of the base class '{1}' must be read-only", nameof(ThinktectureRuntimeExtensionsAnalyzer), DiagnosticSeverity.Error, true); public static readonly DiagnosticDescriptor EnumKeyShouldNotBeNullable = new("TTRESG036", "The key must not be nullable", "The generic type T of SmartEnumAttribute must not be nullable", nameof(ThinktectureRuntimeExtensionsAnalyzer), DiagnosticSeverity.Error, true); public static readonly DiagnosticDescriptor EnumWithoutDerivedTypesMustBeSealed = new("TTRESG037", "Enumeration without derived types must be sealed", "Enumeration '{0}' without derived types must be sealed", nameof(ThinktectureRuntimeExtensionsAnalyzer), DiagnosticSeverity.Error, true); - public static readonly DiagnosticDescriptor ValueObjectMustBeSealed = new("TTRESG038", "Value objects must be sealed", "Value object '{0}' must be sealed", nameof(ThinktectureRuntimeExtensionsAnalyzer), DiagnosticSeverity.Error, true); public static readonly DiagnosticDescriptor ComparerTypeMustMatchMemberType = new("TTRESG041", "The type of the comparer doesn't match the type of the member", "The comparer '{0}' doesn't match the member type '{1}'", nameof(ThinktectureRuntimeExtensionsAnalyzer), DiagnosticSeverity.Error, true); public static readonly DiagnosticDescriptor InitAccessorMustBePrivate = new("TTRESG042", "Property 'init' accessor must be private", "The 'init' accessor of the property '{0}' of the type '{1}' must be private", nameof(ThinktectureRuntimeExtensionsAnalyzer), DiagnosticSeverity.Error, true); public static readonly DiagnosticDescriptor PrimaryConstructorNotAllowed = new("TTRESG043", "Primary constructor is not allowed in Smart Enums and Value Objects", "Primary constructor is not allowed in Smart Enum/Value Object of type '{0}'", nameof(ThinktectureRuntimeExtensionsAnalyzer), DiagnosticSeverity.Error, true); diff --git a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/SmartEnums/EnumSourceGeneratorState.cs b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/SmartEnums/EnumSourceGeneratorState.cs index 72db10e9..a9fb7bfb 100644 --- a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/SmartEnums/EnumSourceGeneratorState.cs +++ b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/SmartEnums/EnumSourceGeneratorState.cs @@ -15,12 +15,10 @@ public sealed class EnumSourceGeneratorState : ITypeInformation, IEquatable _argumentName ??= Name.MakeArgumentName(); - public EnumItems Items { get; } public IReadOnlyList AssignableInstanceFieldsAndProperties { get; } @@ -32,11 +30,13 @@ public EnumSourceGeneratorState( ImmutableArray nonIgnoredMembers, EnumSettings settings, bool hasCreateInvalidItemImplementation, + bool hasDerivedTypes, CancellationToken cancellationToken) { KeyMember = keyMember; Settings = settings; HasCreateInvalidItemImplementation = hasCreateInvalidItemImplementation; + HasDerivedTypes = hasDerivedTypes; ValidationError = validationError; Name = type.Name; @@ -66,6 +66,7 @@ public bool Equals(EnumSourceGeneratorState? other) return TypeFullyQualified == other.TypeFullyQualified && HasCreateInvalidItemImplementation == other.HasCreateInvalidItemImplementation + && HasDerivedTypes == other.HasDerivedTypes && IsReferenceType == other.IsReferenceType && IsAbstract == other.IsAbstract && Equals(KeyMember, other.KeyMember) @@ -82,6 +83,7 @@ public override int GetHashCode() { var hashCode = TypeFullyQualified.GetHashCode(); hashCode = (hashCode * 397) ^ HasCreateInvalidItemImplementation.GetHashCode(); + hashCode = (hashCode * 397) ^ HasDerivedTypes.GetHashCode(); hashCode = (hashCode * 397) ^ IsReferenceType.GetHashCode(); hashCode = (hashCode * 397) ^ IsAbstract.GetHashCode(); hashCode = (hashCode * 397) ^ (KeyMember?.GetHashCode() ?? 0); diff --git a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/SmartEnums/SmartEnumCodeGenerator.cs b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/SmartEnums/SmartEnumCodeGenerator.cs index 84ce64ff..ff51dacd 100644 --- a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/SmartEnums/SmartEnumCodeGenerator.cs +++ b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/SmartEnums/SmartEnumCodeGenerator.cs @@ -55,7 +55,12 @@ private void GenerateEnum(CancellationToken cancellationToken) } _sb.Append(@" - partial ").Append(_state.IsReferenceType ? "class" : "struct").Append(" ").Append(_state.Name).Append(" :"); + "); + + if (!_state.HasDerivedTypes) + _sb.Append(_state.IsReferenceType ? "sealed " : "readonly "); + + _sb.Append("partial ").Append(_state.IsReferenceType ? "class" : "struct").Append(" ").Append(_state.Name).Append(" :"); if (_state.KeyMember is not null) _sb.Append(" global::Thinktecture.IEnum<").Append(_state.KeyMember.TypeFullyQualified).Append(", ").Append(_state.TypeFullyQualified).Append(", ").Append(_state.ValidationError.TypeFullyQualified).Append(">,"); diff --git a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/SmartEnums/SmartEnumSourceGenerator.cs b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/SmartEnums/SmartEnumSourceGenerator.cs index ad22df84..3b27c1a3 100644 --- a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/SmartEnums/SmartEnumSourceGenerator.cs +++ b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/SmartEnums/SmartEnumSourceGenerator.cs @@ -402,8 +402,17 @@ private bool IsEnumCandidate(TypeDeclarationSyntax typeDeclaration) var nonIgnoredMembers = type.GetNonIgnoredMembers(); var hasCreateInvalidItemImplementation = keyMemberType is not null && settings.IsValidatable && type.HasCreateInvalidItemImplementation(nonIgnoredMembers, keyMemberType, cancellationToken); - var enumState = new EnumSourceGeneratorState(factory, type, keyMember, attributeInfo.ValidationError, nonIgnoredMembers, new EnumSettings(settings, attributeInfo), hasCreateInvalidItemImplementation, cancellationToken); - var derivedTypes = new SmartEnumDerivedTypes(enumState.Namespace, enumState.Name, enumState.TypeFullyQualified, enumState.IsReferenceType, FindDerivedTypes(type)); + var derivedTypeNames = FindDerivedTypes(type); + var enumState = new EnumSourceGeneratorState(factory, + type, + keyMember, + attributeInfo.ValidationError, + nonIgnoredMembers, + new EnumSettings(settings, attributeInfo), + hasCreateInvalidItemImplementation, + derivedTypeNames.Count > 0, + cancellationToken); + var derivedTypes = new SmartEnumDerivedTypes(enumState.Namespace, enumState.Name, enumState.TypeFullyQualified, enumState.IsReferenceType, derivedTypeNames); Logger.LogDebug("The type declaration is a valid smart enum", null, enumState); diff --git a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/ValueObjects/ComplexValueObjectCodeGenerator.cs b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/ValueObjects/ComplexValueObjectCodeGenerator.cs index e13638cf..87245547 100644 --- a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/ValueObjects/ComplexValueObjectCodeGenerator.cs +++ b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/ValueObjects/ComplexValueObjectCodeGenerator.cs @@ -47,7 +47,7 @@ namespace ").Append(_state.Namespace).Append(@" private void GenerateValueObject(CancellationToken cancellationToken) { _sb.Append(@" - partial ").Append(_state.IsReferenceType ? "class" : "struct").Append(" ").Append(_state.Name).Append(" : global::System.IEquatable<").Append(_state.TypeFullyQualifiedNullAnnotated).Append(@">, + ").Append(_state.IsReferenceType ? "sealed " : "readonly ").Append("partial ").Append(_state.IsReferenceType ? "class" : "struct").Append(" ").Append(_state.Name).Append(" : global::System.IEquatable<").Append(_state.TypeFullyQualifiedNullAnnotated).Append(@">, global::System.Numerics.IEqualityOperators<").Append(_state.TypeFullyQualified).Append(", ").Append(_state.TypeFullyQualified).Append(@", bool>, global::Thinktecture.IComplexValueObject"); diff --git a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/ValueObjects/KeyedValueObjectCodeGenerator.cs b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/ValueObjects/KeyedValueObjectCodeGenerator.cs index be8b176c..c5c3f802 100644 --- a/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/ValueObjects/KeyedValueObjectCodeGenerator.cs +++ b/src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/ValueObjects/KeyedValueObjectCodeGenerator.cs @@ -57,7 +57,7 @@ private void GenerateValueObject(CancellationToken cancellationToken) } _sb.Append(@" - partial ").Append(_state.IsReferenceType ? "class" : "struct").Append(" ").Append(_state.Name).Append(" : global::System.IEquatable<").Append(_state.TypeFullyQualifiedNullAnnotated).Append(@">, + ").Append(_state.IsReferenceType ? "sealed " : "readonly ").Append("partial ").Append(_state.IsReferenceType ? "class" : "struct").Append(" ").Append(_state.Name).Append(" : global::System.IEquatable<").Append(_state.TypeFullyQualifiedNullAnnotated).Append(@">, global::Thinktecture.IKeyedValueObject<").Append(_state.KeyMember.TypeFullyQualified).Append(@">, global::Thinktecture.IValueObjectConvertable<").Append(_state.KeyMember.TypeFullyQualified).Append(">"); diff --git a/test/Thinktecture.Runtime.Extensions.Json.Tests/Text/Json/Serialization/ValueObjectJsonConverterFactoryTests/TestClasses/ValueObjectWithMultipleProperties.cs b/test/Thinktecture.Runtime.Extensions.Json.Tests/Text/Json/Serialization/ValueObjectJsonConverterFactoryTests/TestClasses/ValueObjectWithMultipleProperties.cs index ce7bb58b..c8176cd2 100644 --- a/test/Thinktecture.Runtime.Extensions.Json.Tests/Text/Json/Serialization/ValueObjectJsonConverterFactoryTests/TestClasses/ValueObjectWithMultipleProperties.cs +++ b/test/Thinktecture.Runtime.Extensions.Json.Tests/Text/Json/Serialization/ValueObjectJsonConverterFactoryTests/TestClasses/ValueObjectWithMultipleProperties.cs @@ -1,7 +1,7 @@ namespace Thinktecture.Runtime.Tests.Text.Json.Serialization.ValueObjectJsonConverterFactoryTests.TestClasses; [ComplexValueObject] -public sealed partial class ValueObjectWithMultipleProperties +public partial class ValueObjectWithMultipleProperties { public decimal StructProperty { get; } public int? NullableStructProperty { get; } diff --git a/test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Formatters/EnumMessagePackFormatterTests/TestClasses/IntBasedEnumWithFormatter.cs b/test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Formatters/EnumMessagePackFormatterTests/TestClasses/IntBasedEnumWithFormatter.cs index c8a62ed6..ec837a89 100644 --- a/test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Formatters/EnumMessagePackFormatterTests/TestClasses/IntBasedEnumWithFormatter.cs +++ b/test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Formatters/EnumMessagePackFormatterTests/TestClasses/IntBasedEnumWithFormatter.cs @@ -5,7 +5,7 @@ namespace Thinktecture.Runtime.Tests.Formatters.EnumMessagePackFormatterTests.Te [SmartEnum(IsValidatable = true)] [MessagePackFormatter(typeof(ValueObjectMessagePackFormatter))] -public sealed partial class IntBasedEnumWithFormatter +public partial class IntBasedEnumWithFormatter { public static readonly IntBasedEnumWithFormatter Value1 = new(1); public static readonly IntBasedEnumWithFormatter Value2 = new(2); diff --git a/test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Formatters/EnumMessagePackFormatterTests/TestClasses/StringBasedEnumWithFormatter.cs b/test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Formatters/EnumMessagePackFormatterTests/TestClasses/StringBasedEnumWithFormatter.cs index 83cdbb90..41b0b502 100644 --- a/test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Formatters/EnumMessagePackFormatterTests/TestClasses/StringBasedEnumWithFormatter.cs +++ b/test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Formatters/EnumMessagePackFormatterTests/TestClasses/StringBasedEnumWithFormatter.cs @@ -5,7 +5,7 @@ namespace Thinktecture.Runtime.Tests.Formatters.EnumMessagePackFormatterTests.Te [SmartEnum(IsValidatable = true)] [MessagePackFormatter(typeof(ValueObjectMessagePackFormatter))] -public sealed partial class StringBasedEnumWithFormatter +public partial class StringBasedEnumWithFormatter { public static readonly StringBasedEnumWithFormatter ValueA = new("A"); public static readonly StringBasedEnumWithFormatter ValueB = new("B"); diff --git a/test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Formatters/EnumMessagePackFormatterTests/TestClasses/TestValueObject_Complex_Class_WithFormatter.cs b/test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Formatters/EnumMessagePackFormatterTests/TestClasses/TestValueObject_Complex_Class_WithFormatter.cs index 70e8d227..4d4e69dc 100644 --- a/test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Formatters/EnumMessagePackFormatterTests/TestClasses/TestValueObject_Complex_Class_WithFormatter.cs +++ b/test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Formatters/EnumMessagePackFormatterTests/TestClasses/TestValueObject_Complex_Class_WithFormatter.cs @@ -2,7 +2,7 @@ namespace Thinktecture.Runtime.Tests.Formatters.EnumMessagePackFormatterTests.Te // ReSharper disable InconsistentNaming [ComplexValueObject] -public sealed partial class TestValueObject_Complex_Class_WithFormatter +public partial class TestValueObject_Complex_Class_WithFormatter { public string Property1 { get; } public string Property2 { get; } diff --git a/test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Formatters/EnumMessagePackFormatterTests/TestClasses/TestValueObject_Complex_Struct_WithFormatter.cs b/test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Formatters/EnumMessagePackFormatterTests/TestClasses/TestValueObject_Complex_Struct_WithFormatter.cs index 2db0900c..2be43730 100644 --- a/test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Formatters/EnumMessagePackFormatterTests/TestClasses/TestValueObject_Complex_Struct_WithFormatter.cs +++ b/test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Formatters/EnumMessagePackFormatterTests/TestClasses/TestValueObject_Complex_Struct_WithFormatter.cs @@ -2,7 +2,7 @@ namespace Thinktecture.Runtime.Tests.Formatters.EnumMessagePackFormatterTests.Te // ReSharper disable InconsistentNaming [ComplexValueObject] -public readonly partial struct TestValueObject_Complex_Struct_WithFormatter +public partial struct TestValueObject_Complex_Struct_WithFormatter { public string Property1 { get; } public string Property2 { get; } diff --git a/test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Formatters/EnumMessagePackFormatterTests/TestClasses/ValueObjectWithMultipleProperties.cs b/test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Formatters/EnumMessagePackFormatterTests/TestClasses/ValueObjectWithMultipleProperties.cs index afbcec56..438d039f 100644 --- a/test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Formatters/EnumMessagePackFormatterTests/TestClasses/ValueObjectWithMultipleProperties.cs +++ b/test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Formatters/EnumMessagePackFormatterTests/TestClasses/ValueObjectWithMultipleProperties.cs @@ -1,7 +1,7 @@ namespace Thinktecture.Runtime.Tests.Formatters.EnumMessagePackFormatterTests.TestClasses; [ComplexValueObject] -public sealed partial class ValueObjectWithMultipleProperties +public partial class ValueObjectWithMultipleProperties { public decimal StructProperty { get; } public int? NullableStructProperty { get; } diff --git a/test/Thinktecture.Runtime.Extensions.Newtonsoft.Json.Tests/Json/ValueObjectNewtonsoftJsonConverterTests/TestClasses/ValueObjectWithMultipleProperties.cs b/test/Thinktecture.Runtime.Extensions.Newtonsoft.Json.Tests/Json/ValueObjectNewtonsoftJsonConverterTests/TestClasses/ValueObjectWithMultipleProperties.cs index 74dbaec4..192efcd2 100644 --- a/test/Thinktecture.Runtime.Extensions.Newtonsoft.Json.Tests/Json/ValueObjectNewtonsoftJsonConverterTests/TestClasses/ValueObjectWithMultipleProperties.cs +++ b/test/Thinktecture.Runtime.Extensions.Newtonsoft.Json.Tests/Json/ValueObjectNewtonsoftJsonConverterTests/TestClasses/ValueObjectWithMultipleProperties.cs @@ -1,7 +1,7 @@ namespace Thinktecture.Runtime.Tests.Json.ValueObjectNewtonsoftJsonConverterTests.TestClasses; [ComplexValueObject] -public sealed partial class ValueObjectWithMultipleProperties +public partial class ValueObjectWithMultipleProperties { public decimal StructProperty { get; } public int? NullableStructProperty { get; } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG001_FieldMustBeReadOnly.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG001_FieldMustBeReadOnly.cs index 45aac93a..b8bbee38 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG001_FieldMustBeReadOnly.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG001_FieldMustBeReadOnly.cs @@ -21,7 +21,7 @@ public async Task Should_trigger_on_non_readonly_enum_item() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static TestEnum {|#0:Item1|} = default; public static readonly TestEnum Item2 = default; @@ -37,7 +37,7 @@ public sealed partial class TestEnum namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; public static readonly TestEnum Item2 = default; @@ -60,10 +60,10 @@ public async Task Should_trigger_on_static_non_readonly_non_enum_item() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + public static object {|#0:SomeStaticField|} = default; } } @@ -77,10 +77,10 @@ public sealed partial class TestEnum namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + public static readonly object {|#0:SomeStaticField|} = default; } } @@ -101,10 +101,10 @@ public async Task Should_trigger_on_non_readonly_instance_field() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + public int {|#0:InstanceField|}; } } @@ -118,10 +118,10 @@ public sealed partial class TestEnum namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + public readonly int InstanceField; } } @@ -142,10 +142,10 @@ public async Task Should_not_trigger_on_readonly_instance_field() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + public readonly int {|#0:InstanceField|}; } } @@ -168,7 +168,7 @@ public async Task Should_trigger_on_static_non_readonly_field() namespace TestNamespace { [ValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { public static object {|#0:Field|} = default; } @@ -183,7 +183,7 @@ public sealed partial class TestValueObject namespace TestNamespace { [ValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { public static readonly object {|#0:Field|} = default; } @@ -205,7 +205,7 @@ public async Task Should_trigger_on_instance_non_readonly_field() namespace TestNamespace { [ValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { public object {|#0:Field|} = default; } @@ -220,7 +220,7 @@ public sealed partial class TestValueObject namespace TestNamespace { [ValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { public readonly object {|#0:Field|} = default; } @@ -245,7 +245,7 @@ public async Task Should_trigger_on_static_non_readonly_field() namespace TestNamespace { [ComplexValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { public static object {|#0:Field|} = default; } @@ -260,7 +260,7 @@ public sealed partial class TestValueObject namespace TestNamespace { [ComplexValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { public static readonly object {|#0:Field|} = default; } @@ -282,7 +282,7 @@ public async Task Should_trigger_on_instance_non_readonly_field() namespace TestNamespace { [ComplexValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { public object {|#0:Field|} = default; } @@ -297,7 +297,7 @@ public sealed partial class TestValueObject namespace TestNamespace { [ComplexValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { public readonly object {|#0:Field|} = default; } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG002_EnumItemMustBePublic.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG002_EnumItemMustBePublic.cs index 5a64cb59..74e99408 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG002_EnumItemMustBePublic.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG002_EnumItemMustBePublic.cs @@ -19,7 +19,7 @@ public async Task Should_trigger_on_internal_enum_item() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { internal static readonly TestEnum {|#0:Item1|} = default; } @@ -34,7 +34,7 @@ public sealed partial class TestEnum namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; } @@ -56,7 +56,7 @@ public async Task Should_trigger_even_if_modifier_is_not_first_one() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { static private readonly TestEnum {|#0:Item1|} = default; } @@ -71,7 +71,7 @@ public sealed partial class TestEnum namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; } @@ -93,7 +93,7 @@ public async Task Should_trigger_on_non_enum_item_without_explicit_modifier() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { static readonly TestEnum {|#0:Item1|} = default; } @@ -108,7 +108,7 @@ public sealed partial class TestEnum namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG003_PropertyMustBeReadOnly.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG003_PropertyMustBeReadOnly.cs index e9ff8c74..c064f056 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG003_PropertyMustBeReadOnly.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG003_PropertyMustBeReadOnly.cs @@ -21,10 +21,10 @@ public async Task Should_trigger_on_non_readonly_instance_property() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + public int {|#0:InstanceProperty|} { get; set; } } } @@ -38,10 +38,10 @@ public sealed partial class TestEnum namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + public int InstanceProperty { get; } } } @@ -62,10 +62,10 @@ public async Task Should_trigger_on_non_readonly_static_property() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + public static int {|#0:InstanceProperty|} { get; set; } } } @@ -79,10 +79,10 @@ public sealed partial class TestEnum namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + public static int InstanceProperty { get; } } } @@ -103,10 +103,10 @@ public async Task Should_not_trigger_on_instance_property_with_getter_expression namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + public int {|#0:InstanceProperty|} { get => 42; @@ -130,10 +130,10 @@ public async Task Should_not_trigger_on_static_property_with_getter_expression_b namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + public static int {|#0:InstanceProperty|} { get => 42; @@ -157,10 +157,10 @@ public async Task Should_not_trigger_on_instance_property_with_getter_body() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + public int {|#0:InstanceProperty|} { get { return 42; } @@ -184,10 +184,10 @@ public async Task Should_not_trigger_on_static_property_with_getter_body() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + public static int {|#0:InstanceProperty|} { get { return 42; } @@ -214,12 +214,12 @@ public static class Helper { public static int Property { get; set; } } - + [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + public int {|#0:InstanceProperty|} { set => Helper.Property = value; @@ -244,12 +244,12 @@ public static class Helper { public static int Property { get; set; } } - + [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + public static int {|#0:InstanceProperty|} { set => Helper.Property = value; @@ -271,10 +271,10 @@ public async Task Should_not_trigger_on_instance_property_with_setter_body() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + public int {|#0:InstanceProperty|} { set { } @@ -297,10 +297,10 @@ public async Task Should_not_trigger_on_static_property_with_setter_body() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + public static int {|#0:InstanceProperty|} { set { } @@ -326,7 +326,7 @@ public async Task Should_trigger_on_non_readonly_instance_property() namespace TestNamespace { [ValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { public int {|#0:InstanceProperty|} { get; set; } } @@ -341,7 +341,7 @@ public sealed partial class TestValueObject namespace TestNamespace { [ValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { public int InstanceProperty { get; } } @@ -363,7 +363,7 @@ public async Task Should_trigger_on_non_readonly_static_property() namespace TestNamespace { [ValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { public static int {|#0:InstanceProperty|} { get; set; } } @@ -378,7 +378,7 @@ public sealed partial class TestValueObject namespace TestNamespace { [ValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { public static int InstanceProperty { get; } } @@ -403,7 +403,7 @@ public async Task Should_trigger_on_non_readonly_instance_property() namespace TestNamespace { [ComplexValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { public int {|#0:InstanceProperty|} { get; set; } } @@ -418,7 +418,7 @@ public sealed partial class TestValueObject namespace TestNamespace { [ComplexValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { public int InstanceProperty { get; } } @@ -440,7 +440,7 @@ public async Task Should_trigger_on_non_readonly_static_property() namespace TestNamespace { [ComplexValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { public static int {|#0:InstanceProperty|} { get; set; } } @@ -455,7 +455,7 @@ public sealed partial class TestValueObject namespace TestNamespace { [ComplexValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { public static int InstanceProperty { get; } } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG004_TypeMustBeClassOrStruct.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG004_TypeMustBeClassOrStruct.cs index 232c7b0a..4ee28990 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG004_TypeMustBeClassOrStruct.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG004_TypeMustBeClassOrStruct.cs @@ -21,7 +21,7 @@ public async Task Should_trigger_on_record() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial record {|#0:TestEnum|} + public partial record {|#0:TestEnum|} { } } @@ -42,7 +42,7 @@ public async Task Should_not_trigger_on_class() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; } @@ -63,7 +63,7 @@ public async Task Should_not_trigger_on_struct() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public readonly partial struct TestEnum + public partial struct TestEnum { public static readonly TestEnum Item1 = default; } @@ -87,7 +87,7 @@ public async Task Should_trigger_on_record() namespace TestNamespace { [ValueObject] - public sealed partial record {|#0:TestValueObject|} + public partial record {|#0:TestValueObject|} { } } @@ -108,7 +108,7 @@ public async Task Should_not_trigger_on_class() namespace TestNamespace { [ValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { } } @@ -128,7 +128,7 @@ public async Task Should_not_trigger_on_struct() namespace TestNamespace { [ValueObject] - public readonly partial struct TestValueObject + public partial struct TestValueObject { } } @@ -151,7 +151,7 @@ public async Task Should_trigger_on_record() namespace TestNamespace { [ComplexValueObject] - public sealed partial record {|#0:TestValueObject|} + public partial record {|#0:TestValueObject|} { } } @@ -172,7 +172,7 @@ public async Task Should_not_trigger_on_class() namespace TestNamespace { [ComplexValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { } } @@ -192,7 +192,7 @@ public async Task Should_not_trigger_on_struct() namespace TestNamespace { [ComplexValueObject] - public readonly partial struct TestValueObject + public partial struct TestValueObject { } } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG006_TypeMustBePartial.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG006_TypeMustBePartial.cs index b6da59d1..41b8666a 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG006_TypeMustBePartial.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG006_TypeMustBePartial.cs @@ -21,7 +21,7 @@ public async Task Should_trigger_on_non_partial_class() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed class {|#0:TestEnum|} + public class {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; } @@ -36,7 +36,7 @@ public sealed class {|#0:TestEnum|} namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} + public partial class {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; } @@ -58,7 +58,7 @@ public async Task Should_trigger_on_non_partial_struct() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public readonly struct {|#0:TestEnum|} + public struct {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; } @@ -73,7 +73,7 @@ namespace TestNamespace namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public readonly partial struct {|#0:TestEnum|} + public partial struct {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; } @@ -95,7 +95,7 @@ public async Task Should_not_trigger_on_partial_class() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} + public partial class {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; } @@ -116,7 +116,7 @@ public async Task Should_not_trigger_on_partial_struct() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public readonly partial struct {|#0:TestEnum|} + public partial struct {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; } @@ -140,7 +140,7 @@ public async Task Should_trigger_on_non_partial_class() namespace TestNamespace { [ValueObject] - public sealed class {|#0:TestValueObject|} + public class {|#0:TestValueObject|} { } } @@ -154,7 +154,7 @@ public sealed class {|#0:TestValueObject|} namespace TestNamespace { [ValueObject] - public sealed partial class {|#0:TestValueObject|} + public partial class {|#0:TestValueObject|} { } } @@ -175,7 +175,7 @@ public async Task Should_trigger_on_non_partial_struct() namespace TestNamespace { [ValueObject] - public readonly struct {|#0:TestValueObject|} + public struct {|#0:TestValueObject|} { } } @@ -189,7 +189,7 @@ namespace TestNamespace namespace TestNamespace { [ValueObject] - public readonly partial struct {|#0:TestValueObject|} + public partial struct {|#0:TestValueObject|} { } } @@ -210,7 +210,7 @@ public async Task Should_not_trigger_on_partial_class() namespace TestNamespace { [ValueObject] - public sealed partial class {|#0:TestValueObject|} + public partial class {|#0:TestValueObject|} { } } @@ -230,7 +230,7 @@ public async Task Should_not_trigger_on_partial_struct() namespace TestNamespace { [ValueObject] - public readonly partial struct {|#0:TestValueObject|} + public partial struct {|#0:TestValueObject|} { } } @@ -253,7 +253,7 @@ public async Task Should_trigger_on_non_partial_class() namespace TestNamespace { [ComplexValueObject] - public sealed class {|#0:TestValueObject|} + public class {|#0:TestValueObject|} { } } @@ -267,7 +267,7 @@ public sealed class {|#0:TestValueObject|} namespace TestNamespace { [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} + public partial class {|#0:TestValueObject|} { } } @@ -288,7 +288,7 @@ public async Task Should_trigger_on_non_partial_struct() namespace TestNamespace { [ComplexValueObject] - public readonly struct {|#0:TestValueObject|} + public struct {|#0:TestValueObject|} { } } @@ -302,7 +302,7 @@ namespace TestNamespace namespace TestNamespace { [ComplexValueObject] - public readonly partial struct {|#0:TestValueObject|} + public partial struct {|#0:TestValueObject|} { } } @@ -323,7 +323,7 @@ public async Task Should_not_trigger_on_partial_class() namespace TestNamespace { [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} + public partial class {|#0:TestValueObject|} { } } @@ -343,7 +343,7 @@ public async Task Should_not_trigger_on_partial_struct() namespace TestNamespace { [ComplexValueObject] - public readonly partial struct {|#0:TestValueObject|} + public partial struct {|#0:TestValueObject|} { } } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG007_InvalidSignatureOfCreateInvalidItem.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG007_InvalidSignatureOfCreateInvalidItem.cs index bf56de70..80ef0017 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG007_InvalidSignatureOfCreateInvalidItem.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG007_InvalidSignatureOfCreateInvalidItem.cs @@ -19,10 +19,10 @@ public async Task Should_trigger_if_not_private() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + public static TestEnum {|#0:CreateInvalidItem|}(string key) { return null; @@ -46,10 +46,10 @@ public async Task Should_trigger_if_not_static() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + private TestEnum {|#0:CreateInvalidItem|}(string key) { return null; @@ -73,10 +73,10 @@ public async Task Should_trigger_if_return_type_incorrect() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + private static string {|#0:CreateInvalidItem|}(string key) { return null; @@ -100,10 +100,10 @@ public async Task Should_trigger_if_argument_type_incorrect() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + private static TestEnum {|#0:CreateInvalidItem|}(int key) { return null; @@ -127,10 +127,10 @@ public async Task Should_trigger_if_argument_count_incorrect() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + private static TestEnum {|#0:CreateInvalidItem|}(string key, string other) { return null; @@ -154,10 +154,10 @@ public async Task Should_not_trigger_on_valid_implementation() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + private static TestEnum {|#0:CreateInvalidItem|}(string key) { return null; diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG009_EnumConstructorsMustBePrivate.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG009_EnumConstructorsMustBePrivate.cs index 3b47e515..84dfc93e 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG009_EnumConstructorsMustBePrivate.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG009_EnumConstructorsMustBePrivate.cs @@ -19,10 +19,10 @@ public async Task Should_trigger_if_constructor_is_protected() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + protected {|#0:TestEnum|}() { } @@ -45,10 +45,10 @@ public async Task Should_trigger_if_constructor_is_private_protected() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + private protected {|#0:TestEnum|}() { } @@ -71,10 +71,10 @@ public async Task Should_not_trigger_if_constructor_is_private() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + private {|#0:TestEnum|}() { } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG010_NonValidatableEnumsMustBeClass.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG010_NonValidatableEnumsMustBeClass.cs index a0d954be..f3c9f926 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG010_NonValidatableEnumsMustBeClass.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG010_NonValidatableEnumsMustBeClass.cs @@ -19,7 +19,7 @@ public async Task Should_trigger_if_IEnum_is_struct() namespace TestNamespace { [SmartEnum] - public readonly partial struct {|#0:TestEnum|} + public partial struct {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; } @@ -41,7 +41,7 @@ public async Task Should_not_trigger_if_IEnum_is_class() namespace TestNamespace { [SmartEnum] - public sealed partial class {|#0:TestEnum|} + public partial class {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG011_StructMustBeReadOnly.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG011_StructMustBeReadOnly.cs deleted file mode 100644 index b2345c77..00000000 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG011_StructMustBeReadOnly.cs +++ /dev/null @@ -1,187 +0,0 @@ -using System.Threading.Tasks; -using Verifier = Thinktecture.Runtime.Tests.Verifiers.CodeFixVerifier; - -namespace Thinktecture.Runtime.Tests.AnalyzerAndCodeFixTests; - -// ReSharper disable InconsistentNaming -public class TTRESG011_StructMustBeReadOnly -{ - private const string _DIAGNOSTIC_ID = "TTRESG011"; - - public class Enum_struct_must_be_readonly - { - [Fact] - public async Task Should_trigger_if_struct_is_not_readonly() - { - var code = """ - - using System; - using Thinktecture; - - namespace TestNamespace - { - [SmartEnum(IsValidatable = true)] - public partial struct {|#0:TestEnum|} - { - public static readonly TestEnum Item1 = default; - } - } - """; - - var expectedCode = """ - - using System; - using Thinktecture; - - namespace TestNamespace - { - [SmartEnum(IsValidatable = true)] - public readonly partial struct {|#0:TestEnum|} - { - public static readonly TestEnum Item1 = default; - } - } - """; - - var expected = Verifier.Diagnostic(_DIAGNOSTIC_ID).WithLocation(0).WithArguments("TestEnum"); - await Verifier.VerifyCodeFixAsync(code, expectedCode, new[] { typeof(IEnum<>).Assembly }, expected); - } - - [Fact] - public async Task Should_not_trigger_if_struct_is_readonly() - { - var code = """ - - using System; - using Thinktecture; - - namespace TestNamespace - { - [SmartEnum(IsValidatable = true)] - public readonly partial struct {|#0:TestEnum|} - { - public static readonly TestEnum Item1 = default; - } - } - """; - - await Verifier.VerifyAnalyzerAsync(code, new[] { typeof(IEnum<>).Assembly }); - } - } - - public class KeyedValueObject_struct_must_be_readonly - { - [Fact] - public async Task Should_trigger_if_struct_is_not_readonly() - { - var code = """ - - using System; - using Thinktecture; - - namespace TestNamespace - { - [ValueObject] - public partial struct {|#0:TestValueObject|} - { - } - } - """; - - var expectedCode = """ - - using System; - using Thinktecture; - - namespace TestNamespace - { - [ValueObject] - public readonly partial struct {|#0:TestValueObject|} - { - } - } - """; - - var expected = Verifier.Diagnostic(_DIAGNOSTIC_ID).WithLocation(0).WithArguments("TestValueObject"); - await Verifier.VerifyCodeFixAsync(code, expectedCode, new[] { typeof(ComplexValueObjectAttribute).Assembly }, expected); - } - - [Fact] - public async Task Should_not_trigger_if_struct_is_readonly() - { - var code = """ - - using System; - using Thinktecture; - - namespace TestNamespace - { - [ValueObject] - public readonly partial struct {|#0:TestValueObject|} - { - } - } - """; - - await Verifier.VerifyAnalyzerAsync(code, new[] { typeof(ComplexValueObjectAttribute).Assembly }); - } - } - - public class ComplexValueObject_struct_must_be_readonly - { - [Fact] - public async Task Should_trigger_if_struct_is_not_readonly() - { - var code = """ - - using System; - using Thinktecture; - - namespace TestNamespace - { - [ComplexValueObject] - public partial struct {|#0:TestValueObject|} - { - } - } - """; - - var expectedCode = """ - - using System; - using Thinktecture; - - namespace TestNamespace - { - [ComplexValueObject] - public readonly partial struct {|#0:TestValueObject|} - { - } - } - """; - - var expected = Verifier.Diagnostic(_DIAGNOSTIC_ID).WithLocation(0).WithArguments("TestValueObject"); - await Verifier.VerifyCodeFixAsync(code, expectedCode, new[] { typeof(ComplexValueObjectAttribute).Assembly }, expected); - } - - [Fact] - public async Task Should_not_trigger_if_struct_is_readonly() - { - var code = """ - - using System; - using Thinktecture; - - namespace TestNamespace - { - [ComplexValueObject] - public readonly partial struct {|#0:TestValueObject|} - { - } - } - """; - - await Verifier.VerifyAnalyzerAsync(code, new[] { typeof(ComplexValueObjectAttribute).Assembly }); - } - } -} diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG012_EnumKeyPropertyNameNotAllowed.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG012_EnumKeyPropertyNameNotAllowed.cs index 9219d158..695f9b3d 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG012_EnumKeyPropertyNameNotAllowed.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG012_EnumKeyPropertyNameNotAllowed.cs @@ -19,7 +19,7 @@ public async Task Should_trigger_if_name_is_item() namespace TestNamespace { [SmartEnum(IsValidatable = true, {|#0:KeyMemberName = "Item"|})] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; } @@ -41,7 +41,7 @@ public async Task Should_not_trigger_if_name_is_not_item() namespace TestNamespace { [SmartEnum(IsValidatable = true, {|#0:KeyMemberName = "Foo"|})] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG014_InnerEnumOnFirstLevelMustBePrivate.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG014_InnerEnumOnFirstLevelMustBePrivate.cs index 2b24bea8..926ae562 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG014_InnerEnumOnFirstLevelMustBePrivate.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG014_InnerEnumOnFirstLevelMustBePrivate.cs @@ -22,7 +22,7 @@ namespace TestNamespace public partial class TestEnum { public static readonly TestEnum Item1 = default; - + public sealed class {|#0:InnerTestEnum|} : TestEnum { } @@ -41,7 +41,7 @@ namespace TestNamespace public partial class TestEnum { public static readonly TestEnum Item1 = default; - + private sealed class {|#0:InnerTestEnum|} : TestEnum { } @@ -67,7 +67,7 @@ namespace TestNamespace public partial class TestEnum { public static readonly TestEnum Item1 = default; - + private sealed class {|#0:InnerTestEnum|} : TestEnum { } @@ -92,7 +92,7 @@ namespace TestNamespace public partial class TestEnum { public static readonly TestEnum Item1 = default; - + private sealed class InnerTestEnum : TestEnum { public sealed class {|#0:MostInnerTestEnum|} : TestEnum diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG015_InnerEnumOnNonFirstLevelMustBePublic.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG015_InnerEnumOnNonFirstLevelMustBePublic.cs index 79c88b90..9a362ee5 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG015_InnerEnumOnNonFirstLevelMustBePublic.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG015_InnerEnumOnNonFirstLevelMustBePublic.cs @@ -22,7 +22,7 @@ namespace TestNamespace public partial class TestEnum { public static readonly TestEnum Item1 = default; - + private sealed class InnerTestEnum : TestEnum { private sealed class {|#0:MostInnerTestEnum|} : TestEnum @@ -44,7 +44,7 @@ namespace TestNamespace public partial class TestEnum { public static readonly TestEnum Item1 = default; - + private sealed class InnerTestEnum : TestEnum { public sealed class {|#0:MostInnerTestEnum|} : TestEnum @@ -73,7 +73,7 @@ namespace TestNamespace public partial class TestEnum { public static readonly TestEnum Item1 = default; - + private sealed class InnerTestEnum : TestEnum { public sealed class {|#0:MostInnerTestEnum|} : TestEnum diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG016_TypeCannotBeNestedClass.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG016_TypeCannotBeNestedClass.cs index 8b31eab1..8eabfe9f 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG016_TypeCannotBeNestedClass.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG016_TypeCannotBeNestedClass.cs @@ -23,7 +23,7 @@ namespace TestNamespace public class SomeClass { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} + public partial class {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG017_KeyMemberShouldNotBeNullable.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG017_KeyMemberShouldNotBeNullable.cs index 8701de0f..3252e687 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG017_KeyMemberShouldNotBeNullable.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG017_KeyMemberShouldNotBeNullable.cs @@ -24,7 +24,7 @@ public async Task Should_trigger_if_key_member_is_nullable_reference_type() namespace TestNamespace { [{|#0:ValueObject|}] - public sealed partial class TestValueObject + public partial class TestValueObject { } } @@ -50,7 +50,7 @@ public async Task Should_not_trigger_if_key_member_is_non_nullable_reference_typ namespace TestNamespace { [ValueObject] - public sealed partial class {|#0:TestValueObject|} + public partial class {|#0:TestValueObject|} { } } @@ -70,7 +70,7 @@ public async Task Should_not_trigger_if_key_member_is_non_nullable_reference_typ namespace TestNamespace { [ValueObject] - public sealed partial class {|#0:TestValueObject|} + public partial class {|#0:TestValueObject|} { } } @@ -92,7 +92,7 @@ public async Task Should_trigger_if_key_member_is_nullable_struct() namespace TestNamespace { [{|#0:ValueObject|}] - public sealed partial class TestValueObject + public partial class TestValueObject { } } @@ -115,7 +115,7 @@ public async Task Should_trigger_if_key_member_is_nullable_struct_even_if_nullab namespace TestNamespace { [{|#0:ValueObject|}] - public sealed partial class TestValueObject + public partial class TestValueObject { } } @@ -138,7 +138,7 @@ public async Task Should_not_trigger_if_key_member_is_non_nullable_struct() namespace TestNamespace { [ValueObject] - public sealed partial class {|#0:TestValueObject|} + public partial class {|#0:TestValueObject|} { } } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG033_EnumsAndValueObjectsMustNotBeGeneric.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG033_EnumsAndValueObjectsMustNotBeGeneric.cs index cdb8976b..4037496d 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG033_EnumsAndValueObjectsMustNotBeGeneric.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG033_EnumsAndValueObjectsMustNotBeGeneric.cs @@ -23,7 +23,7 @@ public async Task Should_trigger_on_generic_class() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} + public partial class {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; } @@ -45,7 +45,7 @@ public async Task Should_trigger_on_generic_struct() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public readonly partial struct {|#0:TestEnum|} + public partial struct {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; } @@ -70,7 +70,7 @@ public async Task Should_trigger_on_generic_class() namespace TestNamespace { [ValueObject] - public sealed partial class {|#0:TestValueObject|} + public partial class {|#0:TestValueObject|} { } } @@ -91,7 +91,7 @@ public async Task Should_trigger_on_generic_struct() namespace TestNamespace { [ValueObject] - public readonly partial struct {|#0:TestValueObject|} + public partial struct {|#0:TestValueObject|} { } } @@ -115,7 +115,7 @@ public async Task Should_trigger_on_generic_class() namespace TestNamespace { [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} + public partial class {|#0:TestValueObject|} { } } @@ -136,7 +136,7 @@ public async Task Should_trigger_on_generic_struct() namespace TestNamespace { [ComplexValueObject] - public readonly partial struct {|#0:TestValueObject|} + public partial struct {|#0:TestValueObject|} { } } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG034_BaseClassFieldMustBeReadOnly.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG034_BaseClassFieldMustBeReadOnly.cs index 47dd4a72..a0440b11 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG034_BaseClassFieldMustBeReadOnly.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG034_BaseClassFieldMustBeReadOnly.cs @@ -25,9 +25,9 @@ public class BaseClass { public static object Field = default; } - + [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClass + public partial class {|#0:TestEnum|} : BaseClass { public static readonly TestEnum Item1 = default; } @@ -52,9 +52,9 @@ public class BaseClass { public static readonly object Field = default; } - + [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClass + public partial class {|#0:TestEnum|} : BaseClass { public static readonly TestEnum Item1 = default; } @@ -78,9 +78,9 @@ public class BaseClass { public object Field = default; } - + [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClass + public partial class {|#0:TestEnum|} : BaseClass { public static readonly TestEnum Item1 = default; } @@ -105,9 +105,9 @@ public class BaseClass { public readonly object Field = default; } - + [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClass + public partial class {|#0:TestEnum|} : BaseClass { public static readonly TestEnum Item1 = default; } @@ -132,7 +132,7 @@ public async Task Should_trigger_on_static_field() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClassWithStaticField + public partial class {|#0:TestEnum|} : BaseClassWithStaticField { public static readonly TestEnum Item1 = default; } @@ -155,7 +155,7 @@ public async Task Should_not_trigger_on_static_readonly_field() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClassWithStaticReadonlyField + public partial class {|#0:TestEnum|} : BaseClassWithStaticReadonlyField { public static readonly TestEnum Item1 = default; } @@ -177,7 +177,7 @@ public async Task Should_trigger_on_instance_field() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClassWithInstanceField + public partial class {|#0:TestEnum|} : BaseClassWithInstanceField { public static readonly TestEnum Item1 = default; } @@ -200,7 +200,7 @@ public async Task Should_not_trigger_on_readonly_instance_field() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClassWithInstanceReadonlyField + public partial class {|#0:TestEnum|} : BaseClassWithInstanceReadonlyField { public static readonly TestEnum Item1 = default; } @@ -227,9 +227,9 @@ public class BaseClass { public static object Field = default; } - + [ValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClass + public partial class {|#0:TestValueObject|} : BaseClass { } } @@ -253,9 +253,9 @@ public class BaseClass { public static readonly object Field = default; } - + [ValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClass + public partial class {|#0:TestValueObject|} : BaseClass { } } @@ -278,9 +278,9 @@ public class BaseClass { public object Field = default; } - + [ValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClass + public partial class {|#0:TestValueObject|} : BaseClass { } } @@ -304,9 +304,9 @@ public class BaseClass { public readonly object Field = default; } - + [ValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClass + public partial class {|#0:TestValueObject|} : BaseClass { } } @@ -332,9 +332,9 @@ public class BaseClass { public static object Field = default; } - + [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClass + public partial class {|#0:TestValueObject|} : BaseClass { } } @@ -358,9 +358,9 @@ public class BaseClass { public static readonly object Field = default; } - + [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClass + public partial class {|#0:TestValueObject|} : BaseClass { } } @@ -383,9 +383,9 @@ public class BaseClass { public object Field = default; } - + [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClass + public partial class {|#0:TestValueObject|} : BaseClass { } } @@ -409,9 +409,9 @@ public class BaseClass { public readonly object Field = default; } - + [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClass + public partial class {|#0:TestValueObject|} : BaseClass { } } @@ -435,7 +435,7 @@ public async Task Should_trigger_on_static_field() namespace TestNamespace { [ValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClassWithStaticField + public partial class {|#0:TestValueObject|} : BaseClassWithStaticField { } } @@ -457,7 +457,7 @@ public async Task Should_not_trigger_on_static_readonly_field() namespace TestNamespace { [ValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClassWithStaticReadonlyField + public partial class {|#0:TestValueObject|} : BaseClassWithStaticReadonlyField { } } @@ -478,7 +478,7 @@ public async Task Should_trigger_on_instance_field() namespace TestNamespace { [ValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClassWithInstanceField + public partial class {|#0:TestValueObject|} : BaseClassWithInstanceField { } } @@ -500,7 +500,7 @@ public async Task Should_not_trigger_on_instance_readonly_field() namespace TestNamespace { [ValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClassWithInstanceReadonlyField + public partial class {|#0:TestValueObject|} : BaseClassWithInstanceReadonlyField { } } @@ -524,7 +524,7 @@ public async Task Should_trigger_on_static_field() namespace TestNamespace { [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClassWithStaticField + public partial class {|#0:TestValueObject|} : BaseClassWithStaticField { } } @@ -546,7 +546,7 @@ public async Task Should_not_trigger_on_static_readonly_field() namespace TestNamespace { [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClassWithStaticReadonlyField + public partial class {|#0:TestValueObject|} : BaseClassWithStaticReadonlyField { } } @@ -567,7 +567,7 @@ public async Task Should_trigger_on_instance_field() namespace TestNamespace { [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClassWithInstanceField + public partial class {|#0:TestValueObject|} : BaseClassWithInstanceField { } } @@ -589,7 +589,7 @@ public async Task Should_not_trigger_on_instance_readonly_field() namespace TestNamespace { [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClassWithInstanceReadonlyField + public partial class {|#0:TestValueObject|} : BaseClassWithInstanceReadonlyField { } } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG035_BaseClassPropertyMustBeReadOnly.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG035_BaseClassPropertyMustBeReadOnly.cs index dcce7198..dfa8227c 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG035_BaseClassPropertyMustBeReadOnly.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG035_BaseClassPropertyMustBeReadOnly.cs @@ -26,9 +26,9 @@ public class BaseClass { public int Property { get; set; } } - + [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClass + public partial class {|#0:TestEnum|} : BaseClass { public static readonly TestEnum Item1 = default; } @@ -53,9 +53,9 @@ public class BaseClass { public int Property { get; } } - + [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClass + public partial class {|#0:TestEnum|} : BaseClass { public static readonly TestEnum Item1 = default; } @@ -79,9 +79,9 @@ public class BaseClass { public static int Property { get; set; } } - + [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClass + public partial class {|#0:TestEnum|} : BaseClass { public static readonly TestEnum Item1 = default; } @@ -106,9 +106,9 @@ public class BaseClass { public static int Property { get; } } - + [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClass + public partial class {|#0:TestEnum|} : BaseClass { public static readonly TestEnum Item1 = default; } @@ -136,9 +136,9 @@ public int Property set { } } } - + [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClass + public partial class {|#0:TestEnum|} : BaseClass { public static readonly TestEnum Item1 = default; } @@ -166,9 +166,9 @@ public static int Property set { } } } - + [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClass + public partial class {|#0:TestEnum|} : BaseClass { public static readonly TestEnum Item1 = default; } @@ -196,9 +196,9 @@ public int Property set { } } } - + [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClass + public partial class {|#0:TestEnum|} : BaseClass { public static readonly TestEnum Item1 = default; } @@ -226,9 +226,9 @@ public static int Property set { } } } - + [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClass + public partial class {|#0:TestEnum|} : BaseClass { public static readonly TestEnum Item1 = default; } @@ -252,7 +252,7 @@ public static class Helper { public static int Property { get; set; } } - + public class BaseClass { public int Property @@ -260,9 +260,9 @@ public int Property set => Helper.Property = value; } } - + [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClass + public partial class {|#0:TestEnum|} : BaseClass { public static readonly TestEnum Item1 = default; } @@ -286,7 +286,7 @@ public static class Helper { public static int Property { get; set; } } - + public class BaseClass { public static int Property @@ -294,9 +294,9 @@ public static int Property set => Helper.Property = value; } } - + [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClass + public partial class {|#0:TestEnum|} : BaseClass { public static readonly TestEnum Item1 = default; } @@ -323,9 +323,9 @@ public int Property set { } } } - + [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClass + public partial class {|#0:TestEnum|} : BaseClass { public static readonly TestEnum Item1 = default; } @@ -352,9 +352,9 @@ public static int Property set { } } } - + [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClass + public partial class {|#0:TestEnum|} : BaseClass { public static readonly TestEnum Item1 = default; } @@ -379,7 +379,7 @@ public async Task Should_trigger_on_instance_property() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClassWithInstanceProperty + public partial class {|#0:TestEnum|} : BaseClassWithInstanceProperty { public static readonly TestEnum Item1 = default; } @@ -402,7 +402,7 @@ public async Task Should_not_trigger_on_instance_property_with_getter_only() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClassWithInstancePropertyWithGetterOnly + public partial class {|#0:TestEnum|} : BaseClassWithInstancePropertyWithGetterOnly { public static readonly TestEnum Item1 = default; } @@ -424,7 +424,7 @@ public async Task Should_trigger_on_static_property() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClassWithStaticProperty + public partial class {|#0:TestEnum|} : BaseClassWithStaticProperty { public static readonly TestEnum Item1 = default; } @@ -447,7 +447,7 @@ public async Task Should_not_trigger_on_static_property_with_getter_only() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClassWithStaticPropertyWithGetterOnly + public partial class {|#0:TestEnum|} : BaseClassWithStaticPropertyWithGetterOnly { public static readonly TestEnum Item1 = default; } @@ -469,7 +469,7 @@ public async Task Should_not_trigger_on_instance_property_with_setter_expression namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClassWithSetExpressionProperty + public partial class {|#0:TestEnum|} : BaseClassWithSetExpressionProperty { public static readonly TestEnum Item1 = default; } @@ -491,7 +491,7 @@ public async Task Should_not_trigger_on_static_property_with_setter_expression_b namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClassWithSetExpressionStaticProperty + public partial class {|#0:TestEnum|} : BaseClassWithSetExpressionStaticProperty { public static readonly TestEnum Item1 = default; } @@ -513,7 +513,7 @@ public async Task Should_not_trigger_on_instance_property_with_setter_body() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClassWithSetBodyProperty + public partial class {|#0:TestEnum|} : BaseClassWithSetBodyProperty { public static readonly TestEnum Item1 = default; } @@ -535,7 +535,7 @@ public async Task Should_not_trigger_on_static_property_with_setter_body() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClassWithSetBodyStaticProperty + public partial class {|#0:TestEnum|} : BaseClassWithSetBodyStaticProperty { public static readonly TestEnum Item1 = default; } @@ -559,7 +559,7 @@ public async Task Should_not_BUT_DOES_trigger_on_instance_property_with_getter_e namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClassWithGetExpressionProperty + public partial class {|#0:TestEnum|} : BaseClassWithGetExpressionProperty { public static readonly TestEnum Item1 = default; } @@ -582,7 +582,7 @@ public async Task Should_not_BUT_DOES_trigger_on_static_property_with_getter_exp namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClassWithGetExpressionStaticProperty + public partial class {|#0:TestEnum|} : BaseClassWithGetExpressionStaticProperty { public static readonly TestEnum Item1 = default; } @@ -605,7 +605,7 @@ public async Task Should_not_BUT_DOES_trigger_on_instance_property_with_getter_b namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClassWithGetBodyProperty + public partial class {|#0:TestEnum|} : BaseClassWithGetBodyProperty { public static readonly TestEnum Item1 = default; } @@ -628,7 +628,7 @@ public async Task Should_not_BUT_DOES_trigger_on_static_property_with_getter_bod namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} : BaseClassWithGetBodyStaticProperty + public partial class {|#0:TestEnum|} : BaseClassWithGetBodyStaticProperty { public static readonly TestEnum Item1 = default; } @@ -657,9 +657,9 @@ public class BaseClass { public int Property { get; set; } } - + [ValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClass + public partial class {|#0:TestValueObject|} : BaseClass { } } @@ -683,9 +683,9 @@ public class BaseClass { public int Property { get; } } - + [ValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClass + public partial class {|#0:TestValueObject|} : BaseClass { } } @@ -708,9 +708,9 @@ public class BaseClass { public static int Property { get; set; } } - + [ValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClass + public partial class {|#0:TestValueObject|} : BaseClass { } } @@ -734,9 +734,9 @@ public class BaseClass { public static int Property { get; } } - + [ValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClass + public partial class {|#0:TestValueObject|} : BaseClass { } } @@ -762,9 +762,9 @@ public class BaseClass { public int Property { get; set; } } - + [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClass + public partial class {|#0:TestValueObject|} : BaseClass { } } @@ -788,9 +788,9 @@ public class BaseClass { public int Property { get; } } - + [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClass + public partial class {|#0:TestValueObject|} : BaseClass { } } @@ -813,9 +813,9 @@ public class BaseClass { public static int Property { get; set; } } - + [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClass + public partial class {|#0:TestValueObject|} : BaseClass { } } @@ -839,9 +839,9 @@ public class BaseClass { public static int Property { get; } } - + [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClass + public partial class {|#0:TestValueObject|} : BaseClass { } } @@ -865,7 +865,7 @@ public async Task Should_trigger_on_instance_property() namespace TestNamespace { [ValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClassWithInstanceProperty + public partial class {|#0:TestValueObject|} : BaseClassWithInstanceProperty { } } @@ -887,7 +887,7 @@ public async Task Should_not_trigger_on_instance_property_with_getter_only() namespace TestNamespace { [ValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClassWithInstancePropertyWithGetterOnly + public partial class {|#0:TestValueObject|} : BaseClassWithInstancePropertyWithGetterOnly { } } @@ -908,7 +908,7 @@ public async Task Should_trigger_on_static_property() namespace TestNamespace { [ValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClassWithStaticProperty + public partial class {|#0:TestValueObject|} : BaseClassWithStaticProperty { } } @@ -930,7 +930,7 @@ public async Task Should_not_trigger_on_static_property_with_getter_only() namespace TestNamespace { [ValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClassWithStaticPropertyWithGetterOnly + public partial class {|#0:TestValueObject|} : BaseClassWithStaticPropertyWithGetterOnly { } } @@ -954,7 +954,7 @@ public async Task Should_trigger_on_instance_property() namespace TestNamespace { [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClassWithInstanceProperty + public partial class {|#0:TestValueObject|} : BaseClassWithInstanceProperty { } } @@ -976,7 +976,7 @@ public async Task Should_not_trigger_on_instance_property_with_getter_only() namespace TestNamespace { [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClassWithInstancePropertyWithGetterOnly + public partial class {|#0:TestValueObject|} : BaseClassWithInstancePropertyWithGetterOnly { } } @@ -997,7 +997,7 @@ public async Task Should_trigger_on_static_property() namespace TestNamespace { [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClassWithStaticProperty + public partial class {|#0:TestValueObject|} : BaseClassWithStaticProperty { } } @@ -1019,7 +1019,7 @@ public async Task Should_not_trigger_on_static_property_with_getter_only() namespace TestNamespace { [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} : BaseClassWithStaticPropertyWithGetterOnly + public partial class {|#0:TestValueObject|} : BaseClassWithStaticPropertyWithGetterOnly { } } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG036_EnumKeyShouldNotBeNullable.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG036_EnumKeyShouldNotBeNullable.cs index e3dbe95d..08809f3d 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG036_EnumKeyShouldNotBeNullable.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG036_EnumKeyShouldNotBeNullable.cs @@ -22,7 +22,7 @@ namespace TestNamespace { #pragma warning disable CS8632 [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} + public partial class {|#0:TestEnum|} #pragma warning restore CS8632 { public static readonly TestEnum Item1 = default; @@ -46,7 +46,7 @@ namespace TestNamespace { #pragma warning disable CS8632 [SmartEnum] - public sealed partial class {|#0:TestEnum|} + public partial class {|#0:TestEnum|} #pragma warning restore CS8632 { public static readonly TestEnum Item1 = default; @@ -69,7 +69,7 @@ public async Task Should_not_trigger_on_string_in_IValidatableEnum() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} + public partial class {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; } @@ -90,7 +90,7 @@ public async Task Should_not_trigger_on_string_in_IEnum() namespace TestNamespace { [SmartEnum] - public sealed partial class {|#0:TestEnum|} + public partial class {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; } @@ -111,7 +111,7 @@ public async Task Should_not_trigger_on_int_in_IValidatableEnum() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} + public partial class {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; } @@ -133,7 +133,7 @@ public async Task Should_not_trigger_on_int_in_IEnum() namespace TestNamespace { [SmartEnum] - public sealed partial class {|#0:TestEnum|} + public partial class {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG037_EnumWithoutDerivedTypesMustBeSealed.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG037_EnumWithoutDerivedTypesMustBeSealed.cs index 3dbcd234..107a7f26 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG037_EnumWithoutDerivedTypesMustBeSealed.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG037_EnumWithoutDerivedTypesMustBeSealed.cs @@ -8,80 +8,6 @@ public class TTRESG037_EnumWithoutDerivedTypesMustBeSealed { private const string _DIAGNOSTIC_ID = "TTRESG037"; - [Fact] - public async Task Should_trigger_on_IValidatableEnum() - { - var code = """ - - using System; - using Thinktecture; - - namespace TestNamespace - { - [SmartEnum(IsValidatable = true)] - public partial class {|#0:TestEnum|} - { - public static readonly TestEnum Item1 = default; - } - } - """; - - var expectedCode = """ - - using System; - using Thinktecture; - - namespace TestNamespace - { - [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum - { - public static readonly TestEnum Item1 = default; - } - } - """; - - var expected = Verifier.Diagnostic(_DIAGNOSTIC_ID).WithLocation(0).WithArguments("TestEnum"); - await Verifier.VerifyCodeFixAsync(code, expectedCode, new[] { typeof(IEnum<>).Assembly }, expected); - } - - [Fact] - public async Task Should_trigger_on_IEnum() - { - var code = """ - - using System; - using Thinktecture; - - namespace TestNamespace - { - [SmartEnum] - public partial class {|#0:TestEnum|} - { - public static readonly TestEnum Item1 = default; - } - } - """; - - var expectedCode = """ - - using System; - using Thinktecture; - - namespace TestNamespace - { - [SmartEnum] - public sealed partial class TestEnum - { - public static readonly TestEnum Item1 = default; - } - } - """; - - var expected = Verifier.Diagnostic(_DIAGNOSTIC_ID).WithLocation(0).WithArguments("TestEnum"); - await Verifier.VerifyCodeFixAsync(code, expectedCode, new[] { typeof(IEnum<>).Assembly }, expected); - } - [Fact] public async Task Should_trigger_on_inner_type() { @@ -96,18 +22,18 @@ namespace TestNamespace public partial class TestEnum { public static readonly TestEnum Item1 = default; - + private class Type_1 : TestEnum { public class {|#0:Type_3|} : Type_1 { } - + public sealed class Type_4 : Type_2 { } } - + private class Type_2 : Type_1 { } @@ -126,18 +52,18 @@ namespace TestNamespace public partial class TestEnum { public static readonly TestEnum Item1 = default; - + private class Type_1 : TestEnum { public sealed class Type_3 : Type_1 { } - + public sealed class Type_4 : Type_2 { } } - + private class Type_2 : Type_1 { } @@ -163,18 +89,18 @@ namespace TestNamespace public partial class TestEnum { public static readonly TestEnum Item1 = default; - + private class Type_1 : TestEnum { public sealed class Type_3 : Type_1 { } - + public class {|#0:Type_4|} : Type_2 { } } - + private class Type_2 : Type_1 { } @@ -193,18 +119,18 @@ namespace TestNamespace public partial class TestEnum { public static readonly TestEnum Item1 = default; - + private class Type_1 : TestEnum { public sealed class Type_3 : Type_1 { } - + public sealed class Type_4 : Type_2 { } } - + private class Type_2 : Type_1 { } @@ -217,7 +143,7 @@ private class Type_2 : Type_1 } [Fact] - public async Task Should_not_trigger_on_IValidatableEnum_with_derived_type() + public async Task Should_not_trigger_on_ValidatableEnum_with_derived_type() { var code = """ @@ -230,7 +156,7 @@ namespace TestNamespace public partial class {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; - + private sealed class DerivedType : TestEnum { } @@ -242,7 +168,7 @@ private sealed class DerivedType : TestEnum } [Fact] - public async Task Should_not_trigger_on_IEnum_with_derived_type() + public async Task Should_not_trigger_on_Enum_with_derived_type() { var code = """ @@ -255,7 +181,7 @@ namespace TestNamespace public partial class {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; - + private sealed class DerivedType : TestEnum { } @@ -280,7 +206,7 @@ namespace TestNamespace public partial class {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; - + private sealed class DerivedType : TestEnum { } @@ -292,7 +218,7 @@ private sealed class DerivedType : TestEnum } [Fact] - public async Task Should_not_trigger_on_IEnum_with_generic_derived_type() + public async Task Should_not_trigger_on_Enum_with_generic_derived_type() { var code = """ @@ -305,7 +231,7 @@ namespace TestNamespace public partial class {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; - + private sealed class DerivedType : TestEnum { } @@ -330,18 +256,18 @@ namespace TestNamespace public partial class {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; - + private class Type_1 : TestEnum { public sealed class Type_3 : Type_1 { } - + public sealed class Type_4 : Type_2 { } } - + private class Type_2 : Type_1 { } @@ -387,7 +313,7 @@ namespace TestNamespace public partial class {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; - + private abstract class Type_1 : TestEnum { } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG038_ValueObjectMustBeSealed.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG038_ValueObjectMustBeSealed.cs deleted file mode 100644 index 06d38ce2..00000000 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG038_ValueObjectMustBeSealed.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System.Threading.Tasks; -using Verifier = Thinktecture.Runtime.Tests.Verifiers.CodeFixVerifier; - -namespace Thinktecture.Runtime.Tests.AnalyzerAndCodeFixTests; - -// ReSharper disable InconsistentNaming -public class TTRESG038_ValueObjectMustBeSealed -{ - private const string _DIAGNOSTIC_ID = "TTRESG038"; - - public class KeyedValueObject_must_be_sealed - { - [Fact] - public async Task Should_trigger_on_non_sealed_value_object() - { - var code = """ - - using System; - using Thinktecture; - - namespace TestNamespace - { - [ValueObject] - public partial class {|#0:TestValueObject|} - { - } - } - """; - - var expectedCode = """ - - using System; - using Thinktecture; - - namespace TestNamespace - { - [ValueObject] - public sealed partial class TestValueObject - { - } - } - """; - - var expected = Verifier.Diagnostic(_DIAGNOSTIC_ID).WithLocation(0).WithArguments("TestValueObject"); - await Verifier.VerifyCodeFixAsync(code, expectedCode, new[] { typeof(ComplexValueObjectAttribute).Assembly }, expected); - } - - [Fact] - public async Task Should_not_trigger_on_sealed_value_object() - { - var code = """ - - using System; - using Thinktecture; - - namespace TestNamespace - { - [ValueObject] - public sealed partial class {|#0:TestValueObject|} - { - } - } - """; - - await Verifier.VerifyAnalyzerAsync(code, new[] { typeof(ComplexValueObjectAttribute).Assembly }); - } - } - - public class ComplexValueObject_must_be_sealed - { - [Fact] - public async Task Should_trigger_on_non_sealed_value_object() - { - var code = """ - - using System; - using Thinktecture; - - namespace TestNamespace - { - [ComplexValueObject] - public partial class {|#0:TestValueObject|} - { - public int Property { get; } - public int Other { get; } - } - } - """; - - var expectedCode = """ - - using System; - using Thinktecture; - - namespace TestNamespace - { - [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} - { - public int Property { get; } - public int Other { get; } - } - } - """; - - var expected = Verifier.Diagnostic(_DIAGNOSTIC_ID).WithLocation(0).WithArguments("TestValueObject"); - await Verifier.VerifyCodeFixAsync(code, expectedCode, new[] { typeof(ComplexValueObjectAttribute).Assembly }, expected); - } - - [Fact] - public async Task Should_not_trigger_on_sealed_value_object() - { - var code = """ - - using System; - using Thinktecture; - - namespace TestNamespace - { - [ComplexValueObject] - public sealed partial class {|#0:TestValueObject|} - { - public int Property { get; } - public int Other { get; } - } - } - """; - - await Verifier.VerifyAnalyzerAsync(code, new[] { typeof(ComplexValueObjectAttribute).Assembly }); - } - } -} diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG041_ComparerTypeMustMatchMemberType.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG041_ComparerTypeMustMatchMemberType.cs index 83c6e187..8a9ff14e 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG041_ComparerTypeMustMatchMemberType.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG041_ComparerTypeMustMatchMemberType.cs @@ -27,7 +27,7 @@ namespace TestNamespace { [SmartEnum] [{|#0:ValueObjectKeyMemberComparer, string>|}] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default!; } @@ -53,7 +53,7 @@ namespace TestNamespace { [SmartEnum] [{|#0:ValueObjectKeyMemberComparer, int>|}] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default!; } @@ -81,7 +81,7 @@ namespace TestNamespace { [ValueObject] [{|#0:ValueObjectKeyMemberComparer, string>|}] - public sealed partial class TestValueObject + public partial class TestValueObject { } } @@ -106,7 +106,7 @@ namespace TestNamespace { [ValueObject] [{|#0:ValueObjectKeyMemberComparer, int>|}] - public sealed partial class TestValueObject + public partial class TestValueObject { } } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG042_InitAccessortMustBePrivate.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG042_InitAccessortMustBePrivate.cs index c23922bf..c7e6909f 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG042_InitAccessortMustBePrivate.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG042_InitAccessortMustBePrivate.cs @@ -21,7 +21,7 @@ public async Task Should_trigger_on_public_property_with_default_init() namespace TestNamespace { [ValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { public int {|#0:InstanceProperty|} { get; init; } } @@ -36,7 +36,7 @@ public sealed partial class TestValueObject namespace TestNamespace { [ValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { public int InstanceProperty { get; private init; } } @@ -58,11 +58,11 @@ public async Task Should_trigger_on_public_property_with_init_expression() namespace TestNamespace { [ValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { [ValueObjectMemberIgnore] private readonly int _instanceProperty; - + public int {|#0:InstanceProperty|} { get => _instanceProperty; @@ -80,11 +80,11 @@ public sealed partial class TestValueObject namespace TestNamespace { [ValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { [ValueObjectMemberIgnore] private readonly int _instanceProperty; - + public int {|#0:InstanceProperty|} { get => _instanceProperty; @@ -109,11 +109,11 @@ public async Task Should_trigger_on_public_property_with_init_body() namespace TestNamespace { [ValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { [ValueObjectMemberIgnore] private readonly int _instanceProperty; - + public int {|#0:InstanceProperty|} { get { return _instanceProperty; } @@ -131,11 +131,11 @@ public sealed partial class TestValueObject namespace TestNamespace { [ValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { [ValueObjectMemberIgnore] private readonly int _instanceProperty; - + public int {|#0:InstanceProperty|} { get { return _instanceProperty; } @@ -160,7 +160,7 @@ public async Task Should_not_trigger_on_private_property_with_default_init() namespace TestNamespace { [ValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { private int {|#0:InstanceProperty|} { get; init; } } @@ -181,11 +181,11 @@ public async Task Should_not_trigger_on_private_property_with_init_expression() namespace TestNamespace { [ValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { [ValueObjectMemberIgnore] private readonly int _instanceProperty; - + private int {|#0:InstanceProperty|} { get => _instanceProperty; @@ -209,11 +209,11 @@ public async Task Should_not_trigger_on_private_property_with_init_body() namespace TestNamespace { [ValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { [ValueObjectMemberIgnore] private readonly int _instanceProperty; - + private int {|#0:InstanceProperty|} { get { return _instanceProperty; } @@ -240,7 +240,7 @@ public async Task Should_trigger_on_public_property_with_default_init() namespace TestNamespace { [ComplexValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { public int {|#0:InstanceProperty|} { get; init; } } @@ -255,7 +255,7 @@ public sealed partial class TestValueObject namespace TestNamespace { [ComplexValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { public int InstanceProperty { get; private init; } } @@ -277,11 +277,11 @@ public async Task Should_trigger_on_public_property_with_init_expression() namespace TestNamespace { [ComplexValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { [ValueObjectMemberIgnore] private readonly int _instanceProperty; - + public int {|#0:InstanceProperty|} { get => _instanceProperty; @@ -299,11 +299,11 @@ public sealed partial class TestValueObject namespace TestNamespace { [ComplexValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { [ValueObjectMemberIgnore] private readonly int _instanceProperty; - + public int {|#0:InstanceProperty|} { get => _instanceProperty; @@ -328,11 +328,11 @@ public async Task Should_trigger_on_public_property_with_init_body() namespace TestNamespace { [ComplexValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { [ValueObjectMemberIgnore] private readonly int _instanceProperty; - + public int {|#0:InstanceProperty|} { get { return _instanceProperty; } @@ -350,11 +350,11 @@ public sealed partial class TestValueObject namespace TestNamespace { [ComplexValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { [ValueObjectMemberIgnore] private readonly int _instanceProperty; - + public int {|#0:InstanceProperty|} { get { return _instanceProperty; } @@ -379,7 +379,7 @@ public async Task Should_not_trigger_on_private_property_with_default_init() namespace TestNamespace { [ComplexValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { private int {|#0:InstanceProperty|} { get; init; } } @@ -400,11 +400,11 @@ public async Task Should_not_trigger_on_private_property_with_init_expression() namespace TestNamespace { [ComplexValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { [ValueObjectMemberIgnore] private readonly int _instanceProperty; - + private int {|#0:InstanceProperty|} { get => _instanceProperty; @@ -428,11 +428,11 @@ public async Task Should_not_trigger_on_private_property_with_init_body() namespace TestNamespace { [ComplexValueObject] - public sealed partial class TestValueObject + public partial class TestValueObject { [ValueObjectMemberIgnore] private readonly int _instanceProperty; - + private int {|#0:InstanceProperty|} { get { return _instanceProperty; } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG043_PrimaryConstructorNotAllowed.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG043_PrimaryConstructorNotAllowed.cs index 7117a60a..aa2705e8 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG043_PrimaryConstructorNotAllowed.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG043_PrimaryConstructorNotAllowed.cs @@ -21,7 +21,7 @@ public async Task Should_trigger_if_enum_is_class_and_has_primary_constructor() namespace TestNamespace { [SmartEnum] - public sealed partial class {|#0:TestEnum|}() + public partial class {|#0:TestEnum|}() { public static readonly TestEnum Item1 = default; } @@ -43,7 +43,7 @@ public async Task Should_trigger_if_enum_is_struct_and_has_primary_constructor() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public readonly partial struct {|#0:TestEnum|}() + public partial struct {|#0:TestEnum|}() { public static readonly TestEnum Item1 = default; } @@ -68,7 +68,7 @@ public async Task Should_trigger_if_value_object_is_class_and_has_primary_constr namespace TestNamespace { [ValueObject] - public sealed partial class {|#0:ValueObject|}() + public partial class {|#0:ValueObject|}() { } } @@ -89,7 +89,7 @@ public async Task Should_trigger_if_value_object_is_struct_and_has_primary_const namespace TestNamespace { [ValueObject] - public readonly partial struct {|#0:ValueObject|}() + public partial struct {|#0:ValueObject|}() { } } @@ -113,7 +113,7 @@ public async Task Should_trigger_if_value_object_is_class_and_has_primary_constr namespace TestNamespace { [ComplexValueObject] - public sealed partial class {|#0:ValueObject|}() + public partial class {|#0:ValueObject|}() { } } @@ -134,7 +134,7 @@ public async Task Should_trigger_if_value_object_is_struct_and_has_primary_const namespace TestNamespace { [ComplexValueObject] - public readonly partial struct {|#0:ValueObject|}() + public partial struct {|#0:ValueObject|}() { } } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG044_CustomKeyMemberImplementationNotFound.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG044_CustomKeyMemberImplementationNotFound.cs index 3245a448..402d9175 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG044_CustomKeyMemberImplementationNotFound.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG044_CustomKeyMemberImplementationNotFound.cs @@ -21,7 +21,7 @@ public async Task Should_trigger_if_key_member_implementation_missing() namespace TestNamespace { [ValueObject(SkipKeyMember = true)] - public sealed partial class {|#0:ValueObject|} + public partial class {|#0:ValueObject|} { } } @@ -42,7 +42,7 @@ public async Task Should_not_trigger_if_key_member_implementation_found() namespace TestNamespace { [ValueObject(SkipKeyMember = true)] - public sealed partial class {|#0:ValueObject|} + public partial class {|#0:ValueObject|} { private readonly string _value; } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG045_CustomKeyMemberImplementationTypeMismatch.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG045_CustomKeyMemberImplementationTypeMismatch.cs index 36e2d0ca..acc93764 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG045_CustomKeyMemberImplementationTypeMismatch.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG045_CustomKeyMemberImplementationTypeMismatch.cs @@ -21,7 +21,7 @@ public async Task Should_trigger_if_key_member_type_differs_from_type_specified_ namespace TestNamespace { [ValueObject(SkipKeyMember = true)] - public sealed partial class ValueObject + public partial class ValueObject { private readonly int {|#0:_value|}; } @@ -45,7 +45,7 @@ public async Task Should_trigger_if_key_member_type_is_nullable_reference_type() namespace TestNamespace { [ValueObject(SkipKeyMember = true)] - public sealed partial class ValueObject + public partial class ValueObject { private readonly string? {|#0:_value|}; } @@ -69,7 +69,7 @@ public async Task Should_trigger_if_key_member_type_is_nullable_struct() namespace TestNamespace { [ValueObject(SkipKeyMember = true)] - public sealed partial class ValueObject + public partial class ValueObject { private readonly int? {|#0:_value|}; } @@ -91,7 +91,7 @@ public async Task Should_not_trigger_if_key_member_type_is_correct() namespace TestNamespace { [ValueObject(SkipKeyMember = true)] - public sealed partial class {|#0:ValueObject|} + public partial class {|#0:ValueObject|} { private readonly string _value; } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG100_EnumerationHasNoItems.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG100_EnumerationHasNoItems.cs index 244c4fbf..b4c11de9 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG100_EnumerationHasNoItems.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG100_EnumerationHasNoItems.cs @@ -19,7 +19,7 @@ public async Task Should_trigger_if_enumeration_has_no_items() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} + public partial class {|#0:TestEnum|} { } } @@ -40,7 +40,7 @@ public async Task Should_not_trigger_if_enumeration_has_items() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class {|#0:TestEnum|} + public partial class {|#0:TestEnum|} { public static readonly TestEnum Item1 = default; } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG101_StaticPropertiesAreNotConsideredItems.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG101_StaticPropertiesAreNotConsideredItems.cs index da0d59de..0550ac57 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG101_StaticPropertiesAreNotConsideredItems.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/AnalyzerAndCodeFixTests/TTRESG101_StaticPropertiesAreNotConsideredItems.cs @@ -19,10 +19,10 @@ public async Task Should_trigger_if_potential_item_is_a_property() namespace TestNamespace { [SmartEnum(IsValidatable = true)] - public sealed partial class TestEnum + public partial class TestEnum { public static readonly TestEnum Item1 = default; - + public static TestEnum {|#0:Item2|} => default; } } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/EnumSourceGeneratorTests.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/EnumSourceGeneratorTests.cs index a024c2dc..50821429 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/EnumSourceGeneratorTests.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/EnumSourceGeneratorTests.cs @@ -59,7 +59,7 @@ public EnumSourceGeneratorTests(ITestOutputHelper output) """; - private const string _MAIN_OUTPUT_STRING_BASED_CLASS = _GENERATED_HEADER + """ + private const string _MAIN_OUTPUT_STRING_BASED_ABSTRACT_CLASS = _GENERATED_HEADER + """ namespace Thinktecture.Tests { @@ -375,12 +375,328 @@ void AddItem(global::Thinktecture.Tests.TestEnum item, string itemName) """; + private const string _MAIN_OUTPUT_STRING_BASED_CLASS = _GENERATED_HEADER + """ + + namespace Thinktecture.Tests + { + [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] + sealed partial class TestEnum : global::Thinktecture.IEnum, + global::System.IEquatable + { + [global::System.Runtime.CompilerServices.ModuleInitializer] + internal static void ModuleInit() + { + var convertFromKey = new global::System.Func(global::Thinktecture.Tests.TestEnum.Get); + global::System.Linq.Expressions.Expression> convertFromKeyExpression = static key => global::Thinktecture.Tests.TestEnum.Get(key); + + var convertToKey = new global::System.Func(static item => item.Key); + global::System.Linq.Expressions.Expression> convertToKeyExpression = static item => item.Key; + + var enumType = typeof(global::Thinktecture.Tests.TestEnum); + var metadata = new global::Thinktecture.Internal.KeyedValueObjectMetadata(enumType, typeof(string), true, false, convertFromKey, convertFromKeyExpression, null, convertToKey, convertToKeyExpression); + + global::Thinktecture.Internal.KeyedValueObjectMetadataLookup.AddMetadata(enumType, metadata); + } + + private static readonly global::System.Lazy> _itemsLookup + = new global::System.Lazy>(GetLookup, global::System.Threading.LazyThreadSafetyMode.PublicationOnly); + + private static readonly global::System.Lazy> _items + = new global::System.Lazy>(() => global::System.Linq.Enumerable.ToList(_itemsLookup.Value.Values).AsReadOnly(), global::System.Threading.LazyThreadSafetyMode.PublicationOnly); + + /// + /// Gets all valid items. + /// + public static global::System.Collections.Generic.IReadOnlyList Items => _items.Value; + + /// + /// The identifier of this item. + /// + public string Key { get; } + + private readonly int _hashCode; + private readonly global::System.Lazy _itemIndex; + + private TestEnum(string key) + { + ValidateConstructorArguments(ref key); + + if (key is null) + throw new global::System.ArgumentNullException(nameof(key)); + + this.Key = key; + this._hashCode = global::System.HashCode.Combine(typeof(global::Thinktecture.Tests.TestEnum), global::System.StringComparer.OrdinalIgnoreCase.GetHashCode(key)); + this._itemIndex = new global::System.Lazy(() => + { + for (var i = 0; i < Items.Count; i++) + { + if (this == Items[i]) + return i; + } + + throw new global::System.Exception($"Current item '{key}' not found in 'Items'."); + }, global::System.Threading.LazyThreadSafetyMode.PublicationOnly); + } + + static partial void ValidateConstructorArguments(ref string key); + + /// + /// Gets the identifier of the item. + /// + [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + string global::Thinktecture.IValueObjectConvertable.ToValue() + { + return this.Key; + } + + /// + /// Gets an enumeration item for provided . + /// + /// The identifier to return an enumeration item for. + /// An instance of if is not null; otherwise null. + /// If there is no item with the provided . + [return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("key")] + public static global::Thinktecture.Tests.TestEnum? Get(string? key) + { + if (key is null) + return default; + + if (!_itemsLookup.Value.TryGetValue(key, out var item)) + { + throw new global::Thinktecture.UnknownEnumIdentifierException(typeof(global::Thinktecture.Tests.TestEnum), key); + } + + return item; + } + + /// + /// Gets a valid enumeration item for provided if a valid item exists. + /// + /// The identifier to return an enumeration item for. + /// An instance of . + /// true if a valid item with provided exists; false otherwise. + public static bool TryGet([global::System.Diagnostics.CodeAnalysis.AllowNull] string key, [global::System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)] out global::Thinktecture.Tests.TestEnum item) + { + if (key is null) + { + item = default; + return false; + } + + return _itemsLookup.Value.TryGetValue(key, out item); + } + + /// + /// Validates the provided and returns a valid enumeration item if found. + /// + /// The identifier to return an enumeration item for. + /// An object that provides culture-specific formatting information. + /// An instance of . + /// null if a valid item with provided exists; with an error message otherwise. + public static global::Thinktecture.ValidationError? Validate([global::System.Diagnostics.CodeAnalysis.AllowNull] string key, global::System.IFormatProvider? provider, [global::System.Diagnostics.CodeAnalysis.MaybeNull] out global::Thinktecture.Tests.TestEnum item) + { + if(global::Thinktecture.Tests.TestEnum.TryGet(key, out item)) + { + return null; + } + else + { + return global::Thinktecture.Internal.ValidationErrorCreator.CreateValidationError($"There is no item of type 'TestEnum' with the identifier '{key}'."); + } + } + + /// + /// Implicit conversion to the type . + /// + /// Item to covert. + /// The of provided or default if is null. + [return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("item")] + public static implicit operator string?(global::Thinktecture.Tests.TestEnum? item) + { + return item is null ? default : item.Key; + } + + /// + /// Explicit conversion from the type . + /// + /// Value to covert. + /// An instance of if the is a known item or implements . + [return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("key")] + public static explicit operator global::Thinktecture.Tests.TestEnum?(string? key) + { + return global::Thinktecture.Tests.TestEnum.Get(key); + } + + /// + public bool Equals(global::Thinktecture.Tests.TestEnum? other) + { + return global::System.Object.ReferenceEquals(this, other); + } + + /// + public override bool Equals(object? other) + { + return other is global::Thinktecture.Tests.TestEnum item && Equals(item); + } + + /// + public override int GetHashCode() + { + return _hashCode; + } + + /// + public override string ToString() + { + return this.Key.ToString(); + } + + /// + /// Executes an action depending on the current item. + /// + /// The action to execute if the current item is equal to . + /// The action to execute if the current item is equal to . + public void Switch( + global::System.Action item1, + global::System.Action item2) + { + switch (_itemIndex.Value) + { + case 0: + item1(); + return; + case 1: + item2(); + return; + default: + throw new global::System.ArgumentOutOfRangeException($"Unknown item '{this}'."); + } + } + + /// + /// Executes an action depending on the current item. + /// + /// Context to be passed to the callbacks. + /// The action to execute if the current item is equal to . + /// The action to execute if the current item is equal to . + public void Switch( + TContext context, + global::System.Action item1, + global::System.Action item2) + { + switch (_itemIndex.Value) + { + case 0: + item1(context); + return; + case 1: + item2(context); + return; + default: + throw new global::System.ArgumentOutOfRangeException($"Unknown item '{this}'."); + } + } + + /// + /// Executes a function depending on the current item. + /// + /// The function to execute if the current item is equal to . + /// The function to execute if the current item is equal to . + public TResult Switch( + global::System.Func item1, + global::System.Func item2) + { + switch (_itemIndex.Value) + { + case 0: + return item1(); + case 1: + return item2(); + default: + throw new global::System.ArgumentOutOfRangeException($"Unknown item '{this}'."); + } + } + + /// + /// Executes a function depending on the current item. + /// + /// Context to be passed to the callbacks. + /// The function to execute if the current item is equal to . + /// The function to execute if the current item is equal to . + public TResult Switch( + TContext context, + global::System.Func item1, + global::System.Func item2) + { + switch (_itemIndex.Value) + { + case 0: + return item1(context); + case 1: + return item2(context); + default: + throw new global::System.ArgumentOutOfRangeException($"Unknown item '{this}'."); + } + } + + /// + /// Maps an item to an instance of type . + /// + /// The instance to return if the current item is equal to . + /// The instance to return if the current item is equal to . + public TResult Map( + TResult item1, + TResult item2) + { + switch (_itemIndex.Value) + { + case 0: + return item1; + case 1: + return item2; + default: + throw new global::System.ArgumentOutOfRangeException($"Unknown item '{this}'."); + } + } + + private static global::System.Collections.Generic.IReadOnlyDictionary GetLookup() + { + var lookup = new global::System.Collections.Generic.Dictionary(2, global::System.StringComparer.OrdinalIgnoreCase); + + void AddItem(global::Thinktecture.Tests.TestEnum item, string itemName) + { + if (item is null) + throw new global::System.ArgumentNullException($"The item \"{itemName}\" of type \"TestEnum\" must not be null."); + + if (item.Key is null) + throw new global::System.ArgumentException($"The \"Key\" of the item \"{itemName}\" of type \"TestEnum\" must not be null."); + + if (lookup.ContainsKey(item.Key)) + throw new global::System.ArgumentException($"The type \"TestEnum\" has multiple items with the identifier \"{item.Key}\"."); + + lookup.Add(item.Key, item); + } + + AddItem(@Item1, nameof(@Item1)); + AddItem(@Item2, nameof(@Item2)); + + #if NET8_0_OR_GREATER + return global::System.Collections.Frozen.FrozenDictionary.ToFrozenDictionary(lookup, global::System.StringComparer.OrdinalIgnoreCase); + #else + return lookup; + #endif + } + } + } + + """; + private const string _MAIN_OUTPUT_INT_BASED_CLASS = _GENERATED_HEADER + """ namespace Thinktecture.Tests { [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial class TestEnum : global::Thinktecture.IEnum, + sealed partial class TestEnum : global::Thinktecture.IEnum, global::System.IEquatable { [global::System.Runtime.CompilerServices.ModuleInitializer] @@ -1236,7 +1552,7 @@ public partial class TestEnum namespace Thinktecture.Tests { - partial class TestEnum : + sealed partial class TestEnum : global::System.IEquatable { private static readonly global::System.Lazy> _items @@ -1604,7 +1920,7 @@ public partial class TestEnum namespace Thinktecture.Tests { - partial class TestEnum : + sealed partial class TestEnum : global::Thinktecture.IValueObjectFactory, global::System.IEquatable { @@ -1844,7 +2160,7 @@ public override string ToString() namespace Thinktecture.Tests { [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial class TestEnum : global::Thinktecture.IEnum, + sealed partial class TestEnum : global::Thinktecture.IEnum, global::System.IEquatable { [global::System.Runtime.CompilerServices.ModuleInitializer] @@ -2394,7 +2710,7 @@ public partial class TestEnum namespace Thinktecture.Tests { [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial class TestEnum : global::Thinktecture.IEnum, + sealed partial class TestEnum : global::Thinktecture.IEnum, global::System.IEquatable { [global::System.Runtime.CompilerServices.ModuleInitializer] @@ -2685,7 +3001,7 @@ public partial class TestEnum namespace Thinktecture.Tests { [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial class TestEnum : global::Thinktecture.IEnum, + sealed partial class TestEnum : global::Thinktecture.IEnum, global::System.IEquatable { [global::System.Runtime.CompilerServices.ModuleInitializer] @@ -3152,7 +3468,7 @@ public partial class TestEnum : BaseClass namespace Thinktecture.Tests { [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial class TestEnum : global::Thinktecture.IEnum, + sealed partial class TestEnum : global::Thinktecture.IEnum, global::System.IEquatable { [global::System.Runtime.CompilerServices.ModuleInitializer] @@ -3674,7 +3990,7 @@ public partial class TestEnum AssertOutput(mainOutput, _GENERATED_HEADER + """ [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial class TestEnum : global::Thinktecture.IEnum, + sealed partial class TestEnum : global::Thinktecture.IEnum, global::System.IEquatable { [global::System.Runtime.CompilerServices.ModuleInitializer] @@ -5188,7 +5504,7 @@ public partial class TestEnum namespace Thinktecture.Tests { [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial class TestEnum : global::Thinktecture.IEnum, + sealed partial class TestEnum : global::Thinktecture.IEnum, global::Thinktecture.IValidatableEnum, global::System.IEquatable { @@ -5815,7 +6131,7 @@ namespace Thinktecture.Tests [SmartEnum(IsValidatable = true, SwitchMethods = SwitchMapMethodsGeneration.DefaultWithPartialOverloads, MapMethods = SwitchMapMethodsGeneration.DefaultWithPartialOverloads)] - public readonly partial struct TestEnum + public partial struct TestEnum { public static readonly TestEnum Item1 = new("Item1"); public static readonly TestEnum Item2 = new("Item2"); @@ -5839,7 +6155,7 @@ namespace Thinktecture.Tests { [global::System.Runtime.InteropServices.StructLayout(global::System.Runtime.InteropServices.LayoutKind.Auto)] [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial struct TestEnum : global::Thinktecture.IEnum, + readonly partial struct TestEnum : global::Thinktecture.IEnum, global::Thinktecture.IValidatableEnum, global::System.IEquatable { @@ -6614,7 +6930,7 @@ public DerivedEnum( namespace Thinktecture.Tests { [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial class TestEnum : global::Thinktecture.IEnum, + sealed partial class TestEnum : global::Thinktecture.IEnum, global::Thinktecture.IValidatableEnum, global::System.IEquatable { @@ -7516,7 +7832,7 @@ public partial class TestEnum namespace Thinktecture.Tests { [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial class TestEnum : global::Thinktecture.IEnum, + sealed partial class TestEnum : global::Thinktecture.IEnum, global::Thinktecture.IValueObjectFactory, global::System.IEquatable { @@ -8013,7 +8329,7 @@ public partial class TestEnum namespace Thinktecture.Tests { [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial class TestEnum : global::Thinktecture.IEnum, + sealed partial class TestEnum : global::Thinktecture.IEnum, global::Thinktecture.IValueObjectFactory, global::Thinktecture.IValueObjectConvertable, global::System.IEquatable @@ -8508,7 +8824,7 @@ public ConcreteEnum(int key) var equalityComparisonOperators = outputs.Single(kvp => kvp.Key.Contains("Thinktecture.Tests.TestEnum.EqualityComparisonOperators.g.cs")).Value; var derivedTypes = outputs.Single(kvp => kvp.Key.Contains("Thinktecture.Tests.TestEnum.DerivedTypes.g.cs")).Value; - AssertOutput(mainOutput, _MAIN_OUTPUT_STRING_BASED_CLASS); + AssertOutput(mainOutput, _MAIN_OUTPUT_STRING_BASED_ABSTRACT_CLASS); AssertOutput(comparableOutput, _COMPARABLE_OUTPUT_CLASS_STRING_BASED); AssertOutput(parsableOutput, _PARSABLE_OUTPUT_CLASS_STRING_BASED); AssertOutput(comparisonOperatorsOutput, _COMPARISON_OPERATORS_OUTPUT_CLASS_STRING_BASED); diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/JsonSmartEnumSourceGeneratorTests.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/JsonSmartEnumSourceGeneratorTests.cs index 6a62c239..18d16c8d 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/JsonSmartEnumSourceGeneratorTests.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/JsonSmartEnumSourceGeneratorTests.cs @@ -88,7 +88,7 @@ public void Should_generate_JsonConverter_and_Attribute_for_struct_if_Attribute_ namespace Thinktecture.Tests { [SmartEnum] - public readonly partial struct TestEnum + public partial struct TestEnum { public static readonly TestEnum Item1 = new("Item1"); public static readonly TestEnum Item2 = new("Item2"); diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/JsonValueObjectSourceGeneratorTests.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/JsonValueObjectSourceGeneratorTests.cs index 01fd0e34..1bcf71c8 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/JsonValueObjectSourceGeneratorTests.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/JsonValueObjectSourceGeneratorTests.cs @@ -86,7 +86,7 @@ public void Should_generate_JsonConverter_and_attribute_for_keyed_struct() namespace Thinktecture.Tests { [ValueObject] - public readonly partial struct TestValueObject + public partial struct TestValueObject { } } @@ -293,7 +293,7 @@ public void Should_generate_JsonConverter_and_attribute_for_complex_struct() namespace Thinktecture.Tests { [ComplexValueObject] - public readonly partial struct TestValueObject + public partial struct TestValueObject { public readonly string ReferenceField; public int StructProperty { get; } @@ -465,7 +465,7 @@ public void Should_generate_JsonConverter_complex_class_if_Attribute_is_missing( namespace Thinktecture.Tests { [ComplexValueObject] - public readonly partial struct TestValueObject + public partial struct TestValueObject { public readonly string ReferenceField; public int StructProperty { get; } @@ -635,7 +635,7 @@ public void Should_generate_JsonConverter_and_attribute_for_complex_struct_witho using Thinktecture; [ComplexValueObject] - public readonly partial struct TestValueObject + public partial struct TestValueObject { public readonly string ReferenceField; public int StructProperty { get; } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/MessagePackSmartEnumSourceGeneratorTests.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/MessagePackSmartEnumSourceGeneratorTests.cs index 1775b95a..9e844f83 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/MessagePackSmartEnumSourceGeneratorTests.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/MessagePackSmartEnumSourceGeneratorTests.cs @@ -90,7 +90,7 @@ public void Should_generate_MessagePackFormatter_and_Attribute_for_struct_if_Att namespace Thinktecture.Tests { [SmartEnum] - public readonly partial struct TestEnum + public partial struct TestEnum { public static readonly TestEnum Item1 = new("Item1"); public static readonly TestEnum Item2 = new("Item2"); @@ -133,7 +133,7 @@ public TestEnumMessagePackFormatter() { } } - + [SmartEnum] [MessagePackFormatter(typeof(TestEnumMessagePackFormatter))] public partial class TestEnum diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/MessagePackValueObjectSourceGeneratorTests.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/MessagePackValueObjectSourceGeneratorTests.cs index 2ecab314..dbe243a5 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/MessagePackValueObjectSourceGeneratorTests.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/MessagePackValueObjectSourceGeneratorTests.cs @@ -88,7 +88,7 @@ public void Should_generate_MessagePackFormatter_and_attribute_for_keyed_struct( namespace Thinktecture.Tests { [ValueObject] - public readonly partial struct TestValueObject + public partial struct TestValueObject { } } @@ -308,7 +308,7 @@ public void Should_generate_MessagePackFormatter_and_attribute_for_complex_struc namespace Thinktecture.Tests { [ComplexValueObject] - public readonly partial struct TestValueObject + public partial struct TestValueObject { public readonly string ReferenceField; public int StructProperty { get; } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/NewtonsoftJsonSmartEnumSourceGeneratorTests.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/NewtonsoftJsonSmartEnumSourceGeneratorTests.cs index 8bdc6998..5e44d65d 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/NewtonsoftJsonSmartEnumSourceGeneratorTests.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/NewtonsoftJsonSmartEnumSourceGeneratorTests.cs @@ -53,7 +53,7 @@ public void Should_generate_NewtonsoftJsonConverter_for_enum_without_namespace() using System; using Thinktecture; - + [SmartEnum] public partial class TestEnum { @@ -88,7 +88,7 @@ public void Should_generate_NewtonsoftJsonConverter_and_Attribute_for_struct_if_ namespace Thinktecture.Tests { [SmartEnum] - public readonly partial struct TestEnum + public partial struct TestEnum { public static readonly TestEnum Item1 = new("Item1"); public static readonly TestEnum Item2 = new("Item2"); @@ -131,7 +131,7 @@ public TestEnum_ValueObjectNewtonsoftJsonConverter() { } } - + [SmartEnum] [JsonConverterAttribute(typeof(TestEnum_ValueObjectNewtonsoftJsonConverter))] public partial class TestEnum diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/NewtonsoftJsonValueObjectSourceGeneratorTests.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/NewtonsoftJsonValueObjectSourceGeneratorTests.cs index 29f5aab4..1b7a95d6 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/NewtonsoftJsonValueObjectSourceGeneratorTests.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/NewtonsoftJsonValueObjectSourceGeneratorTests.cs @@ -86,7 +86,7 @@ public void Should_generate_NewtonsoftJsonConverter_and_attribute_for_keyed_stru namespace Thinktecture.Tests { [ValueObject] - public readonly partial struct TestValueObject + public partial struct TestValueObject { } } @@ -530,7 +530,7 @@ public void Should_generate_NewtonsoftJsonConverter_and_attribute_for_complex_st namespace Thinktecture.Tests { [ComplexValueObject] - public readonly partial struct TestValueObject + public partial struct TestValueObject { public readonly string ReferenceField; public int StructProperty { get; } diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/ValueObjectSourceGeneratorTests.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/ValueObjectSourceGeneratorTests.cs index 99904050..78945ab7 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/ValueObjectSourceGeneratorTests.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/SourceGeneratorTests/ValueObjectSourceGeneratorTests.cs @@ -17,7 +17,7 @@ namespace Thinktecture.Tests { [global::System.Runtime.InteropServices.StructLayout(global::System.Runtime.InteropServices.LayoutKind.Auto)] [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial struct TestValueObject : global::System.IEquatable, + readonly partial struct TestValueObject : global::System.IEquatable, global::Thinktecture.IKeyedValueObject, global::Thinktecture.IValueObjectConvertable, global::Thinktecture.IValueObjectFactory @@ -587,7 +587,7 @@ public string ToString(string? format, global::System.IFormatProvider? formatPro namespace Thinktecture.Tests { [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial class TestValueObject : global::System.IEquatable, + sealed partial class TestValueObject : global::System.IEquatable, global::Thinktecture.IKeyedValueObject, global::Thinktecture.IValueObjectConvertable, global::Thinktecture.IValueObjectFactory @@ -1264,7 +1264,7 @@ private static bool Equals(global::Thinktecture.Tests.TestValueObject? obj, int namespace Thinktecture.Tests { - partial class TestValueObject : global::System.IEquatable, + sealed partial class TestValueObject : global::System.IEquatable, global::System.Numerics.IEqualityOperators, global::Thinktecture.IComplexValueObject { @@ -1405,7 +1405,7 @@ public override string ToString() namespace Thinktecture.Tests { - partial struct TestValueObject : global::System.IEquatable, + readonly partial struct TestValueObject : global::System.IEquatable, global::System.Numerics.IEqualityOperators, global::Thinktecture.IComplexValueObject { @@ -1536,7 +1536,7 @@ public override string ToString() namespace Thinktecture.Tests { [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial class TestValueObject : global::System.IEquatable, + sealed partial class TestValueObject : global::System.IEquatable, global::Thinktecture.IKeyedValueObject, global::Thinktecture.IValueObjectConvertable, global::Thinktecture.IValueObjectFactory @@ -1700,7 +1700,7 @@ namespace Thinktecture.Tests { [global::System.Runtime.InteropServices.StructLayout(global::System.Runtime.InteropServices.LayoutKind.Auto)] [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial struct TestValueObject : global::System.IEquatable, + readonly partial struct TestValueObject : global::System.IEquatable, global::Thinktecture.IKeyedValueObject, global::Thinktecture.IValueObjectConvertable, global::Thinktecture.IValueObjectFactory @@ -1919,7 +1919,7 @@ static partial int ValidateFactoryArguments(ref ValidationError? validationError namespace Thinktecture.Tests { - partial class TestValueObject : global::System.IEquatable, + sealed partial class TestValueObject : global::System.IEquatable, global::System.Numerics.IEqualityOperators, global::Thinktecture.IComplexValueObject { @@ -2086,7 +2086,7 @@ public partial class TestValueObject namespace Thinktecture.Tests { - partial class TestValueObject : global::System.IEquatable, + sealed partial class TestValueObject : global::System.IEquatable, global::System.Numerics.IEqualityOperators, global::Thinktecture.IComplexValueObject { @@ -2284,7 +2284,7 @@ public partial class TestValueObject AssertOutput(output, _GENERATED_HEADER + """ - partial class TestValueObject : global::System.IEquatable, + sealed partial class TestValueObject : global::System.IEquatable, global::System.Numerics.IEqualityOperators, global::Thinktecture.IComplexValueObject { @@ -2477,7 +2477,7 @@ public partial class TestValueObject namespace Thinktecture.Tests { - partial class TestValueObject : global::System.IEquatable, + sealed partial class TestValueObject : global::System.IEquatable, global::Thinktecture.IKeyedValueObject, global::Thinktecture.IValueObjectConvertable { @@ -2593,7 +2593,7 @@ public void Should_generate_complex_struct_without_members() namespace Thinktecture.Tests { [ComplexValueObject] - public readonly partial struct TestValueObject + public partial struct TestValueObject { } } @@ -2615,7 +2615,7 @@ public void Should_generate_complex_struct_with_custom_default_instance_property namespace Thinktecture.Tests { [ComplexValueObject(DefaultInstancePropertyName = "Null")] - public readonly partial struct TestValueObject + public partial struct TestValueObject { } } @@ -2627,7 +2627,7 @@ public readonly partial struct TestValueObject namespace Thinktecture.Tests { - partial struct TestValueObject : global::System.IEquatable, + readonly partial struct TestValueObject : global::System.IEquatable, global::System.Numerics.IEqualityOperators, global::Thinktecture.IComplexValueObject { @@ -2765,7 +2765,7 @@ public void Should_generate_string_based_keyed_struct() namespace Thinktecture.Tests { [ValueObject] - public readonly partial struct TestValueObject + public partial struct TestValueObject { } } @@ -2798,7 +2798,7 @@ public void Should_generate_int_based_keyed_struct() namespace Thinktecture.Tests { [ValueObject] - public readonly partial struct TestValueObject + public partial struct TestValueObject { } } @@ -2841,7 +2841,7 @@ public void Should_generate_int_based_keyed_struct_with_custom_int_key_member_wi namespace Thinktecture.Tests { [ValueObject(SkipKeyMember = true)] - public readonly partial struct TestValueObject + public partial struct TestValueObject { public readonly int _value { get; private init; } } @@ -2878,7 +2878,7 @@ namespace Thinktecture.Tests { [global::System.Runtime.InteropServices.StructLayout(global::System.Runtime.InteropServices.LayoutKind.Auto)] [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial struct TestValueObject : global::System.IEquatable, + readonly partial struct TestValueObject : global::System.IEquatable, global::Thinktecture.IKeyedValueObject, global::Thinktecture.IValueObjectConvertable, global::Thinktecture.IValueObjectFactory @@ -3039,7 +3039,7 @@ public void Should_generate_string_based_keyed_struct_with_NullInFactoryMethodsY namespace Thinktecture.Tests { [ValueObject(NullInFactoryMethodsYieldsNull = true)] - public readonly partial struct TestValueObject + public partial struct TestValueObject { } } @@ -3072,7 +3072,7 @@ public void Should_generate_string_based_keyed_struct_with_EmptyStringInFactoryM namespace Thinktecture.Tests { [ValueObject(EmptyStringInFactoryMethodsYieldsNull = true)] - public readonly partial struct TestValueObject + public partial struct TestValueObject { } } @@ -3202,7 +3202,7 @@ public partial class TestValueObject namespace Thinktecture.Tests { [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial class TestValueObject : global::System.IEquatable, + sealed partial class TestValueObject : global::System.IEquatable, global::Thinktecture.IKeyedValueObject, global::Thinktecture.IValueObjectConvertable, global::Thinktecture.IValueObjectFactory @@ -3573,7 +3573,7 @@ public partial class TestValueObject namespace Thinktecture.Tests { [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial class TestValueObject : global::System.IEquatable, + sealed partial class TestValueObject : global::System.IEquatable, global::Thinktecture.IKeyedValueObject, global::Thinktecture.IValueObjectConvertable, global::Thinktecture.IValueObjectFactory @@ -4361,7 +4361,7 @@ public partial class TestValueObject namespace Thinktecture.Tests { [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial class TestValueObject : global::System.IEquatable, + sealed partial class TestValueObject : global::System.IEquatable, global::Thinktecture.IKeyedValueObject, global::Thinktecture.IValueObjectConvertable, global::Thinktecture.IValueObjectFactory @@ -4557,7 +4557,7 @@ public partial class TestValueObject namespace Thinktecture.Tests { [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial class TestValueObject : global::System.IEquatable, + sealed partial class TestValueObject : global::System.IEquatable, global::Thinktecture.IKeyedValueObject, global::Thinktecture.IValueObjectConvertable, global::Thinktecture.IValueObjectFactory @@ -4787,7 +4787,7 @@ public partial class TestValueObject namespace Thinktecture.Tests { [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial class TestValueObject : global::System.IEquatable, + sealed partial class TestValueObject : global::System.IEquatable, global::Thinktecture.IKeyedValueObject, global::Thinktecture.IValueObjectConvertable, global::Thinktecture.IValueObjectFactory @@ -4981,7 +4981,7 @@ public class Foo namespace Thinktecture.Tests { [global::System.ComponentModel.TypeConverter(typeof(global::Thinktecture.ValueObjectTypeConverter))] - partial class TestValueObject : global::System.IEquatable, + sealed partial class TestValueObject : global::System.IEquatable, global::Thinktecture.IKeyedValueObject, global::Thinktecture.IValueObjectConvertable, global::Thinktecture.IValueObjectFactory @@ -5190,7 +5190,7 @@ public int SetterProperty namespace Thinktecture.Tests { - partial class TestValueObject : global::System.IEquatable, + sealed partial class TestValueObject : global::System.IEquatable, global::System.Numerics.IEqualityOperators, global::Thinktecture.IComplexValueObject { @@ -5422,7 +5422,7 @@ public int SetterProperty namespace Thinktecture.Tests { - partial class TestValueObject : global::System.IEquatable, + sealed partial class TestValueObject : global::System.IEquatable, global::System.Numerics.IEqualityOperators, global::Thinktecture.IComplexValueObject, global::Thinktecture.IValueObjectFactory @@ -5698,7 +5698,7 @@ public int SetterProperty namespace Thinktecture.Tests { - partial class TestValueObject : global::System.IEquatable, + sealed partial class TestValueObject : global::System.IEquatable, global::System.Numerics.IEqualityOperators, global::Thinktecture.IComplexValueObject, global::Thinktecture.IValueObjectFactory, @@ -5952,7 +5952,7 @@ public partial class TestValueObject namespace Thinktecture.Tests { - partial class TestValueObject : global::System.IEquatable, + sealed partial class TestValueObject : global::System.IEquatable, global::System.Numerics.IEqualityOperators, global::Thinktecture.IComplexValueObject { diff --git a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/Verifiers/CodeFixVerifier.cs b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/Verifiers/CodeFixVerifier.cs index 9fa7f497..bce95fdf 100644 --- a/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/Verifiers/CodeFixVerifier.cs +++ b/test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/Verifiers/CodeFixVerifier.cs @@ -86,7 +86,7 @@ public CodeFixTest( protected override ParseOptions CreateParseOptions() { var options = (CSharpParseOptions)base.CreateParseOptions(); - options = options.WithLanguageVersion(LanguageVersion.Preview); + options = options.WithLanguageVersion(LanguageVersion.CSharp12); return options; } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/EmptyEnum.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/EmptyEnum.cs index 875d1d1e..d15cfe28 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/EmptyEnum.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/EmptyEnum.cs @@ -4,6 +4,6 @@ namespace Thinktecture.Runtime.Tests.TestEnums; [SuppressMessage("ReSharper", "TTRESG100")] [SmartEnum(IsValidatable = true)] -public sealed partial class EmptyEnum +public partial class EmptyEnum { } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/EnumWithDuplicateKey.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/EnumWithDuplicateKey.cs index a8642ba4..b0f89d2c 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/EnumWithDuplicateKey.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/EnumWithDuplicateKey.cs @@ -1,7 +1,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; [SmartEnum(IsValidatable = true)] -public sealed partial class EnumWithDuplicateKey +public partial class EnumWithDuplicateKey { public static readonly EnumWithDuplicateKey Item = new("Item"); public static readonly EnumWithDuplicateKey Duplicate = new("item"); diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/EnumWithFactory.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/EnumWithFactory.cs index fede0c43..21ae4dd7 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/EnumWithFactory.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/EnumWithFactory.cs @@ -4,7 +4,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; [SmartEnum] [ValueObjectFactory(UseForSerialization = SerializationFrameworks.All)] -public sealed partial class EnumWithFactory +public partial class EnumWithFactory { public static readonly EnumWithFactory Item1 = new(1); public static readonly EnumWithFactory Item2 = new(2); diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/IntegerEnum.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/IntegerEnum.cs index 40964bcc..d26c5de5 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/IntegerEnum.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/IntegerEnum.cs @@ -2,7 +2,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; [SmartEnum(IsValidatable = true, ComparisonOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads)] -public sealed partial class IntegerEnum +public partial class IntegerEnum { public static readonly IntegerEnum Item1 = new(1); public static readonly IntegerEnum Item2 = new(2); diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/KeylessTestEnum.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/KeylessTestEnum.cs index d375c4ee..3a885647 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/KeylessTestEnum.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/KeylessTestEnum.cs @@ -2,7 +2,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; [SmartEnum(SwitchMethods = SwitchMapMethodsGeneration.DefaultWithPartialOverloads, MapMethods = SwitchMapMethodsGeneration.DefaultWithPartialOverloads)] -public sealed partial class KeylessTestEnum +public partial class KeylessTestEnum { public static readonly KeylessTestEnum Item1 = new(1); public static readonly KeylessTestEnum Item2 = new(2); diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/KeylessTestEnumWithFactory.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/KeylessTestEnumWithFactory.cs index 2b95bb5c..727f5a5c 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/KeylessTestEnumWithFactory.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/KeylessTestEnumWithFactory.cs @@ -4,7 +4,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; [SmartEnum] [ValueObjectFactory] -public sealed partial class KeylessTestEnumWithFactory +public partial class KeylessTestEnumWithFactory { public static readonly KeylessTestEnumWithFactory Item1 = new(1); public static readonly KeylessTestEnumWithFactory Item2 = new(2); diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/StructIntegerEnum.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/StructIntegerEnum.cs index b2d6acbe..01e138f1 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/StructIntegerEnum.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/StructIntegerEnum.cs @@ -1,7 +1,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; [SmartEnum(IsValidatable = true)] -public readonly partial struct StructIntegerEnum +public partial struct StructIntegerEnum { public static readonly StructIntegerEnum Item1 = new(1, 42, 100); public static readonly StructIntegerEnum Item2 = new(2, 43, 200); diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/StructIntegerEnumWithZero.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/StructIntegerEnumWithZero.cs index ddab7f02..d9a28847 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/StructIntegerEnumWithZero.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/StructIntegerEnumWithZero.cs @@ -1,7 +1,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; [SmartEnum(IsValidatable = true)] -public readonly partial struct StructIntegerEnumWithZero +public partial struct StructIntegerEnumWithZero { public static readonly StructIntegerEnumWithZero Item0 = new(0); public static readonly StructIntegerEnumWithZero Item1 = new(1); diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/StructStringEnum.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/StructStringEnum.cs index bfc24cf2..96e92240 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/StructStringEnum.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/StructStringEnum.cs @@ -3,7 +3,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; [SmartEnum(IsValidatable = true)] -public readonly partial struct StructStringEnum +public partial struct StructStringEnum { public static readonly StructStringEnum Item1 = new(String.Empty); public static readonly StructStringEnum Item2 = new("item2"); diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnum.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnum.cs index dd1a1bbf..ffc755b0 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnum.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnum.cs @@ -5,7 +5,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; [SmartEnum(IsValidatable = true, SwitchMethods = SwitchMapMethodsGeneration.DefaultWithPartialOverloads, MapMethods = SwitchMapMethodsGeneration.DefaultWithPartialOverloads)] -public sealed partial class TestEnum +public partial class TestEnum { public static readonly TestEnum Item1 = new("item1"); public static readonly TestEnum Item2 = new("item2"); diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnumCaseSensitive.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnumCaseSensitive.cs index 2582bd03..4ddaa505 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnumCaseSensitive.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnumCaseSensitive.cs @@ -3,7 +3,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; [SmartEnum] [ValueObjectKeyMemberComparer] [ValueObjectKeyMemberEqualityComparer] -public sealed partial class TestEnumCaseSensitive +public partial class TestEnumCaseSensitive { public static readonly TestEnumCaseSensitive LowerCased = new("item"); public static readonly TestEnumCaseSensitive UpperCased = new("ITEM"); diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnumWithCustomError.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnumWithCustomError.cs index 7456a28d..bf0ef406 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnumWithCustomError.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnumWithCustomError.cs @@ -2,7 +2,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; [SmartEnum] [ValueObjectValidationError] -public sealed partial class TestEnumWithCustomError +public partial class TestEnumWithCustomError { public static readonly TestEnumWithCustomError Item1 = new("item1"); public static readonly TestEnumWithCustomError Item2 = new("item2"); diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnumWithInvalidCreateInvalidItem.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnumWithInvalidCreateInvalidItem.cs index 624f0208..7177eb29 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnumWithInvalidCreateInvalidItem.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnumWithInvalidCreateInvalidItem.cs @@ -1,7 +1,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; [SmartEnum(IsValidatable = true)] -public sealed partial class TestEnumWithInvalidCreateInvalidItem +public partial class TestEnumWithInvalidCreateInvalidItem { public const int INVALID_KEY_FOR_TESTING_KEY_REUSE = 0; public const int INVALID_KEY_FOR_TESTING_IS_VALID_TRUE = -1; diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnumWithRenamedKeyMember.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnumWithRenamedKeyMember.cs index 08eea896..b810120a 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnumWithRenamedKeyMember.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnumWithRenamedKeyMember.cs @@ -1,7 +1,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; [SmartEnum(KeyMemberName = "_name")] -public sealed partial class TestEnumWithRenamedKeyMember +public partial class TestEnumWithRenamedKeyMember { public static readonly TestEnumWithRenamedKeyMember Item1 = new("Item1"); } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnumWithReservedIdentifier.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnumWithReservedIdentifier.cs index a98f8773..9d76100d 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnumWithReservedIdentifier.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestEnumWithReservedIdentifier.cs @@ -1,7 +1,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; [SmartEnum] -public sealed partial class TestEnumWithReservedIdentifier +public partial class TestEnumWithReservedIdentifier { public static readonly TestEnumWithReservedIdentifier Operator = new(1); public static readonly TestEnumWithReservedIdentifier True = new(2); diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestSmartEnum_Class_DecimalBased.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestSmartEnum_Class_DecimalBased.cs index c544c760..7d5b6ada 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestSmartEnum_Class_DecimalBased.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestSmartEnum_Class_DecimalBased.cs @@ -2,7 +2,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; // ReSharper disable once InconsistentNaming [SmartEnum] -public sealed partial class TestSmartEnum_Class_DecimalBased +public partial class TestSmartEnum_Class_DecimalBased { public static readonly TestSmartEnum_Class_DecimalBased Value1 = new(1); public static readonly TestSmartEnum_Class_DecimalBased Value2 = new(2); diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestSmartEnum_Class_IntBased.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestSmartEnum_Class_IntBased.cs index 66154c2a..75b04fa2 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestSmartEnum_Class_IntBased.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestSmartEnum_Class_IntBased.cs @@ -2,7 +2,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; // ReSharper disable once InconsistentNaming [SmartEnum] -public sealed partial class TestSmartEnum_Class_IntBased +public partial class TestSmartEnum_Class_IntBased { public static readonly TestSmartEnum_Class_IntBased Value1 = new(1); public static readonly TestSmartEnum_Class_IntBased Value2 = new(2); diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestSmartEnum_Class_StringBased.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestSmartEnum_Class_StringBased.cs index 81b75799..542b4314 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestSmartEnum_Class_StringBased.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestSmartEnum_Class_StringBased.cs @@ -2,7 +2,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; // ReSharper disable once InconsistentNaming [SmartEnum] -public sealed partial class TestSmartEnum_Class_StringBased +public partial class TestSmartEnum_Class_StringBased { public static readonly TestSmartEnum_Class_StringBased Value1 = new("Value1"); public static readonly TestSmartEnum_Class_StringBased Value2 = new("Value2"); diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestSmartEnum_Struct_IntBased.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestSmartEnum_Struct_IntBased.cs index aa5e3f02..c98102b4 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestSmartEnum_Struct_IntBased.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestSmartEnum_Struct_IntBased.cs @@ -4,7 +4,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; [SmartEnum(IsValidatable = true, SwitchMethods = SwitchMapMethodsGeneration.DefaultWithPartialOverloads, MapMethods = SwitchMapMethodsGeneration.DefaultWithPartialOverloads)] -public readonly partial struct TestSmartEnum_Struct_IntBased +public partial struct TestSmartEnum_Struct_IntBased { public static readonly TestSmartEnum_Struct_IntBased Value1 = new(1); public static readonly TestSmartEnum_Struct_IntBased Value2 = new(2); diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestSmartEnum_Struct_StringBased.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestSmartEnum_Struct_StringBased.cs index a42fc451..78ee0621 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestSmartEnum_Struct_StringBased.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/TestSmartEnum_Struct_StringBased.cs @@ -2,7 +2,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; // ReSharper disable once InconsistentNaming [SmartEnum(IsValidatable = true)] -public readonly partial struct TestSmartEnum_Struct_StringBased +public partial struct TestSmartEnum_Struct_StringBased { public static readonly TestSmartEnum_Struct_StringBased Value1 = new("Value1"); public static readonly TestSmartEnum_Struct_StringBased Value2 = new("Value2"); diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/ValidIntegerEnum.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/ValidIntegerEnum.cs index 450baac9..20664e54 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/ValidIntegerEnum.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/ValidIntegerEnum.cs @@ -1,7 +1,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; [SmartEnum] -public sealed partial class ValidIntegerEnum +public partial class ValidIntegerEnum { public static readonly ValidIntegerEnum Item1 = new(1); public static readonly ValidIntegerEnum Item2 = new(2); diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/ValidTestEnum.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/ValidTestEnum.cs index 70e316a5..71be8f28 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/ValidTestEnum.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/ValidTestEnum.cs @@ -2,7 +2,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; [SmartEnum(SwitchMethods = SwitchMapMethodsGeneration.DefaultWithPartialOverloads, MapMethods = SwitchMapMethodsGeneration.DefaultWithPartialOverloads)] -public sealed partial class ValidTestEnum +public partial class ValidTestEnum { public static readonly ValidTestEnum Item1 = new("item1"); public static readonly ValidTestEnum Item2 = new("item2"); diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/ValidatableTestEnumCaseSensitive.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/ValidatableTestEnumCaseSensitive.cs index 220f4017..0606572f 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/ValidatableTestEnumCaseSensitive.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/ValidatableTestEnumCaseSensitive.cs @@ -3,7 +3,7 @@ [SmartEnum(IsValidatable = true)] [ValueObjectKeyMemberComparer] [ValueObjectKeyMemberEqualityComparer] -public sealed partial class ValidatableTestEnumCaseSensitive +public partial class ValidatableTestEnumCaseSensitive { public static readonly ValidatableTestEnumCaseSensitive LowerCased = new("item"); public static readonly ValidatableTestEnumCaseSensitive UpperCased = new("ITEM"); diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/ValidatableTestEnumWithRenamedKeyMember.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/ValidatableTestEnumWithRenamedKeyMember.cs index e9a05742..794f8899 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/ValidatableTestEnumWithRenamedKeyMember.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestEnums/ValidatableTestEnumWithRenamedKeyMember.cs @@ -2,7 +2,7 @@ namespace Thinktecture.Runtime.Tests.TestEnums; [SmartEnum(KeyMemberName = "_name", IsValidatable = true)] -public sealed partial class ValidatableTestEnumWithRenamedKeyMember +public partial class ValidatableTestEnumWithRenamedKeyMember { public static readonly ValidatableTestEnumWithRenamedKeyMember Item1 = new("Item1"); } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/Boundary.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/Boundary.cs index 326e58de..ce0137e0 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/Boundary.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/Boundary.cs @@ -1,7 +1,7 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; [ComplexValueObject] -public sealed partial class Boundary +public partial class Boundary { public decimal Lower { get; } public decimal Upper { get; } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/BoundaryWithCustomError.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/BoundaryWithCustomError.cs index 2b050b0a..5c344c0f 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/BoundaryWithCustomError.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/BoundaryWithCustomError.cs @@ -2,7 +2,7 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; [ComplexValueObject] [ValueObjectValidationError] -public sealed partial class BoundaryWithCustomError +public partial class BoundaryWithCustomError { public decimal Lower { get; } public decimal Upper { get; } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/BoundaryWithCustomFactoryNames.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/BoundaryWithCustomFactoryNames.cs index 3dc409c9..4ae7c393 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/BoundaryWithCustomFactoryNames.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/BoundaryWithCustomFactoryNames.cs @@ -2,7 +2,7 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; [ComplexValueObject(CreateFactoryMethodName = "Get", TryCreateFactoryMethodName = "TryGet")] -public sealed partial class BoundaryWithCustomFactoryNames +public partial class BoundaryWithCustomFactoryNames { public decimal Lower { get; } public decimal Upper { get; } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/BoundaryWithFactories.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/BoundaryWithFactories.cs index 478d7532..cfe27b9d 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/BoundaryWithFactories.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/BoundaryWithFactories.cs @@ -5,7 +5,7 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; [ComplexValueObject] [ValueObjectFactory(UseForSerialization = SerializationFrameworks.All)] [ValueObjectFactory>] -public sealed partial class BoundaryWithFactories +public partial class BoundaryWithFactories { public decimal Lower { get; } public decimal Upper { get; } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/BoundaryWithFactoryAndExplicitImplementation.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/BoundaryWithFactoryAndExplicitImplementation.cs index 4942e5e0..0fc0fff4 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/BoundaryWithFactoryAndExplicitImplementation.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/BoundaryWithFactoryAndExplicitImplementation.cs @@ -4,7 +4,7 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; [ComplexValueObject] [ValueObjectFactory(UseForSerialization = SerializationFrameworks.All)] -public sealed partial class BoundaryWithFactoryAndExplicitImplementation +public partial class BoundaryWithFactoryAndExplicitImplementation { public decimal Lower { get; } public decimal Upper { get; } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/BoundaryWithStrings.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/BoundaryWithStrings.cs index 11db0574..8f4b8997 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/BoundaryWithStrings.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/BoundaryWithStrings.cs @@ -1,7 +1,7 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; [ComplexValueObject] -public sealed partial class BoundaryWithStrings +public partial class BoundaryWithStrings { public string Lower { get; } public string? Upper { get; } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/ComplexValueObjectWithPublicCtor.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/ComplexValueObjectWithPublicCtor.cs index a867c895..651530dc 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/ComplexValueObjectWithPublicCtor.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/ComplexValueObjectWithPublicCtor.cs @@ -1,7 +1,7 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; [ComplexValueObject(ConstructorAccessModifier = ValueObjectAccessModifier.Public)] -public sealed partial class ComplexValueObjectWithPublicCtor +public partial class ComplexValueObjectWithPublicCtor { public decimal Lower { get; } public decimal Upper { get; } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/ComplexValueObjectWithReservedIdentifiers.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/ComplexValueObjectWithReservedIdentifiers.cs index 558d2833..7e904669 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/ComplexValueObjectWithReservedIdentifiers.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/ComplexValueObjectWithReservedIdentifiers.cs @@ -1,7 +1,7 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; [ComplexValueObject] -public sealed partial class ComplexValueObjectWithReservedIdentifiers +public partial class ComplexValueObjectWithReservedIdentifiers { public int Operator { get; } public int? True { get; } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/DecimalBasedStructValueObject.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/DecimalBasedStructValueObject.cs index 17b76cf0..e89fe3df 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/DecimalBasedStructValueObject.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/DecimalBasedStructValueObject.cs @@ -8,6 +8,6 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; SubtractionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, MultiplyOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, DivisionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads)] -public sealed partial class DecimalBasedClassValueObject +public partial class DecimalBasedClassValueObject { } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/IntBasedReferenceValueObject.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/IntBasedReferenceValueObject.cs index 9ad2ede9..a0056603 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/IntBasedReferenceValueObject.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/IntBasedReferenceValueObject.cs @@ -3,6 +3,6 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; [ValueObject(KeyMemberKind = ValueObjectMemberKind.Property, KeyMemberName = "Property", KeyMemberAccessModifier = ValueObjectAccessModifier.Public)] -public sealed partial class IntBasedReferenceValueObject +public partial class IntBasedReferenceValueObject { } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/IntBasedReferenceValueObjectWithCustomFactoryNames.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/IntBasedReferenceValueObjectWithCustomFactoryNames.cs index ba76b990..79257cd0 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/IntBasedReferenceValueObjectWithCustomFactoryNames.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/IntBasedReferenceValueObjectWithCustomFactoryNames.cs @@ -10,6 +10,6 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; DivisionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, MultiplyOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, SubtractionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads)] -public sealed partial class IntBasedReferenceValueObjectWithCustomFactoryNames +public partial class IntBasedReferenceValueObjectWithCustomFactoryNames { } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/IntBasedStructValueObject.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/IntBasedStructValueObject.cs index a274e4f1..6fd0c70d 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/IntBasedStructValueObject.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/IntBasedStructValueObject.cs @@ -3,6 +3,6 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; [ValueObject(KeyMemberKind = ValueObjectMemberKind.Property, KeyMemberName = "Property", KeyMemberAccessModifier = ValueObjectAccessModifier.Public)] -public readonly partial struct IntBasedStructValueObject +public partial struct IntBasedStructValueObject { } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/KeyedValueObjectWithPublicCtor.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/KeyedValueObjectWithPublicCtor.cs index e92a6f30..47275465 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/KeyedValueObjectWithPublicCtor.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/KeyedValueObjectWithPublicCtor.cs @@ -1,6 +1,6 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; [ValueObject(ConstructorAccessModifier = ValueObjectAccessModifier.Public)] -public sealed partial class KeyedValueObjectWithPublicCtor +public partial class KeyedValueObjectWithPublicCtor { } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/SimpleValueObjectWithReservedIdentifiers.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/SimpleValueObjectWithReservedIdentifiers.cs index 48e338d8..694be5d4 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/SimpleValueObjectWithReservedIdentifiers.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/SimpleValueObjectWithReservedIdentifiers.cs @@ -3,6 +3,6 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; [ValueObject(KeyMemberKind = ValueObjectMemberKind.Property, KeyMemberName = "Property", KeyMemberAccessModifier = ValueObjectAccessModifier.Public)] -public sealed partial class SimpleValueObjectWithReservedIdentifiers +public partial class SimpleValueObjectWithReservedIdentifiers { } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StringBasedReferenceValueObject.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StringBasedReferenceValueObject.cs index f5f94c25..de2cefdf 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StringBasedReferenceValueObject.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StringBasedReferenceValueObject.cs @@ -5,7 +5,7 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; [ValueObject(KeyMemberKind = ValueObjectMemberKind.Property, KeyMemberName = "Property", KeyMemberAccessModifier = ValueObjectAccessModifier.Public)] -public sealed partial class StringBasedReferenceValueObject +public partial class StringBasedReferenceValueObject { static partial void ValidateFactoryArguments(ref ValidationError? validationError, ref string property) { diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StringBasedReferenceValueObjectWithCustomError.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StringBasedReferenceValueObjectWithCustomError.cs index b1329fbd..d54d1467 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StringBasedReferenceValueObjectWithCustomError.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StringBasedReferenceValueObjectWithCustomError.cs @@ -6,7 +6,7 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; KeyMemberName = "Property", KeyMemberAccessModifier = ValueObjectAccessModifier.Public)] [ValueObjectValidationError] -public sealed partial class StringBasedReferenceValueObjectWithCustomError +public partial class StringBasedReferenceValueObjectWithCustomError { static partial void ValidateFactoryArguments(ref StringBasedReferenceValueObjectValidationError? validationError, ref string property) { diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StringBasedReferenceValueObjectWithEmptyStringInFactoryMethodsYieldsNull.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StringBasedReferenceValueObjectWithEmptyStringInFactoryMethodsYieldsNull.cs index 27ccc2ae..5c021b42 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StringBasedReferenceValueObjectWithEmptyStringInFactoryMethodsYieldsNull.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StringBasedReferenceValueObjectWithEmptyStringInFactoryMethodsYieldsNull.cs @@ -6,7 +6,7 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; KeyMemberName = "Property", KeyMemberAccessModifier = ValueObjectAccessModifier.Public, EmptyStringInFactoryMethodsYieldsNull = true)] -public sealed partial class StringBasedReferenceValueObjectWithEmptyStringInFactoryMethodsYieldsNull +public partial class StringBasedReferenceValueObjectWithEmptyStringInFactoryMethodsYieldsNull { static partial void ValidateFactoryArguments(ref ValidationError? validationError, ref string property) { diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StringBasedReferenceValueObjectWithNullInFactoryMethodsYieldsNull.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StringBasedReferenceValueObjectWithNullInFactoryMethodsYieldsNull.cs index 81a07b20..6ef093aa 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StringBasedReferenceValueObjectWithNullInFactoryMethodsYieldsNull.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StringBasedReferenceValueObjectWithNullInFactoryMethodsYieldsNull.cs @@ -6,7 +6,7 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; KeyMemberName = "Property", KeyMemberAccessModifier = ValueObjectAccessModifier.Public, NullInFactoryMethodsYieldsNull = true)] -public sealed partial class StringBasedReferenceValueObjectWithNullInFactoryMethodsYieldsNull +public partial class StringBasedReferenceValueObjectWithNullInFactoryMethodsYieldsNull { static partial void ValidateFactoryArguments(ref ValidationError? validationError, ref string property) { diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StringBasedStructValueObject.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StringBasedStructValueObject.cs index 5cfa9a6f..bef91be4 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StringBasedStructValueObject.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StringBasedStructValueObject.cs @@ -3,6 +3,6 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; [ValueObject(KeyMemberKind = ValueObjectMemberKind.Property, KeyMemberName = "Property", KeyMemberAccessModifier = ValueObjectAccessModifier.Public)] -public readonly partial struct StringBasedStructValueObject +public partial struct StringBasedStructValueObject { } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StructValueObjectWithoutMembers.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StructValueObjectWithoutMembers.cs index 92a59055..facff0f9 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StructValueObjectWithoutMembers.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/StructValueObjectWithoutMembers.cs @@ -1,6 +1,6 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; [ComplexValueObject] -public readonly partial struct StructValueObjectWithoutMembers +public partial struct StructValueObjectWithoutMembers { } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/TestValueObjectByte.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/TestValueObjectByte.cs index 98a2cd6b..1ae21c64 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/TestValueObjectByte.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/TestValueObjectByte.cs @@ -4,7 +4,7 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; SubtractionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, MultiplyOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, DivisionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads)] -public sealed partial class TestValueObjectByte +public partial class TestValueObjectByte { } @@ -12,7 +12,7 @@ public sealed partial class TestValueObjectByte SubtractionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, MultiplyOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, DivisionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads)] -public sealed partial class TestValueObjectSByte +public partial class TestValueObjectSByte { } @@ -20,7 +20,7 @@ public sealed partial class TestValueObjectSByte SubtractionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, MultiplyOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, DivisionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads)] -public sealed partial class TestValueObjectShort +public partial class TestValueObjectShort { } @@ -28,7 +28,7 @@ public sealed partial class TestValueObjectShort SubtractionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, MultiplyOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, DivisionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads)] -public sealed partial class TestValueObjectUShort +public partial class TestValueObjectUShort { } @@ -36,7 +36,7 @@ public sealed partial class TestValueObjectUShort SubtractionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, MultiplyOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, DivisionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads)] -public sealed partial class TestValueObjectInt +public partial class TestValueObjectInt { } @@ -44,7 +44,7 @@ public sealed partial class TestValueObjectInt SubtractionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, MultiplyOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, DivisionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads)] -public sealed partial class TestValueObjectUInt +public partial class TestValueObjectUInt { } @@ -52,7 +52,7 @@ public sealed partial class TestValueObjectUInt SubtractionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, MultiplyOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, DivisionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads)] -public sealed partial class TestValueObjectLong +public partial class TestValueObjectLong { } @@ -60,7 +60,7 @@ public sealed partial class TestValueObjectLong SubtractionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, MultiplyOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, DivisionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads)] -public sealed partial class TestValueObjectULong +public partial class TestValueObjectULong { } @@ -68,7 +68,7 @@ public sealed partial class TestValueObjectULong SubtractionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, MultiplyOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, DivisionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads)] -public sealed partial class TestValueObjectFloat +public partial class TestValueObjectFloat { } @@ -76,7 +76,7 @@ public sealed partial class TestValueObjectFloat SubtractionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, MultiplyOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, DivisionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads)] -public sealed partial class TestValueObjectDouble +public partial class TestValueObjectDouble { } @@ -84,6 +84,6 @@ public sealed partial class TestValueObjectDouble SubtractionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, MultiplyOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads, DivisionOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads)] -public sealed partial class TestValueObjectDecimal +public partial class TestValueObjectDecimal { } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/TestValueObject_Complex_Class.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/TestValueObject_Complex_Class.cs index 14babfe5..1f0b0176 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/TestValueObject_Complex_Class.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/TestValueObject_Complex_Class.cs @@ -2,7 +2,7 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; // ReSharper disable once InconsistentNaming [ComplexValueObject] -public sealed partial class TestValueObject_Complex_Class +public partial class TestValueObject_Complex_Class { public string Property1 { get; } public string Property2 { get; } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/TestValueObject_Complex_Struct.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/TestValueObject_Complex_Struct.cs index 2ac8d2e0..facbf0d3 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/TestValueObject_Complex_Struct.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/TestValueObject_Complex_Struct.cs @@ -2,7 +2,7 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; // ReSharper disable once InconsistentNaming [ComplexValueObject] -public readonly partial struct TestValueObject_Complex_Struct +public partial struct TestValueObject_Complex_Struct { public string Property1 { get; } public string Property2 { get; } diff --git a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/ValueObjectWithInitProperties.cs b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/ValueObjectWithInitProperties.cs index d93c3e3d..36147523 100644 --- a/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/ValueObjectWithInitProperties.cs +++ b/test/Thinktecture.Runtime.Extensions.Tests.Shared/TestValueObjects/ValueObjectWithInitProperties.cs @@ -1,7 +1,7 @@ namespace Thinktecture.Runtime.Tests.TestValueObjects; [ComplexValueObject] -public sealed partial class ValueObjectWithInitProperties +public partial class ValueObjectWithInitProperties { [ValueObjectMemberIgnore] private readonly int _initExpression;