From d8adff722d364b002a0ea7ea349c3e376b5348e6 Mon Sep 17 00:00:00 2001 From: Temo Nikolaishvili Date: Fri, 16 May 2025 11:03:26 +0400 Subject: [PATCH] Bump version to 1.3.0 and add ChoiceProperty attribute - Introduced `ChoicePropertyAttribute` for marking choice properties. - Enhanced code generation in `Executor.cs` to include the `[ChoiceProperty]` attribute. --- Directory.Build.props | 2 +- src/AltaSoft.Choice.Generator/Executor.cs | 2 ++ src/AltaSoft.Choice/ChoicePropertyAttribute.cs | 9 +++++++++ ...ndCompileCorrectly#Authorisation1Choice.g.verified.cs | 2 ++ ...ndCompileCorrectly#Authorisation1Choice.g.verified.cs | 2 ++ 5 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/AltaSoft.Choice/ChoicePropertyAttribute.cs diff --git a/Directory.Build.props b/Directory.Build.props index 52332b7..41e8f40 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -9,7 +9,7 @@ Choice generator ALTA Software llc. Copyright © 2024 ALTA Software llc. - 1.2.3 + 1.3.0 diff --git a/src/AltaSoft.Choice.Generator/Executor.cs b/src/AltaSoft.Choice.Generator/Executor.cs index d284c9a..4ec1948 100644 --- a/src/AltaSoft.Choice.Generator/Executor.cs +++ b/src/AltaSoft.Choice.Generator/Executor.cs @@ -115,6 +115,8 @@ private static SourceCodeBuilder Process(INamedTypeSymbol typeSymbol, List +/// Represents the attribute used to mark a property as a choice property. +/// +[AttributeUsage(AttributeTargets.Property)] +public sealed class ChoicePropertyAttribute : Attribute; diff --git a/tests/AltaSoft.Choice.Generator.SnapshotTests/Snapshots/ChoiceGeneratorTest.ChoiceTypeShouldGenerateAllMethodsAndCompileCorrectly#Authorisation1Choice.g.verified.cs b/tests/AltaSoft.Choice.Generator.SnapshotTests/Snapshots/ChoiceGeneratorTest.ChoiceTypeShouldGenerateAllMethodsAndCompileCorrectly#Authorisation1Choice.g.verified.cs index e4118cb..758cb24 100644 --- a/tests/AltaSoft.Choice.Generator.SnapshotTests/Snapshots/ChoiceGeneratorTest.ChoiceTypeShouldGenerateAllMethodsAndCompileCorrectly#Authorisation1Choice.g.verified.cs +++ b/tests/AltaSoft.Choice.Generator.SnapshotTests/Snapshots/ChoiceGeneratorTest.ChoiceTypeShouldGenerateAllMethodsAndCompileCorrectly#Authorisation1Choice.g.verified.cs @@ -49,6 +49,7 @@ public Authorisation1Choice() /// [DisallowNull] [XmlElement("Code")] + [ChoiceProperty] public partial TestNamespace.OtherNamespace.Authorisation1Code? Code { get => _code; @@ -67,6 +68,7 @@ public partial TestNamespace.OtherNamespace.Authorisation1Code? Code /// [DisallowNull] [XmlElement("Proprietary")] + [ChoiceProperty] public partial string? Proprietary { get => _proprietary; diff --git a/tests/AltaSoft.Choice.Generator.SnapshotTests/Snapshots/ChoiceGeneratorTest.ChoiceTypeShouldNotGenerateImplicitMethodsAndCompileCorrectly#Authorisation1Choice.g.verified.cs b/tests/AltaSoft.Choice.Generator.SnapshotTests/Snapshots/ChoiceGeneratorTest.ChoiceTypeShouldNotGenerateImplicitMethodsAndCompileCorrectly#Authorisation1Choice.g.verified.cs index 0d1bcac..a943f9a 100644 --- a/tests/AltaSoft.Choice.Generator.SnapshotTests/Snapshots/ChoiceGeneratorTest.ChoiceTypeShouldNotGenerateImplicitMethodsAndCompileCorrectly#Authorisation1Choice.g.verified.cs +++ b/tests/AltaSoft.Choice.Generator.SnapshotTests/Snapshots/ChoiceGeneratorTest.ChoiceTypeShouldNotGenerateImplicitMethodsAndCompileCorrectly#Authorisation1Choice.g.verified.cs @@ -49,6 +49,7 @@ public Authorisation1Choice() /// [DisallowNull] [XmlElement("Code")] + [ChoiceProperty] public partial string? Code { get => _code; @@ -67,6 +68,7 @@ public partial string? Code /// [DisallowNull] [XmlElement("Proprietary")] + [ChoiceProperty] public partial TestNamespace.OtherNamespace.Authorisation1Code? Proprietary { get => _proprietary;