Table of Contents

Class Extensions

Namespace
Albatross.CodeAnalysis.Testing
Assembly
Albatross.CodeAnalysis.Testing.dll

Provides extension methods for creating Roslyn compilations in test scenarios.

public static class Extensions
Inheritance
Extensions
Inherited Members

Methods

CreateNet8CompilationAsync(string, string, CancellationToken)

Creates a C# compilation targeting .NET 8 with C# 12 language version from the provided source code.

public static Task<CSharpCompilation> CreateNet8CompilationAsync(this string source, string assemblyName = "Net8TestAssembly", CancellationToken cancellationToken = default)

Parameters

source string

The C# source code to compile.

assemblyName string

The name of the assembly. Defaults to "Net8TestAssembly".

cancellationToken CancellationToken

A cancellation token to observe while waiting for the task to complete.

Returns

Task<CSharpCompilation>

A CSharpCompilation configured for .NET 8 with the parsed source code.