Aspid.Generators.Helper
0.0.1-alpha.1
See the version list below for details.
dotnet add package Aspid.Generators.Helper --version 0.0.1-alpha.1
NuGet\Install-Package Aspid.Generators.Helper -Version 0.0.1-alpha.1
<PackageReference Include="Aspid.Generators.Helper" Version="0.0.1-alpha.1" />
<PackageVersion Include="Aspid.Generators.Helper" Version="0.0.1-alpha.1" />
<PackageReference Include="Aspid.Generators.Helper" />
paket add Aspid.Generators.Helper --version 0.0.1-alpha.1
#r "nuget: Aspid.Generators.Helper, 0.0.1-alpha.1"
#:package Aspid.Generators.Helper@0.0.1-alpha.1
#addin nuget:?package=Aspid.Generators.Helper&version=0.0.1-alpha.1&prerelease
#tool nuget:?package=Aspid.Generators.Helper&version=0.0.1-alpha.1&prerelease
Aspid.Generators.Helper
A set of utilities for simplifying Source Generators development:
Code generation helper CodeWriter
Extensions for symbols and syntax nodes
Text "builders" for delegates/attributes/namespaces
Status: prerelease (alpha). Interfaces and API may change.
Installation
The package is available on NuGet (prerelease):
Install-Package Aspid.Generators.Helper -Version 0.0.1-alpha.1
or via .csproj:
<ItemGroup>
<PackageReference Include="Aspid.Generators.Helper" Version="0.0.1-alpha.1" />
</ItemGroup>
For the package to work correctly, we also recommend installing SourceGenerator.Foundations
Install-Package SourceGenerator.Foundations -Version 2.0.13
or via .csproj:
<ItemGroup>
<PackageReference Include="SourceGenerator.Foundations" Version="2.0.13" />
</ItemGroup>
Target framework: .NET Standard 2.0. Compatible with generators for .NET Standard 2.0/+.
Examples
using Aspid.Generators.Helper;
using static Aspid.Generators.Helper.Classes;
private static void GenerateCode(SourceProductionContext context)
{
var hasNamespace = true;
var namespaceName = "MyNamespace";
var code = new CodeWrite()
.Append("// ")
.AppendLine("<auto generated \>")
.AppendLine()
.AppendLineIf(hasNamespace, $"namespace {namespaceName}");
.BeginBlockIf(hasNamespace)
.AppendMultiLine(
$$"""
public static class MyExtensions
{
public staic void DoSomthing()
{
throw new {{Exception}}();
}
}
"""
)
.EndBlockIf(hasNamespace);
context.AddSource(hintName, code.GetSourceText());
// Generated Code:
// // <auto generated \>
// namespace MyNamespace
// {
// public static class MyExtensions
// {
// public static void DoSomthing()
// {
// throw new global::System.Exception();
// }
// }
// }
}
using Aspid.Generators.Helper;
public static void DoSomething(
SemanticModel semanticModel,
CSharpSyntaxNode cSharpSyntaxNode,
MemberDeclarationSyntax memberDeclarationSyntax,
PropertyDeclarationSyntax propertyDeclarationSyntax)
{
var namespaceName = cSharpSyntaxNode.GetNamespaceName();
bool value1 = memberDeclarationSyntax.HasAnyAttributeInSelf(semanticModel, "FullNameAttribute", "OtherFullNameAttribute");
bool value3 = memberDeclarationSyntax.TryGetAnyAttributeInSelf(semanticModel, out IMethodSymbol? outAttribute2, "FullNameAttribute", "OtherFullNameAttribute");
IMethodSymbol attribute = memberDeclarationSyntax.GetAttributeInSelf(semanticModel, "FullNameAttribute");
IEnumerable<IMethodSymbol> attributes = memberDeclarationSyntax.GetAttributesInSelf(semanticModel, "FullNameAttribute", "OtherFullNameAttribute");
var hasGet = propertyDeclarationSyntax.HasGetAccessor();
var hasSet = propertyDeclarationSyntax.HasSetAccessor();
var hasInit = propertyDeclarationSyntax.HasInitAccessor();
}
using Aspid.Generators.Helper;
public static void DoSomething(
ISymbol symbol,
IMethodSymbol methodSymbol1,
IMethodSymbol methodSymbol2)
{
ITypeSymbol typeSymbol = symbol.GetSymbolType();
string globalName = symbol.ToDisplayStringGlobal();
bool value2 = symbol.HasAnyAttributeInSelf("FullNameAttribute", "OtherFullNameAttribute");
bool value3 = symbol.TryGetAnyAttributeInSelf(out AttributeData? outAttribute2, "FullNameAttribute", "OtherFullNameAttribute");
AttributeData? attributeData1 = symbol.GetAttributeInSelf("FullNameAttribute");
IEnumerable<AttributeData> attributesData1 = symbol.GetAttributesInSelf("FullNameAttribute", "OtherFullNameAttribute");
bool equalsMethods = methodSymbol.EqualsSignature(methodSymbol2);
string nameFromExplicitImplementation = methodSymbol.NameFromExplicitImplementation();
bool value4 = typeSymbol.HasAnyAttributeInBases("FullNameAttribute");
bool value5 = typeSymbol.HasAnyAttributeInSelfAndBases("FullNameAttribute", "OtherFullNameAttribute");
bool value6 = typeSymbol.TryGetAnyAttributeInBases(out AttributeData? outAttribute2, "FullNameAttribute", "OtherFullNameAttribute");
bool value7 = typeSymbol.TryGetAnyAttributeInSelfAndBases(out AttributeData? outAttribute2, "FullNameAttribute", "OtherFullNameAttribute");
AttributeData? attributeData2 = symbol.GetAttributeInBases("FullNameAttribute");
AttributeData? attributeData3 = symbol.GetAttributeInSelfAndBases("FullNameAttribute");
IEnumerable<AttributeData> attributesData2 = symbol.GetAttributesInBases("FullNameAttribute", "OtherFullNameAttribute");
IEnumerable<AttributeData> attributesData3 = symbol.GetAttributesInSelfAndBases("FullNameAttribute", "OtherFullNameAttribute");
bool value8 = typeSymbol.HasAnyBaseType("FullBaseTypeName", "OtherFullBaseTypeName");
bool value9 = typeSymbol.TryGetAnyBaseType(out out ITypeSymbol? outBaseType1, "FullBaseTypeName", "OtherFullBaseTypeName");
ITypeSymbol? baseType = typeSymbol.GetBaseType("FullBaseTypeName");
IEnumerable<ITypeSymbol> baseTypes = typeSymbol.GetBaseType("FullBaseTypeName", "OtherFullBaseTypeName");
IEnumerable<ITypeSymbol> allBaseTypes1 = typeSymbol.GetAllBaseTypes();
IEnumerable<ITypeSymbol> allBaseTypes2 = typeSymbol.GetAllBaseTypesAndSelf();
bool value10 = typeSymbol.HasAnyInterfaceInSelf("FullInterfaceName", "OtherFullInterfaceName");
bool value11 = typeSymbol.HasAnyInterfaceInSelfAndBases("FullInterfaceName", "OtherInterfaceName");
bool value12 = typeSymbol.TryGetAnyInterfaceInSelf(out INamedTypeSymbol? outInterface1, "FullInterfaceName", "OtherFullInterfaceName");
bool value13 = typeSymbol.TryGetAnyInterfaceInSelfAndBases(out INamedTypeSymbol? outInterface2, "FullInterfaceName", "OtherInterfaceName");
INamedTypeSymbol? interface1 = typeSymbol.GetInterfaceInSelf("FullInterfaceName");
INamedTypeSymbol? interface2 = typeSymbol.GetInterfaceInSelfAndBases("FullInterfaceName");
IEnumerable<INamedTypeSymbol> interfaces1 = typeSymbol.GetInterfacesInSelf("FullInterfaceName", "OtherInterfaceName");
IEnumerable<INamedTypeSymbol> interfaces2 = typeSymbol.GetInterfacesInSelfAndBases("FullInterfaceName", "OtherInterfaceName");
}
Links
- Repository on GitHub
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.CSharp (>= 4.3.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Aspid.Generators.Helper:
| Package | Downloads |
|---|---|
|
Aspid.Generators.Helper.Unity
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 0.0.1-alpha.3 | 74 | 10/11/2025 | |
| 0.0.1-alpha.1 | 93 | 10/10/2025 |
Alpha release:
- Initial packaging of helper utilities for C# source generators.
- CodeWriter helpers and Roslyn symbol/syntax extension methods.
- Target framework: .NET Standard 2.0.
- License: MIT.
- Repository: https://github.com/VPDPersonal/Aspid.Generators.Helper
(2025-10-06)