Basilisque.CodeAnalysis.TestSupport 1.0.0-RC25

This is a prerelease version of Basilisque.CodeAnalysis.TestSupport.
dotnet add package Basilisque.CodeAnalysis.TestSupport --version 1.0.0-RC25                
NuGet\Install-Package Basilisque.CodeAnalysis.TestSupport -Version 1.0.0-RC25                
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="Basilisque.CodeAnalysis.TestSupport" Version="1.0.0-RC25" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Basilisque.CodeAnalysis.TestSupport --version 1.0.0-RC25                
#r "nuget: Basilisque.CodeAnalysis.TestSupport, 1.0.0-RC25"                
#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.
// Install Basilisque.CodeAnalysis.TestSupport as a Cake Addin
#addin nuget:?package=Basilisque.CodeAnalysis.TestSupport&version=1.0.0-RC25&prerelease

// Install Basilisque.CodeAnalysis.TestSupport as a Cake Tool
#tool nuget:?package=Basilisque.CodeAnalysis.TestSupport&version=1.0.0-RC25&prerelease                

Basilisque - Code Analysis

Overview

This project provides helpers for writing .Net code analyzers and source generators.

NuGet Basilisque.CodeAnalysis License

NuGet Basilisque.CodeAnalysis
NuGet Basilisque.CodeAnalysis
NuGet Basilisque.CodeAnalysis
NuGet Basilisque.CodeAnalysis

Description

This project contains helpers and structured classes, that support you in generating source code that is syntactically correct and well formatted. It also contains helpers for unit testing source generators.

For example this code...

private string generateMyDemoMethod()
{
    var classInfo = new ClassInfo("MyDemoClass", AccessModifier.Public);
    classInfo.GenericTypes.Add("T1", (new List<string>() { "class", "new()" }, "Description of T1"));
    classInfo.GenericTypes.Add("T2", null);
    classInfo.Methods.Add(new MethodInfo(AccessModifier.Public, "bool", "MyDemoMethod")
    {
        Parameters =
        {
            new ParameterInfo(ParameterKind.Ordinary, "int", "myMaxParam")
        },
        Body =
        {
            @"
// this is the method body. You can write any code in here...
var r = System.Random.Shared.Next(myMaxParam);
if (r > 5)
    return true;
else
    return false;
"
        }
    });

    return classInfo.ToString();
}

...will result in this output:

/// <summary>
/// MyDemoClass
/// </summary>
/// <typeparam name="T1">Description of T1</typeparam>
/// <typeparam name="T2"></typeparam>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("My.Demo.SourceGenerator", "1.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class MyDemoClass<T1, T2>
    where T1 : class, new()
{
    public bool MyDemoMethod(int myMaxParam)
    {
        // this is the method body. You can write any code in here...
        var r = System.Random.Shared.Next(myMaxParam);
        if (r > 5)
            return true;
        else
            return false;
    }
}

There is support for namespaces with usings, classes, properties, methods and fields with matching support for XML code documentation, generics and extension methods.

In addition there are some helpers for registering the generated source in an incremental source generator. They will automatically provide you with information about the used language, the language version and the nullable context.

You don't have to care about the order in that you specify the code parts. The generated source code will always be well structured and correctly indented.

For details see the wiki.

Installation for Code Analyzers and Source Generators

Install the NuGet package Basilisque.CodeAnalysis.
Installing the package will automaticall configure your project to be packed as code analyzer/source generator. It will also pack its own assemblies beside your analyzer/generator as dependency.

So you're ready to get started.

Installation for Unit Tests

This project currently provides helpers for MSTest, NUnit and XUnit.
So you have to install the correct package for the test framework you're using:
Basilisque.CodeAnalysis.TestSupport.MSTest
Basilisque.CodeAnalysis.TestSupport.NUnit
Basilisque.CodeAnalysis.TestSupport.XUnit

Now you can write your first Unit Test.

License

The Basilisque framework (including this repository) is licensed under the Apache License, Version 2.0.

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. 
.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 (3)

Showing the top 3 NuGet packages that depend on Basilisque.CodeAnalysis.TestSupport:

Package Downloads
Basilisque.CodeAnalysis.TestSupport.MSTest

Package Description

Basilisque.CodeAnalysis.TestSupport.XUnit

Package Description

Basilisque.CodeAnalysis.TestSupport.NUnit

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-RC25 59 10/24/2024