-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename CSnake project to CSnake.SourceGeneration
Resolves #290
- Loading branch information
Showing
31 changed files
with
1,044 additions
and
1,032 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
66 changes: 33 additions & 33 deletions
66
src/CSnakes/CSnakes.csproj → ...eneration/CSnakes.SourceGeneration.csproj
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 |
---|---|---|
@@ -1,33 +1,33 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0</TargetFrameworks> | ||
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules> | ||
<NoWarn>$(NoWarn);RS1035</NoWarn> | ||
<IsPackable>true</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" /> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Superpower" GeneratePathProperty="true" PrivateAssets="all" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<GetTargetPathDependsOn>$(GetTargetPathDependsOn);GetDependencyTargetPaths</GetTargetPathDependsOn> | ||
</PropertyGroup> | ||
|
||
<Target Name="GetDependencyTargetPaths"> | ||
<ItemGroup> | ||
<TargetPathWithTargetPlatformMoniker Include="$(PKGSuperpower)\lib\netstandard2.0\Superpower.dll" IncludeRuntimeDependency="false" /> | ||
</ItemGroup> | ||
</Target> | ||
|
||
<Import Project="Packaging.targets" /> | ||
</Project> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0</TargetFrameworks> | ||
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules> | ||
<NoWarn>$(NoWarn);RS1035</NoWarn> | ||
<IsPackable>true</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" /> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Superpower" GeneratePathProperty="true" PrivateAssets="all" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<GetTargetPathDependsOn>$(GetTargetPathDependsOn);GetDependencyTargetPaths</GetTargetPathDependsOn> | ||
</PropertyGroup> | ||
|
||
<Target Name="GetDependencyTargetPaths"> | ||
<ItemGroup> | ||
<TargetPathWithTargetPlatformMoniker Include="$(PKGSuperpower)\lib\netstandard2.0\Superpower.dll" IncludeRuntimeDependency="false" /> | ||
</ItemGroup> | ||
</Target> | ||
|
||
<Import Project="Packaging.targets" /> | ||
</Project> |
86 changes: 43 additions & 43 deletions
86
...akes/CallerArgumentExpressionAttribute.cs → ...tion/CallerArgumentExpressionAttribute.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 |
---|---|---|
@@ -1,44 +1,44 @@ | ||
// credit: https://github.com/SimonCropp/Polyfill/blob/main/src/Polyfill/CallerArgumentExpressionAttribute.cs | ||
// Bringing in the file rather than using the library to avoid problems of additional libraries | ||
// within a source generator. | ||
|
||
// <auto-generated /> | ||
#pragma warning disable | ||
|
||
#if NETFRAMEWORK || NETSTANDARD || NETCOREAPP2X | ||
|
||
namespace System.Runtime.CompilerServices; | ||
|
||
using System.Diagnostics; | ||
using System.Diagnostics.CodeAnalysis; | ||
using Link = System.ComponentModel.DescriptionAttribute; | ||
|
||
/// <summary> | ||
/// Indicates that a parameter captures the expression passed for another parameter as a string. | ||
/// </summary> | ||
[ExcludeFromCodeCoverage] | ||
[DebuggerNonUserCode] | ||
[AttributeUsage(AttributeTargets.Parameter)] | ||
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.callerargumentexpressionattribute")] | ||
#if PolyPublic | ||
public | ||
#endif | ||
sealed class CallerArgumentExpressionAttribute : | ||
Attribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="CallerArgumentExpressionAttribute"/> class. | ||
/// </summary> | ||
/// <param name="parameterName"> | ||
/// The name of the parameter whose expression should be captured as a string. | ||
/// </param> | ||
public CallerArgumentExpressionAttribute(string parameterName) => | ||
ParameterName = parameterName; | ||
|
||
/// <summary> | ||
/// Gets the name of the parameter whose expression should be captured as a string. | ||
/// </summary> | ||
public string ParameterName { get; } | ||
} | ||
|
||
// credit: https://github.com/SimonCropp/Polyfill/blob/main/src/Polyfill/CallerArgumentExpressionAttribute.cs | ||
// Bringing in the file rather than using the library to avoid problems of additional libraries | ||
// within a source generator. | ||
|
||
// <auto-generated /> | ||
#pragma warning disable | ||
|
||
#if NETFRAMEWORK || NETSTANDARD || NETCOREAPP2X | ||
|
||
namespace System.Runtime.CompilerServices; | ||
|
||
using System.Diagnostics; | ||
using System.Diagnostics.CodeAnalysis; | ||
using Link = System.ComponentModel.DescriptionAttribute; | ||
|
||
/// <summary> | ||
/// Indicates that a parameter captures the expression passed for another parameter as a string. | ||
/// </summary> | ||
[ExcludeFromCodeCoverage] | ||
[DebuggerNonUserCode] | ||
[AttributeUsage(AttributeTargets.Parameter)] | ||
[Link("https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.callerargumentexpressionattribute")] | ||
#if PolyPublic | ||
public | ||
#endif | ||
sealed class CallerArgumentExpressionAttribute : | ||
Attribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="CallerArgumentExpressionAttribute"/> class. | ||
/// </summary> | ||
/// <param name="parameterName"> | ||
/// The name of the parameter whose expression should be captured as a string. | ||
/// </param> | ||
public CallerArgumentExpressionAttribute(string parameterName) => | ||
ParameterName = parameterName; | ||
|
||
/// <summary> | ||
/// Gets the name of the parameter whose expression should be captured as a string. | ||
/// </summary> | ||
public string ParameterName { get; } | ||
} | ||
|
||
#endif |
32 changes: 16 additions & 16 deletions
32
src/CSnakes/CaseHelper.cs → src/CSnakes.SourceGeneration/CaseHelper.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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
namespace CSnakes | ||
{ | ||
public static class CaseHelper | ||
{ | ||
public static string ToPascalCase(this string snakeCase) | ||
{ | ||
return string.Join("", snakeCase.Split('_').Select(s => s.Length > 1 ? char.ToUpperInvariant(s[0]) + s.Substring(1) : "_")); | ||
} | ||
|
||
public static string ToLowerPascalCase(this string snakeCase) | ||
{ | ||
// Make sure the first letter is lowercase | ||
return char.ToLowerInvariant(snakeCase[0]) + ToPascalCase(snakeCase).Substring(1); | ||
} | ||
} | ||
} | ||
namespace CSnakes | ||
{ | ||
public static class CaseHelper | ||
{ | ||
public static string ToPascalCase(this string snakeCase) | ||
{ | ||
return string.Join("", snakeCase.Split('_').Select(s => s.Length > 1 ? char.ToUpperInvariant(s[0]) + s.Substring(1) : "_")); | ||
} | ||
|
||
public static string ToLowerPascalCase(this string snakeCase) | ||
{ | ||
// Make sure the first letter is lowercase | ||
return char.ToLowerInvariant(snakeCase[0]) + ToPascalCase(snakeCase).Substring(1); | ||
} | ||
} | ||
} |
54 changes: 27 additions & 27 deletions
54
src/CSnakes/GeneratorError.cs → ...Snakes.SourceGeneration/GeneratorError.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 |
---|---|---|
@@ -1,27 +1,27 @@ | ||
namespace CSnakes; | ||
|
||
public class GeneratorError | ||
{ | ||
|
||
public string Message { get; } | ||
|
||
public int StartLine { get; } | ||
|
||
public int StartColumn { get; } | ||
|
||
public int EndLine { get; } | ||
|
||
public int EndColumn { get; } | ||
|
||
public string Code { get; } | ||
|
||
public GeneratorError(int startLine, int endLine, int startColumn, int endColumn, string message) | ||
{ | ||
Message = message; | ||
StartLine = startLine; | ||
StartColumn = startColumn; | ||
EndLine = endLine == -1 ? startLine : endLine; | ||
EndColumn = endColumn; | ||
Code = "hello"; | ||
} | ||
} | ||
namespace CSnakes; | ||
|
||
public class GeneratorError | ||
{ | ||
|
||
public string Message { get; } | ||
|
||
public int StartLine { get; } | ||
|
||
public int StartColumn { get; } | ||
|
||
public int EndLine { get; } | ||
|
||
public int EndColumn { get; } | ||
|
||
public string Code { get; } | ||
|
||
public GeneratorError(int startLine, int endLine, int startColumn, int endColumn, string message) | ||
{ | ||
Message = message; | ||
StartLine = startLine; | ||
StartColumn = startColumn; | ||
EndLine = endLine == -1 ? startLine : endLine; | ||
EndColumn = endColumn; | ||
Code = "hello"; | ||
} | ||
} |
Oops, something went wrong.