CircularReflection 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package CircularReflection --version 1.0.0                
NuGet\Install-Package CircularReflection -Version 1.0.0                
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="CircularReflection" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CircularReflection --version 1.0.0                
#r "nuget: CircularReflection, 1.0.0"                
#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 CircularReflection as a Cake Addin
#addin nuget:?package=CircularReflection&version=1.0.0

// Install CircularReflection as a Cake Tool
#tool nuget:?package=CircularReflection&version=1.0.0                

CircularReflection

MSBuild task that re-writes classes as abstract definitions, to allow circular references

This is useful for:

  • Auto-generation of references (such as URLs from ASPNet)
  • Making nameof(...) references
  • Making <see cref="..."/> references in doc comments

Applying the build task to your project

  1. Reference the NuGet package in the project that wants to read the types
  2. Add <InputBase>$(MSBuildProjectDirectory)\..\SourceProject\CsFileDirectory</InputBase> into a <PropertyGroup> of any project referencing this package
  3. Rebuild, and start referencing types
    <PropertyGroup>
        
        <ReflectionInputBase>$(MSBuildProjectDirectory)\..\SourceProject\CsFileDirectory</ReflectionInputBase>
    </PropertyGroup>

Referencing types in your project

The types in the source files will be added with the namespace prefix Reflection. So if the source has a class Me.MyPackage.MyClass, the generated type will be Reflection.Me.MyPackage.MyClass

Adding more using directives

If you are referencing files between different targets, you may need to include extra namespaces into the output.

    <PropertyGroup>
        
        <ReflectionAdditionalUsings>System;System.Collections.Generic;System.Threading.Tasks;</ReflectionAdditionalUsings>
    </PropertyGroup>

Generated files

The generated files are written to the project's obj directory in a file named CircularReflection.generated.cs. This will be linked into the sources as part of the build.

If required, the output can be moved with the ReflectionOutputBase setting

Development of the package

Building the NuGet package

First, always do a clean and rebuild.

Update the versions to match in the project properties ( assembly and nuget), and the nuspec file.

Open a terminal in the directory of CircularReflection.csproj, and run the command dotnet pack -o ...

References

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.4 660 9/9/2024
1.0.3 548 7/2/2024
1.0.2 121 7/2/2024
1.0.1 130 7/2/2024
1.0.0 126 7/1/2024