-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Access modifier of union ctors are configurable + implicit conversion…
…s can be omitted.
- Loading branch information
Showing
11 changed files
with
738 additions
and
2 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...ture.Runtime.Extensions.Samples/DiscriminatedUnions/TextOrNumberWithAdditionalProperty.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace Thinktecture.DiscriminatedUnions; | ||
|
||
[Union<string, int>(T1Name = "Text", | ||
T2Name = "Number", | ||
SkipImplicitConversionFromValue = true, | ||
ConstructorAccessModifier = UnionConstructorAccessModifier.Private)] | ||
public sealed partial class TextOrNumberExtended | ||
{ | ||
public required string AdditionalProperty { get; init; } | ||
|
||
public TextOrNumberExtended(string text, string additionalProperty) | ||
: this(text) | ||
{ | ||
AdditionalProperty = additionalProperty; | ||
} | ||
|
||
public TextOrNumberExtended(int number, string additionalProperty) | ||
: this(number) | ||
{ | ||
AdditionalProperty = additionalProperty; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...tecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/UnionConstructorAccessModifier.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Thinktecture.CodeAnalysis; | ||
|
||
public enum UnionConstructorAccessModifier | ||
{ | ||
Private = 1 << 0, | ||
Internal = 1 << 2, | ||
Public = 1 << 3 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Thinktecture.Runtime.Extensions/UnionConstructorAccessModifier.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace Thinktecture; | ||
|
||
/// <summary> | ||
/// Access modifer. | ||
/// </summary> | ||
public enum UnionConstructorAccessModifier | ||
{ | ||
/// <summary> | ||
/// Access modifer "private". | ||
/// </summary> | ||
Private = 1 << 0, | ||
|
||
/// <summary> | ||
/// Access modifer "internal". | ||
/// </summary> | ||
Internal = 1 << 2, | ||
|
||
/// <summary> | ||
/// Access modifer "public". | ||
/// </summary> | ||
Public = 1 << 3 | ||
} |
Oops, something went wrong.