-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1325a8c
commit 24aab6d
Showing
19 changed files
with
236 additions
and
33 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
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
13 changes: 13 additions & 0 deletions
13
...eratorGuide/Generated/net7.0/MySourceGenerator/AugmentingGenerator/UserClass.Generated.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,13 @@ | ||
| ||
namespace MySourceGenerator | ||
{ | ||
|
||
public partial class UserClass | ||
{ | ||
private void GeneratedMethod() | ||
{ | ||
// generated code | ||
Console.WriteLine("Hello from generated code!"); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...ourceGeneratorGuide/Generated/net7.0/MySourceGenerator/CustomGenerator/myGeneratedFile.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,10 @@ | ||
namespace MySourceGenerator | ||
{ | ||
public class GeneratedClass | ||
{ | ||
public static void GeneratedMethod() | ||
{ | ||
Console.WriteLine("GeneratedMethod..."); | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
....0/MySourceGenerator/MySourceGenerator.Enums.EnumToGenerator/EnumExtensionsAttribute.g.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,9 @@ | ||
| ||
namespace MySourceGenerator.Enums | ||
{ | ||
[System.AttributeUsage(System.AttributeTargets.Enum)] | ||
public class EnumExtensionsAttribute : System.Attribute | ||
{ | ||
|
||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...ed/net7.0/MySourceGenerator/MySourceGenerator.Enums2.EnumToGenerator/EnumExtensions2.g.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,41 @@ | ||
| ||
namespace MySourceGenerator.Enums2 | ||
{ | ||
public static partial class DirectionExtensions | ||
{ | ||
public static string ToStringFast(this MySourceGenerator.Program.Direction value) | ||
=> value switch | ||
{ | ||
MySourceGenerator.Program.Direction.Left => nameof(MySourceGenerator.Program.Direction.Left), | ||
MySourceGenerator.Program.Direction.Right => nameof(MySourceGenerator.Program.Direction.Right), | ||
MySourceGenerator.Program.Direction.Up => nameof(MySourceGenerator.Program.Direction.Up), | ||
MySourceGenerator.Program.Direction.Down => nameof(MySourceGenerator.Program.Direction.Down), | ||
_ => value.ToString(), | ||
}; | ||
} | ||
|
||
public static partial class EnumExtensions | ||
{ | ||
public static string ToStringFast(this MySourceGenerator.Program.Color value) | ||
=> value switch | ||
{ | ||
MySourceGenerator.Program.Color.Red => nameof(MySourceGenerator.Program.Color.Red), | ||
MySourceGenerator.Program.Color.Green => nameof(MySourceGenerator.Program.Color.Green), | ||
MySourceGenerator.Program.Color.Yellow => nameof(MySourceGenerator.Program.Color.Yellow), | ||
MySourceGenerator.Program.Color.Pink => nameof(MySourceGenerator.Program.Color.Pink), | ||
MySourceGenerator.Program.Color.Black => nameof(MySourceGenerator.Program.Color.Black), | ||
_ => value.ToString(), | ||
}; | ||
} | ||
|
||
public static partial class EnumExtensions | ||
{ | ||
public static string ToStringFast(this MySourceGenerator.NestedEnum.RoleEnum value) | ||
=> value switch | ||
{ | ||
MySourceGenerator.NestedEnum.RoleEnum.None => nameof(MySourceGenerator.NestedEnum.RoleEnum.None), | ||
MySourceGenerator.NestedEnum.RoleEnum.Admin => nameof(MySourceGenerator.NestedEnum.RoleEnum.Admin), | ||
_ => value.ToString(), | ||
}; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...0/MySourceGenerator/MySourceGenerator.Enums2.EnumToGenerator/EnumExtensionsAttribute.g.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,9 @@ | ||
| ||
namespace MySourceGenerator.Enums2 | ||
{ | ||
[System.AttributeUsage(System.AttributeTargets.Enum)] | ||
public class EnumExtensionsAttribute : System.Attribute | ||
{ | ||
public string ExtensionClassName { get; set; } | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...de/Generated/net7.0/MySourceGenerator/MySourceGenerator.HelloSourceGenerator/Program.g.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,11 @@ | ||
// Auto-generated code | ||
using System; | ||
|
||
namespace MySourceGenerator | ||
{ | ||
public static partial class Program | ||
{ | ||
static partial void HelloFrom(string name) => | ||
Console.WriteLine($"Generator says: Hi from '{name}'"); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...eratorGuide/Generated/net8.0/MySourceGenerator/AugmentingGenerator/UserClass.Generated.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,13 @@ | ||
| ||
namespace MySourceGenerator | ||
{ | ||
|
||
public partial class UserClass | ||
{ | ||
private void GeneratedMethod() | ||
{ | ||
// generated code | ||
Console.WriteLine("Hello from generated code!"); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...ourceGeneratorGuide/Generated/net8.0/MySourceGenerator/CustomGenerator/myGeneratedFile.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,10 @@ | ||
namespace MySourceGenerator | ||
{ | ||
public class GeneratedClass | ||
{ | ||
public static void GeneratedMethod() | ||
{ | ||
Console.WriteLine("GeneratedMethod..."); | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
....0/MySourceGenerator/MySourceGenerator.Enums.EnumToGenerator/EnumExtensionsAttribute.g.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,9 @@ | ||
| ||
namespace MySourceGenerator.Enums | ||
{ | ||
[System.AttributeUsage(System.AttributeTargets.Enum)] | ||
public class EnumExtensionsAttribute : System.Attribute | ||
{ | ||
|
||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...ed/net8.0/MySourceGenerator/MySourceGenerator.Enums2.EnumToGenerator/EnumExtensions2.g.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,41 @@ | ||
| ||
namespace MySourceGenerator.Enums2 | ||
{ | ||
public static partial class DirectionExtensions | ||
{ | ||
public static string ToStringFast(this MySourceGenerator.Program.Direction value) | ||
=> value switch | ||
{ | ||
MySourceGenerator.Program.Direction.Left => nameof(MySourceGenerator.Program.Direction.Left), | ||
MySourceGenerator.Program.Direction.Right => nameof(MySourceGenerator.Program.Direction.Right), | ||
MySourceGenerator.Program.Direction.Up => nameof(MySourceGenerator.Program.Direction.Up), | ||
MySourceGenerator.Program.Direction.Down => nameof(MySourceGenerator.Program.Direction.Down), | ||
_ => value.ToString(), | ||
}; | ||
} | ||
|
||
public static partial class EnumExtensions | ||
{ | ||
public static string ToStringFast(this MySourceGenerator.Program.Color value) | ||
=> value switch | ||
{ | ||
MySourceGenerator.Program.Color.Red => nameof(MySourceGenerator.Program.Color.Red), | ||
MySourceGenerator.Program.Color.Green => nameof(MySourceGenerator.Program.Color.Green), | ||
MySourceGenerator.Program.Color.Yellow => nameof(MySourceGenerator.Program.Color.Yellow), | ||
MySourceGenerator.Program.Color.Pink => nameof(MySourceGenerator.Program.Color.Pink), | ||
MySourceGenerator.Program.Color.Black => nameof(MySourceGenerator.Program.Color.Black), | ||
_ => value.ToString(), | ||
}; | ||
} | ||
|
||
public static partial class EnumExtensions | ||
{ | ||
public static string ToStringFast(this MySourceGenerator.NestedEnum.RoleEnum value) | ||
=> value switch | ||
{ | ||
MySourceGenerator.NestedEnum.RoleEnum.None => nameof(MySourceGenerator.NestedEnum.RoleEnum.None), | ||
MySourceGenerator.NestedEnum.RoleEnum.Admin => nameof(MySourceGenerator.NestedEnum.RoleEnum.Admin), | ||
_ => value.ToString(), | ||
}; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...0/MySourceGenerator/MySourceGenerator.Enums2.EnumToGenerator/EnumExtensionsAttribute.g.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,9 @@ | ||
| ||
namespace MySourceGenerator.Enums2 | ||
{ | ||
[System.AttributeUsage(System.AttributeTargets.Enum)] | ||
public class EnumExtensionsAttribute : System.Attribute | ||
{ | ||
public string ExtensionClassName { get; set; } | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...de/Generated/net8.0/MySourceGenerator/MySourceGenerator.HelloSourceGenerator/Program.g.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,11 @@ | ||
// Auto-generated code | ||
using System; | ||
|
||
namespace MySourceGenerator | ||
{ | ||
public static partial class Program | ||
{ | ||
static partial void HelloFrom(string name) => | ||
Console.WriteLine($"Generator says: Hi from '{name}'"); | ||
} | ||
} |
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
12 changes: 11 additions & 1 deletion
12
CSharpGuide/SourceGeneratorDemo/SourceGeneratorGuide/UserClass.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
Oops, something went wrong.