Skip to content

Commit 854427b

Browse files
committed
Add disabling mechanism for automatically included IgnoreAccessChecksToAttribute definition
1 parent ed02951 commit 854427b

5 files changed

Lines changed: 20 additions & 6 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,13 @@ No matter your project type, the following attributes are always defined.
296296
Additionally, for each `ResoniteReference` with `UsePublicized` set to `true`,
297297
a corresponding `IgnoreAccessChecksTo` attribute is added.
298298
This ensures that there will be no issues when accessing non-public types or
299-
members of those assemblies at runtime.
299+
members of those assemblies at runtime.
300+
As this attribute is supported by the runtime but not available by default,
301+
it has to be supplied directly or from another library.
302+
To do this, a definition for the attribute is automatically included
303+
for mod projects that do not already get access to it
304+
through a library included by the SDK.
305+
To prevent this, set the property `ResoniteHasIgnoreAccessChecksAttribute` to `true`.
300306

301307

302308
### Publishing

Remora.Resonite.Sdk/Sdk/ProjectTypes/Mod.BepisLoader.targets

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<Project>
22
<PropertyGroup>
33
<DefineConstants>$(DefineConstants);RESONITE_BEPISLOADER</DefineConstants>
4+
45
<_MainOutputDirectory>BepInEx/plugins/$(AssemblyName)/</_MainOutputDirectory>
6+
7+
<ResoniteHasIgnoreAccessChecksAttribute>true</ResoniteHasIgnoreAccessChecksAttribute>
58
</PropertyGroup>
69

710
<PropertyGroup Condition="'$(ResoniteTarget)' != 'renderite'">

Remora.Resonite.Sdk/Sdk/ProjectTypes/Mod.MonkeyLoader.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
<ResoniteMonkeyLoaderPath>$(ResoniteTargetPath)MonkeyLoader/</ResoniteMonkeyLoaderPath>
2020
<ResoniteMonkeyLoaderOutputPath>$(ResoniteTargetPath)$(_MonkeyLoaderMainDirectory)</ResoniteMonkeyLoaderOutputPath>
21+
22+
<ResoniteHasIgnoreAccessChecksAttribute>true</ResoniteHasIgnoreAccessChecksAttribute>
2123
</PropertyGroup>
2224

2325
<!-- References for client / headless -->

Remora.Resonite.Sdk/Sdk/ProjectTypes/Mod.targets

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@
44

55
<ResoniteUseMonkeyLoaderCore Condition="'$(ResoniteUseMonkeyLoaderCore)' == ''">false</ResoniteUseMonkeyLoaderCore>
66
<ResoniteUseMonkeyLoaderCore Condition="'$(ResoniteTargetModLoader)' == 'MonkeyLoader'">false</ResoniteUseMonkeyLoaderCore>
7+
8+
<ResoniteHasIgnoreAccessChecksAttribute Condition="'$(ResoniteHasIgnoreAccessChecksAttribute)' == ''">false</ResoniteHasIgnoreAccessChecksAttribute>
9+
<ResoniteHasIgnoreAccessChecksAttribute Condition="'$(ResoniteUseMonkeyLoaderCore)' == 'true'">true</ResoniteHasIgnoreAccessChecksAttribute>
710
</PropertyGroup>
811

12+
<ItemGroup>
13+
<Compile Include="$(MSBuildThisFileDirectory)../include/IgnoresAccessChecksToAttribute.cs" Visible="false"
14+
Condition="'$(ResoniteHasIgnoreAccessChecksAttribute)' == 'true'" />
15+
</ItemGroup>
16+
917
<ItemGroup>
1018
<PackageReference Include="MicroUtils.HarmonyAnalyzers" Version="1.6.1">
1119
<PrivateAssets>all</PrivateAssets>

Remora.Resonite.Sdk/Sdk/ProjectTypes/Shared.ResoniteModLoader.targets

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
<PackageReference Include="Lib.Harmony" Version="2.4.2" />
1111
</ItemGroup>
1212

13-
<ItemGroup>
14-
<Compile Include="$(MSBuildThisFileDirectory)../include/IgnoresAccessChecksToAttribute.cs" Visible="false"
15-
Condition="'$(ResoniteUseMonkeyLoaderCore)' != 'true'" />
16-
</ItemGroup>
17-
1813
<!-- Error for invalid RML target (renderite) -->
1914
<Target Name="RML_ResoniteTarget_Checking" Condition="'$(ResoniteTarget)' != 'client' AND '$(ResoniteTarget)' != 'headless'">
2015
<Error Code="RESO501" Text="ResoniteModLoader does not support ResoniteTarget options other than 'client' and 'headless'!" />

0 commit comments

Comments
 (0)