-
Notifications
You must be signed in to change notification settings - Fork 27
Publicizer
StarCpt edited this page Jan 10, 2026
·
7 revisions
Plugins can use the Publicizer to expose internal and private types and members. Publicizer should be used instead of reflection when possible because it results in faster, safer, and more readable code.
Prerequisite: Create an SDK style .NET Framework 4.8 project.
-
Add the Krafs.Publicizer package to your project.
-
Add a file named
IgnoresAccessChecksToAttribute.csto your project with the following code. Do not change the namespace.
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}- Add the following line at the start of the file (before the namespace declaration) 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")]- Add the following items and properties to your .csproj file. Add as many
<Publicize />items as you addedIgnoresAccessChecksToentries in step 3. These are needed for Krafs.Publicizer to work properly, without them builds will fail and autocompletion will not work for 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>