FractalDataWorks.CodeBuilder.Analysis 0.6.0-rc.1

This is a prerelease version of FractalDataWorks.CodeBuilder.Analysis.
dotnet add package FractalDataWorks.CodeBuilder.Analysis --version 0.6.0-rc.1
                    
NuGet\Install-Package FractalDataWorks.CodeBuilder.Analysis -Version 0.6.0-rc.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="FractalDataWorks.CodeBuilder.Analysis" Version="0.6.0-rc.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FractalDataWorks.CodeBuilder.Analysis" Version="0.6.0-rc.1" />
                    
Directory.Packages.props
<PackageReference Include="FractalDataWorks.CodeBuilder.Analysis" />
                    
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 FractalDataWorks.CodeBuilder.Analysis --version 0.6.0-rc.1
                    
#r "nuget: FractalDataWorks.CodeBuilder.Analysis, 0.6.0-rc.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 FractalDataWorks.CodeBuilder.Analysis@0.6.0-rc.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=FractalDataWorks.CodeBuilder.Analysis&version=0.6.0-rc.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=FractalDataWorks.CodeBuilder.Analysis&version=0.6.0-rc.1&prerelease
                    
Install as a Cake Tool

FractalDataWorks.CodeBuilder.Analysis

Abstractions for code analysis expectations used in testing source generators and code generation output.

Overview

This package defines interfaces for a fluent expectation API that verifies generated code structure. It provides contracts for asserting the presence and characteristics of namespaces, classes, interfaces, records, enums, methods, properties, fields, and constructors within syntax trees.

Installation

<PackageReference Include="FractalDataWorks.CodeBuilder.Analysis" Version="1.0.0" />

Core Interfaces

Entry Point

From ISyntaxExpectations.cs:6-21:

public interface ISyntaxExpectations
{
    /// <summary>
    /// Creates expectations for generated code.
    /// </summary>
    /// <param name="generatedCode">The generated code as a string.</param>
    /// <returns>A syntax tree expectations instance.</returns>
    ISyntaxTreeExpectations ExpectCode(string generatedCode);

    /// <summary>
    /// Creates expectations for a syntax tree.
    /// </summary>
    /// <param name="syntaxTree">The syntax tree object.</param>
    /// <returns>A syntax tree expectations instance.</returns>
    ISyntaxTreeExpectations ExpectSyntaxTree(object syntaxTree);
}

Syntax Tree Expectations

From ISyntaxTreeExpectations.cs:8-55:

public interface ISyntaxTreeExpectations
{
    ISyntaxTreeExpectations HasNamespace(string namespaceName, Action<INamespaceExpectations>? expectations = null);
    ISyntaxTreeExpectations HasClass(string className, Action<IClassExpectations>? expectations = null);
    ISyntaxTreeExpectations HasInterface(string interfaceName, Action<IInterfaceExpectations>? expectations = null);
    ISyntaxTreeExpectations HasEnum(string enumName, Action<IEnumExpectations>? expectations = null);
    ISyntaxTreeExpectations HasRecord(string recordName, Action<IRecordExpectations>? expectations = null);
    ISyntaxTreeExpectations Compiles();
}

Class Expectations

From IClassExpectations.cs:8-85:

public interface IClassExpectations
{
    IClassExpectations HasAccessModifier(string modifier);
    IClassExpectations HasMethod(string methodName, Action<IMethodExpectations>? expectations = null);
    IClassExpectations HasProperty(string propertyName, Action<IPropertyExpectations>? expectations = null);
    IClassExpectations HasField(string fieldName, Action<IFieldExpectations>? expectations = null);
    IClassExpectations HasConstructor(Action<IConstructorExpectations>? expectations = null);
    IClassExpectations ImplementsInterface(string interfaceName);
    IClassExpectations InheritsFrom(string baseClassName);
    IClassExpectations IsAbstract();
    IClassExpectations IsSealed();
    IClassExpectations IsStatic();
    IClassExpectations IsPartial();
}

Method Expectations

From IMethodExpectations.cs:6-54:

public interface IMethodExpectations
{
    IMethodExpectations HasReturnType(string returnType);
    IMethodExpectations HasParameter(string parameterName, string parameterType);
    IMethodExpectations IsAsync();
    IMethodExpectations IsStatic();
    IMethodExpectations IsVirtual();
    IMethodExpectations IsOverride();
    IMethodExpectations IsAbstract();
}

Property Expectations

From IPropertyExpectations.cs:6-44:

public interface IPropertyExpectations
{
    IPropertyExpectations HasType(string propertyType);
    IPropertyExpectations HasGetter();
    IPropertyExpectations HasSetter();
    IPropertyExpectations HasInitSetter();
    IPropertyExpectations IsReadOnly();
    IPropertyExpectations IsStatic();
}

Field Expectations

From IFieldExpectations.cs:6-32:

public interface IFieldExpectations
{
    IFieldExpectations HasType(string fieldType);
    IFieldExpectations IsReadOnly();
    IFieldExpectations IsStatic();
    IFieldExpectations IsConst();
}

Constructor Expectations

From IConstructorExpectations.cs:6-21:

public interface IConstructorExpectations
{
    IConstructorExpectations HasParameter(string parameterName, string parameterType);
    IConstructorExpectations IsStatic();
}

Enum Expectations

From IEnumExpectations.cs:6-22:

public interface IEnumExpectations
{
    IEnumExpectations HasValue(string valueName, int? value = null);
    IEnumExpectations HasUnderlyingType(string underlyingType);
}

Architecture

This package provides interface definitions only. For concrete implementations, see:

  • FractalDataWorks.CodeBuilder.Analysis.CSharp - Roslyn-based implementation for C# code verification

The separation allows language-agnostic test contracts while supporting language-specific implementations.

Package Purpose
FractalDataWorks.CodeBuilder.Analysis.CSharp C# implementation with Roslyn integration
FractalDataWorks.CodeBuilder.Abstractions Core CodeBuilder abstractions
FractalDataWorks.CodeBuilder.CSharp C# code generation

Best Practices

  1. Use the fluent API - Chain expectations for readable test code
  2. Test generated code structure - Verify classes, methods, and properties exist with correct signatures
  3. Verify compilation - Use Compiles() to ensure generated code is valid C#
  4. Test modifiers - Verify access modifiers, sealed/abstract, and other declarations

Next Steps

  • See FractalDataWorks.CodeBuilder.Analysis.CSharp for the concrete implementation
  • See test projects for usage examples
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.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on FractalDataWorks.CodeBuilder.Analysis:

Package Downloads
FractalDataWorks.CodeBuilder.Analysis.CSharp

C# testing utilities for FractalDataWorks CodeBuilder - compile and test generated code

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.6.0-rc.1 59 2/9/2026
Loading failed