Skip to content

Publicizer

StarCpt edited this page Nov 19, 2025 · 6 revisions

Plugins can use the Publicizer to expose private types and members in order to avoid using reflection which results in slower and less readable code.

Prerequisite: Create an SDK style .NET Framework 4.8 project.

Enabling Publicizer in your project

  1. Add the Krafs.Publicizer package to your project.
  2. Create an assembly info file if it doesn't already exist.
    • In Visual Studio, right click the project in Solution Explorer, navigate to Add > New Item, then select Assembly Information File.
  3. Disable "Generate assembly info" in project settings. If not, AssemblyInfo.cs will conflict with its auto-generated counterpart when building the project.
  4. Add the following line to the assembly info file for every assembly you want to publicize. Currently Pulsar does not support publicizing only specific members.
[assembly: System.Runtime.CompilerServices.IgnoresAccessChecksTo("REPLACE WITH ASSEMBLY NAME")]

Example for Sandbox.Game.dll:

[assembly: System.Runtime.CompilerServices.IgnoresAccessChecksTo("Sandbox.Game")]
  1. Add the following class to your project (note, changing the namespace will break it). File name doesn't matter.
namespace System.Runtime.CompilerServices
{
    [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
    internal sealed class IgnoresAccessChecksToAttribute : Attribute
    {
        internal IgnoresAccessChecksToAttribute(string assemblyName)
        {
        }
    }
}
  1. Add the following items and properties to your .csproj file. Add as many <Publicize /> items as you added IgnoresAccessChecksTo entries in step 4. These are needed for Krafs.Publicizer to work properly, without them builds will fail and intellisense will not show publicized types.
<ItemGroup>
  <Publicize Include="REPLACE WITH ASSEMBLY NAME" IncludeCompilerGeneratedMembers="false" />
</ItemGroup>

<PropertyGroup>
  <PublicizerClearCacheOnClean>true</PublicizerClearCacheOnClean>
  <PublicizerRuntimeStrategies>Unsafe</PublicizerRuntimeStrategies>
  <PublicizerLogFilePath>$(SolutionDir)/Krafs.Publicizer.log</PublicizerLogFilePath>
</PropertyGroup>

Clone this wiki locally