Basilisque.CodeAnalysis.TestSupport
1.0.0-RC25
dotnet add package Basilisque.CodeAnalysis.TestSupport --version 1.0.0-RC25
NuGet\Install-Package Basilisque.CodeAnalysis.TestSupport -Version 1.0.0-RC25
<PackageReference Include="Basilisque.CodeAnalysis.TestSupport" Version="1.0.0-RC25" />
paket add Basilisque.CodeAnalysis.TestSupport --version 1.0.0-RC25
#r "nuget: Basilisque.CodeAnalysis.TestSupport, 1.0.0-RC25"
// 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.
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 | 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. |
.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 (>= 4.5.0)
- Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing (>= 1.1.1)
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 |