Install-Package MakeTypesPublic -Version 1.0.3
dotnet add package MakeTypesPublic --version 1.0.3
<PackageReference Include="MakeTypesPublic" Version="1.0.3"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add MakeTypesPublic --version 1.0.3
#r "nuget: MakeTypesPublic, 1.0.3"
// Install MakeTypesPublic as a Cake Addin #addin nuget:?package=MakeTypesPublic&version=1.0.3 // Install MakeTypesPublic as a Cake Tool #tool nuget:?package=MakeTypesPublic&version=1.0.3
The package MakeTypesPublic is intended to disable access checks to non-public (private, internal) types and its members in other assemblies.
How to use it
- You should set the
<IgnoreAccessChecks>true</IgnoreAccessChecks>property. By default it's enabled only for compile-time builds (not for design-time builds). So, Visual Studio will show errors but compiler and runtime will work.
- You should set up the
PackageReferenceitems with the
<PropertyGroup> <IgnoreAccessChecks>true</IgnoreAccessChecks> </PropertyGroup> <ItemGroup> <ProjectReference Include="..\Lib\Lib.csproj" IgnoreAccessChecks="true" /> <PackageReference Include="NuGetPackage" IgnoreAccessChecks="true" /> </ItemGroup>
How it works
There are a few types of access checks:
- Compile-time access checks. You should compile with fake assemblies with public types and members (ideally reference-only assembly) to disable it. The Roslyn has options to disable access checks but those options are internal. To learn more see the following links: Link 1, Link 2, Link 3.
- Run-time access checks. You should add
IgnoresAccessChecksToAttributeassembly attributes to disable it.
- Design-time access checks. There is a problem here.
You could make Visual Studio to consume the fake assemblies. But this can lead to some problems. So I preferred just ignore those errors.
Maybe there are other ways to suppress these errors? But I don't know them.
If you still want to make Visual Studio to consume the fake assemblies you can set
IgnoreAccessChecksproperty to true. By default this property is true only for not design-time builds.
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.