Compze.Build.InternalizedSourceReferences 0.1.0-alpha.3

This is a prerelease version of Compze.Build.InternalizedSourceReferences.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Compze.Build.InternalizedSourceReferences --version 0.1.0-alpha.3
                    
NuGet\Install-Package Compze.Build.InternalizedSourceReferences -Version 0.1.0-alpha.3
                    
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="Compze.Build.InternalizedSourceReferences" Version="0.1.0-alpha.3">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Compze.Build.InternalizedSourceReferences" Version="0.1.0-alpha.3" />
                    
Directory.Packages.props
<PackageReference Include="Compze.Build.InternalizedSourceReferences">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
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 Compze.Build.InternalizedSourceReferences --version 0.1.0-alpha.3
                    
#r "nuget: Compze.Build.InternalizedSourceReferences, 0.1.0-alpha.3"
                    
#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 Compze.Build.InternalizedSourceReferences@0.1.0-alpha.3
                    
#: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=Compze.Build.InternalizedSourceReferences&version=0.1.0-alpha.3&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Compze.Build.InternalizedSourceReferences&version=0.1.0-alpha.3&prerelease
                    
Install as a Cake Tool

Compze.Build.InternalizedSourceReferences

An MSBuild task that enables circular dependencies between .NET library projects. The library using thing task gets a local "internalized" copy of the other library's code (or any number of other libraries' code).

Key Constraints and gotchas

Internalized types cannot appear in the public API of the consuming project. Since they are rewritten to internal, they can't be used in public method signatures, property types, base classes, or interface implementations that are exposed to consumers.

Static state Any static state in the "referenced" library will NOT be shared. The local source results in entirely different types and data as far as the runtime is concerned.

What Gets Rewritten

Input Output
public class Foo internal class Foo
public interface IBar internal interface IBar
public struct Baz internal struct Baz
public enum Color internal enum Color
public record Person internal record Person
public delegate void Handler internal delegate void Handler
public static class Extensions internal static class Extensions
public abstract class Base internal abstract class Base
public sealed partial class Widget internal sealed partial class Widget

MSBuild Integration

Add this to your .csproj file

<PropertyGroup>
  <InternalizeSourceFrom>..\LibraryA;..\LibraryB;..\LibraryC</InternalizeSourceFrom>
  <InternalizeSourceTo>$(MSBuildProjectDirectory)\InternalizedSource</InternalizeSourceTo>
</PropertyGroup>

The target:

  • Runs BeforeTargets="CoreCompile" so rewriting happens before your code compiles
  • Only writes files when content has actually changed
  • Auto-includes the generated files in compilation
  • Only runs when both properties are set

The InternalizedSource folder can be .gitignored since it's regenerated on build.

API

SourceRewriter.MakeTypesInternal(string source) → string

Rewrites a single C# source string. Prepends the auto-generated header and replaces public type declarations with internal.

SourceRewriter.RewriteDirectory(string inputDirectory, string outputDirectory)

Convenience overload — calls RewriteDirectories with a single input directory.

SourceRewriter.RewriteDirectories(string[] inputDirectories, string outputDirectory)

Rewrites all .cs files from multiple input directories into outputDirectory, preserving directory structure per input. Only writes files whose content has actually changed. Removes stale output files that no longer have a corresponding input.

License

Apache-2.0

Development

See DEVELOPMENT.md for project structure, build instructions, testing workflow, and implementation details.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • net9.0

    • 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