Skip to content

Commit 44eefdb

Browse files
sunnamed434claude
andcommitted
refactor: rename NonPublicized -> Reflection
The plugin's purpose IS the reflection approach, so name it by technique: the pair is now Reflection vs Publicized. Renames the folder, project, namespace, class, and solution entry, and updates the README + Dependabot directories. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 6accfac commit 44eefdb

7 files changed

Lines changed: 54 additions & 55 deletions

.github/dependabot.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ updates:
2424
- package-ecosystem: "nuget"
2525
directories:
2626
- "/Publicized"
27-
- "/NonPublicized"
27+
- "/Reflection"
2828
schedule:
2929
interval: "weekly"
3030
day: "monday"
@@ -44,7 +44,7 @@ updates:
4444
allow:
4545
- dependency-type: "direct"
4646
ignore:
47-
# Both projects are pinned to the SAME game build so the publicized-vs-not
48-
# contrast stays apples-to-apples. Bump these two by hand, together.
47+
# Both projects are pinned to the SAME game build so the comparison stays
48+
# apples-to-apples. Bump these two by hand, together.
4949
- dependency-name: "RocketModFix.Unturned.Redist.Server"
5050
- dependency-name: "RocketModFix.Unturned.Redist.Server.Publicized"

Publicized/PublicizedExamplePlugin.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
namespace UnturnedRedistExample.Publicized
66
{
77
/// <summary>
8-
/// Uses the <c>.Publicized</c> redist, so it can read members that are
9-
/// non-public in the stock game. Compare with <c>../NonPublicized</c>, which
10-
/// references the plain redist and can only touch public API.
8+
/// Uses the <c>.Publicized</c> redist, so it reads members that are non-public
9+
/// in the stock game as plain, compile-checked field accesses. Compare with
10+
/// <c>../Reflection</c>, which reads the same field via reflection.
1111
/// </summary>
1212
public class PublicizedExamplePlugin : RocketPlugin
1313
{

Publicized/UnturnedRedistExample.Publicized.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
<PackageReference Include="RocketModFix.Rocket.Unturned" Version="4.23.1" />
1313

1414
<!-- Publicized: Unturned's assemblies with non-public members rewritten to
15-
public, so this plugin can read them. Pinned to the SAME game build as
16-
../NonPublicized so the ONLY difference between the two projects is
17-
publicization (bump both together). -->
15+
public, so this plugin can read them directly. Pinned to the SAME game
16+
build as ../Reflection so only the technique differs (bump both together). -->
1817
<PackageReference Include="RocketModFix.Unturned.Redist.Server.Publicized" Version="3.26.3.3" />
1918

2019
<!-- UnityEngine assemblies (Unturned types derive from MonoBehaviour). -->

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Both reference the **same game build** (`3.26.3.3`) and both read `SDG.Unturned.
1010

1111
| Project | Redist package | How it reads the non-public field |
1212
| --- | --- | --- |
13-
| [`NonPublicized/`](NonPublicized) | `RocketModFix.Unturned.Redist.Server` | **Reflection** — string-keyed, not compile-checked, slower |
13+
| [`Reflection/`](Reflection) | `RocketModFix.Unturned.Redist.Server` | **Reflection** — string-keyed, not compile-checked, slower |
1414
| [`Publicized/`](Publicized) | `RocketModFix.Unturned.Redist.Server.Publicized` (+ `AllowUnsafeBlocks`) | **Direct field access** — compile-checked, fast |
1515

1616
## Why publicize instead of reflection?
@@ -21,7 +21,7 @@ A direct `Provider.isDedicatedUGCInstalled` **doesn't compile** against the plai
2121
CS0117: 'Provider' does not contain a definition for 'isDedicatedUGCInstalled'
2222
```
2323

24-
So without publicizing, your only option is **reflection** ([`NonPublicized/`](NonPublicized/NonPublicizedExamplePlugin.cs)):
24+
So without publicizing, your only option is **reflection** ([`Reflection/`](Reflection/ReflectionExamplePlugin.cs)):
2525

2626
```csharp
2727
FieldInfo field = typeof(Provider).GetField(
@@ -71,8 +71,8 @@ Builds both projects (via `UnturnedRedistExample.sln`); the DLLs land in each pr
7171
3. Start the server and watch the console — both read the same value, the hard way and the easy way:
7272

7373
```
74-
[UnturnedRedistExample.NonPublicized] Loaded. Read non-public isDedicatedUGCInstalled = False via REFLECTION ...
75-
[UnturnedRedistExample.Publicized] Loaded. Read NON-public Provider.isDedicatedUGCInstalled = False via the .Publicized redist.
74+
[UnturnedRedistExample.Reflection] Loaded. Read non-public isDedicatedUGCInstalled = False via REFLECTION ...
75+
[UnturnedRedistExample.Publicized] Loaded. Read NON-public Provider.isDedicatedUGCInstalled = False via the .Publicized redist.
7676
```
7777

7878
Seeing those lines confirms each plugin **loaded** and read the non-public member **at runtime**. (For the publicized one, that also proves `AllowUnsafeBlocks` did its job — if publicization were broken you'd get a `FieldAccessException` instead.)

NonPublicized/NonPublicizedExamplePlugin.cs renamed to Reflection/ReflectionExamplePlugin.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,18 @@
33
using Rocket.Core.Plugins;
44
using SDG.Unturned;
55

6-
namespace UnturnedRedistExample.NonPublicized
6+
namespace UnturnedRedistExample.Reflection
77
{
88
/// <summary>
9-
/// Uses the plain (non-publicized) redist. Public Unturned members are used
10-
/// directly; a NON-public member can only be reached via reflection — which
11-
/// is the cost of not publicizing. Compare with <c>../Publicized</c>, which
12-
/// reads the same field as a plain, compile-checked field access.
9+
/// Reads a NON-public Unturned field WITHOUT the .Publicized package — so the
10+
/// only option is reflection. Compare with <c>../Publicized</c>, which reads
11+
/// the same field as a plain, compile-checked field access.
1312
/// </summary>
14-
public class NonPublicizedExamplePlugin : RocketPlugin
13+
public class ReflectionExamplePlugin : RocketPlugin
1514
{
1615
protected override void Load()
1716
{
18-
// Public members would be trivial here (e.g. Provider.maxPlayers).
19-
// But isDedicatedUGCInstalled is NON-public: a direct
17+
// isDedicatedUGCInstalled is NON-public: a direct
2018
// `Provider.isDedicatedUGCInstalled` does not even compile against the
2119
// plain redist (CS0117). Without the .Publicized package, reflection
2220
// is the only way in:
@@ -26,15 +24,15 @@ protected override void Load()
2624
bool ugcInstalled = (bool)field.GetValue(null);
2725

2826
Logger.Log(
29-
$"[UnturnedRedistExample.NonPublicized] Loaded. Read non-public " +
27+
$"[UnturnedRedistExample.Reflection] Loaded. Read non-public " +
3028
$"isDedicatedUGCInstalled = {ugcInstalled} via REFLECTION — the name " +
3129
$"is a string (a rename breaks at runtime, not build) and every read " +
3230
$"pays a reflection + boxing cost.");
3331
}
3432

3533
protected override void Unload()
3634
{
37-
Logger.Log("[UnturnedRedistExample.NonPublicized] Unloaded.");
35+
Logger.Log("[UnturnedRedistExample.Reflection] Unloaded.");
3836
}
3937
}
4038
}

NonPublicized/UnturnedRedistExample.NonPublicized.csproj renamed to Reflection/UnturnedRedistExample.Reflection.csproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22

33
<PropertyGroup>
44
<TargetFramework>net461</TargetFramework>
5-
<!-- No AllowUnsafeBlocks: this plugin only touches public Unturned API. -->
5+
<!-- No AllowUnsafeBlocks needed: reflection reaches the non-public member at
6+
runtime; there's no compile-time access to guard. -->
67
</PropertyGroup>
78

89
<ItemGroup>
910
<!-- RocketMod API. Brings Rocket.Core (RocketPlugin, Logger) + Rocket.API. -->
1011
<PackageReference Include="RocketModFix.Rocket.Unturned" Version="4.23.1" />
1112

12-
<!-- Plain (non-publicized) redist: only public Unturned members are visible.
13-
Pinned to the SAME game build as ../Publicized (see that project). -->
13+
<!-- Plain (non-publicized) redist: non-public members aren't exposed, so this
14+
project reaches isDedicatedUGCInstalled via reflection. Pinned to the SAME
15+
game build as ../Publicized so only the technique differs. -->
1416
<PackageReference Include="RocketModFix.Unturned.Redist.Server" Version="3.26.3.3" />
1517

1618
<!-- UnityEngine assemblies (Unturned types derive from MonoBehaviour). -->

UnturnedRedistExample.sln

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ VisualStudioVersion = 17.0.31903.59
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Publicized", "Publicized", "{13690DB7-DDCB-4696-BED3-7D678EA970EF}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnturnedRedistExample.Publicized", "Publicized\UnturnedRedistExample.Publicized.csproj", "{896C0490-A78C-4A21-BFC1-CD7339AFC231}"
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnturnedRedistExample.Publicized", "Publicized\UnturnedRedistExample.Publicized.csproj", "{48B3A1E5-F587-42CC-93BC-91562998D480}"
99
EndProject
10-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NonPublicized", "NonPublicized", "{B69B8454-F946-7ECE-B261-90047B2E26B8}"
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Reflection", "Reflection", "{4AEFA1A0-0E78-32D8-7F79-B3573092D8DF}"
1111
EndProject
12-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnturnedRedistExample.NonPublicized", "NonPublicized\UnturnedRedistExample.NonPublicized.csproj", "{13E9644A-9A16-4900-AE18-31DF62DD8EE2}"
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnturnedRedistExample.Reflection", "Reflection\UnturnedRedistExample.Reflection.csproj", "{E27A0926-F77A-4DA3-9BEA-42C646A9DE95}"
1313
EndProject
1414
Global
1515
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -21,36 +21,36 @@ Global
2121
Release|x86 = Release|x86
2222
EndGlobalSection
2323
GlobalSection(ProjectConfigurationPlatforms) = postSolution
24-
{896C0490-A78C-4A21-BFC1-CD7339AFC231}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25-
{896C0490-A78C-4A21-BFC1-CD7339AFC231}.Debug|Any CPU.Build.0 = Debug|Any CPU
26-
{896C0490-A78C-4A21-BFC1-CD7339AFC231}.Debug|x64.ActiveCfg = Debug|Any CPU
27-
{896C0490-A78C-4A21-BFC1-CD7339AFC231}.Debug|x64.Build.0 = Debug|Any CPU
28-
{896C0490-A78C-4A21-BFC1-CD7339AFC231}.Debug|x86.ActiveCfg = Debug|Any CPU
29-
{896C0490-A78C-4A21-BFC1-CD7339AFC231}.Debug|x86.Build.0 = Debug|Any CPU
30-
{896C0490-A78C-4A21-BFC1-CD7339AFC231}.Release|Any CPU.ActiveCfg = Release|Any CPU
31-
{896C0490-A78C-4A21-BFC1-CD7339AFC231}.Release|Any CPU.Build.0 = Release|Any CPU
32-
{896C0490-A78C-4A21-BFC1-CD7339AFC231}.Release|x64.ActiveCfg = Release|Any CPU
33-
{896C0490-A78C-4A21-BFC1-CD7339AFC231}.Release|x64.Build.0 = Release|Any CPU
34-
{896C0490-A78C-4A21-BFC1-CD7339AFC231}.Release|x86.ActiveCfg = Release|Any CPU
35-
{896C0490-A78C-4A21-BFC1-CD7339AFC231}.Release|x86.Build.0 = Release|Any CPU
36-
{13E9644A-9A16-4900-AE18-31DF62DD8EE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37-
{13E9644A-9A16-4900-AE18-31DF62DD8EE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
38-
{13E9644A-9A16-4900-AE18-31DF62DD8EE2}.Debug|x64.ActiveCfg = Debug|Any CPU
39-
{13E9644A-9A16-4900-AE18-31DF62DD8EE2}.Debug|x64.Build.0 = Debug|Any CPU
40-
{13E9644A-9A16-4900-AE18-31DF62DD8EE2}.Debug|x86.ActiveCfg = Debug|Any CPU
41-
{13E9644A-9A16-4900-AE18-31DF62DD8EE2}.Debug|x86.Build.0 = Debug|Any CPU
42-
{13E9644A-9A16-4900-AE18-31DF62DD8EE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
43-
{13E9644A-9A16-4900-AE18-31DF62DD8EE2}.Release|Any CPU.Build.0 = Release|Any CPU
44-
{13E9644A-9A16-4900-AE18-31DF62DD8EE2}.Release|x64.ActiveCfg = Release|Any CPU
45-
{13E9644A-9A16-4900-AE18-31DF62DD8EE2}.Release|x64.Build.0 = Release|Any CPU
46-
{13E9644A-9A16-4900-AE18-31DF62DD8EE2}.Release|x86.ActiveCfg = Release|Any CPU
47-
{13E9644A-9A16-4900-AE18-31DF62DD8EE2}.Release|x86.Build.0 = Release|Any CPU
24+
{48B3A1E5-F587-42CC-93BC-91562998D480}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25+
{48B3A1E5-F587-42CC-93BC-91562998D480}.Debug|Any CPU.Build.0 = Debug|Any CPU
26+
{48B3A1E5-F587-42CC-93BC-91562998D480}.Debug|x64.ActiveCfg = Debug|Any CPU
27+
{48B3A1E5-F587-42CC-93BC-91562998D480}.Debug|x64.Build.0 = Debug|Any CPU
28+
{48B3A1E5-F587-42CC-93BC-91562998D480}.Debug|x86.ActiveCfg = Debug|Any CPU
29+
{48B3A1E5-F587-42CC-93BC-91562998D480}.Debug|x86.Build.0 = Debug|Any CPU
30+
{48B3A1E5-F587-42CC-93BC-91562998D480}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{48B3A1E5-F587-42CC-93BC-91562998D480}.Release|Any CPU.Build.0 = Release|Any CPU
32+
{48B3A1E5-F587-42CC-93BC-91562998D480}.Release|x64.ActiveCfg = Release|Any CPU
33+
{48B3A1E5-F587-42CC-93BC-91562998D480}.Release|x64.Build.0 = Release|Any CPU
34+
{48B3A1E5-F587-42CC-93BC-91562998D480}.Release|x86.ActiveCfg = Release|Any CPU
35+
{48B3A1E5-F587-42CC-93BC-91562998D480}.Release|x86.Build.0 = Release|Any CPU
36+
{E27A0926-F77A-4DA3-9BEA-42C646A9DE95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37+
{E27A0926-F77A-4DA3-9BEA-42C646A9DE95}.Debug|Any CPU.Build.0 = Debug|Any CPU
38+
{E27A0926-F77A-4DA3-9BEA-42C646A9DE95}.Debug|x64.ActiveCfg = Debug|Any CPU
39+
{E27A0926-F77A-4DA3-9BEA-42C646A9DE95}.Debug|x64.Build.0 = Debug|Any CPU
40+
{E27A0926-F77A-4DA3-9BEA-42C646A9DE95}.Debug|x86.ActiveCfg = Debug|Any CPU
41+
{E27A0926-F77A-4DA3-9BEA-42C646A9DE95}.Debug|x86.Build.0 = Debug|Any CPU
42+
{E27A0926-F77A-4DA3-9BEA-42C646A9DE95}.Release|Any CPU.ActiveCfg = Release|Any CPU
43+
{E27A0926-F77A-4DA3-9BEA-42C646A9DE95}.Release|Any CPU.Build.0 = Release|Any CPU
44+
{E27A0926-F77A-4DA3-9BEA-42C646A9DE95}.Release|x64.ActiveCfg = Release|Any CPU
45+
{E27A0926-F77A-4DA3-9BEA-42C646A9DE95}.Release|x64.Build.0 = Release|Any CPU
46+
{E27A0926-F77A-4DA3-9BEA-42C646A9DE95}.Release|x86.ActiveCfg = Release|Any CPU
47+
{E27A0926-F77A-4DA3-9BEA-42C646A9DE95}.Release|x86.Build.0 = Release|Any CPU
4848
EndGlobalSection
4949
GlobalSection(SolutionProperties) = preSolution
5050
HideSolutionNode = FALSE
5151
EndGlobalSection
5252
GlobalSection(NestedProjects) = preSolution
53-
{896C0490-A78C-4A21-BFC1-CD7339AFC231} = {13690DB7-DDCB-4696-BED3-7D678EA970EF}
54-
{13E9644A-9A16-4900-AE18-31DF62DD8EE2} = {B69B8454-F946-7ECE-B261-90047B2E26B8}
53+
{48B3A1E5-F587-42CC-93BC-91562998D480} = {13690DB7-DDCB-4696-BED3-7D678EA970EF}
54+
{E27A0926-F77A-4DA3-9BEA-42C646A9DE95} = {4AEFA1A0-0E78-32D8-7F79-B3573092D8DF}
5555
EndGlobalSection
5656
EndGlobal

0 commit comments

Comments
 (0)