-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow intercepting enums from other projects (#106)
* Add interceptable attribute * Add additional interceptors and unit test * Add integration tests
- Loading branch information
1 parent
c8d69fe
commit 31e3977
Showing
26 changed files
with
1,597 additions
and
184 deletions.
There are no files selected for viewing
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
29 changes: 29 additions & 0 deletions
29
src/NetEscapades.EnumGenerators.Attributes/InterceptableAttribute.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,29 @@ | ||
namespace NetEscapades.EnumGenerators | ||
{ | ||
/// <summary> | ||
/// Add to an assembly to indicate that usages of the enum should | ||
/// be automatically intercepted to use the extension methods | ||
/// generated by <see cref="EnumExtensionsAttribute"/> in this project. | ||
/// Note that the extension methods must be accessible from this project, | ||
/// otherwise you will receive compilation errors | ||
/// </summary> | ||
[System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple = true)] | ||
[System.Diagnostics.Conditional("NETESCAPADES_ENUMGENERATORS_USAGES")] | ||
public class InterceptableAttribute<T> : System.Attribute | ||
where T: System.Enum | ||
{ | ||
/// <summary> | ||
/// The namespace generated for the extension class. | ||
/// If not provided, the namespace of the enum will be assumed. | ||
/// </summary> | ||
public string? ExtensionClassNamespace { get; set; } | ||
|
||
/// <summary> | ||
/// The name used for the extension class. | ||
/// If not provided, the enum name with ""Extensions"" will be assumed. | ||
/// For example for an Enum called StatusCodes, the assumed name | ||
/// will be StatusCodesExtensions. | ||
/// </summary> | ||
public string? ExtensionClassName { get; set; } | ||
} | ||
} |
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
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
Oops, something went wrong.