Aspid.Generators.Helper 0.0.1-alpha.1

Suggested Alternatives

Aspid.Generators.Helper 0.0.1-alpha.3

This is a prerelease version of Aspid.Generators.Helper.
There is a newer prerelease version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Aspid.Generators.Helper" Version="0.0.1-alpha.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Aspid.Generators.Helper" Version="0.0.1-alpha.1" />
                    
Directory.Packages.props
<PackageReference Include="Aspid.Generators.Helper" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Aspid.Generators.Helper --version 0.0.1-alpha.1
                    
#r "nuget: Aspid.Generators.Helper, 0.0.1-alpha.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Aspid.Generators.Helper@0.0.1-alpha.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Aspid.Generators.Helper&version=0.0.1-alpha.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Aspid.Generators.Helper&version=0.0.1-alpha.1&prerelease
                    
Install as a Cake Tool

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");
}
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

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)