Skip to content

Conversation

@Redforce04
Copy link

Changes

Styling

  • Implemented / Fixed Stylecop formatting.
  • Refactored code for full Stylecop Compliance. (0 error / 0 warning builds)
  • Added Nullable warnings. Many code items now have nullable markers.

Project File (.csproj)

Note: Most of these changes were based off of a standard template I have. Some other small details may have changed because of this, like the build output path or embedded debug pdbs.

  • Converted to Microsoft.NET.Sdk. (Cleaner and easier to use)
  • Moved some files into the Resources folder with linking.
  • Added Private="False" & ExcludeAssets="RUNTIME" flags to prevent the output directory from being flooded with dependencies. (This can prevent dependencies from showing up in the folder but they can still be manually installed in the server).

Packages

  • Changed some references over to NuGet packages. (LabAPI, Harmony)
  • Added BepInEx NuGet repository (for the Publicizer)
  • Added BepInEx AssemblyPublicizer to auto-publicize AssemblyCSharp without any manual publicizing required.
  • Added HarmonyX instead of a generic harmony reference file.*

*Note: Occasionally HarmonyX will fight older HarmonyLib dependencies. HarmonyX is the latest harmony version and is a fork of the original project. It still contains all the stubs for older versions of harmony to use. Serverhosts should ensure the version of Harmony is HarmonyX to prevent any potential issues.

Feel free to let me know of any questions or issues. I would highly recommend testing these changes before publicly releasing this as some nullable items may throw NullReferenceExceptions.

Copy link
Owner

@skyfr0676 skyfr0676 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't accept your PR for a lot of reasons including:

  • I can't compile (idk why your mmoved the whole "Compile" sequence in the .csproj)
  • NET v4.8.1 used instead of NET v4.8
  • Used file-scoped namespace instead of block-scoped namespace
  • Your name is in the "companyName"
  • Weird unused references added (like BepInEx)
    Change this and i will accept the PR (unless i see some other things to change)

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<TargetFramework>net481</TargetFramework>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change this to net48

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really not compatible on linux? The download seems to be available in the same way that net48 is released. Otherwise it shouldn't make much of a difference. This is just how I have my personal plugin template.
https://dotnet.microsoft.com/en-us/download/dotnet-framework/net481

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just a personnal thing, because most of EXILED plugins use .NET 4.8
I remember HSM used .NET 4.8.1 and it was not compatible with .NET 4.8 (most of plugins) projects, so i prefere to use .NET 4.8 instead of .NET 4.8.1

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I am normally only developing single server projects so I just use 4.8.1 for everything. Because this is an API it should be the lower version of the two allowing either to use it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ?

Comment on lines +53 to +54
<PackageReference Include="BepInEx.AssemblyPublicizer" Version="0.5.0-beta.1" ExcludeAssets="RUNTIME" />
<PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.5.0-beta.1" ExcludeAssets="RUNTIME" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what is this, can you explain to me please ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevents developers from having to manually publicize documents. Saves time and effort making contributions easier.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice how Publicize="True". This automatically publicizes any assembly with Publicize="True".

<Reference Include="Assembly-CSharp" HintPath="$(EXILED_REFERENCES)\Assembly-CSharp-firstpass.dll" Private="False" Publicize="True"/>

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooooh i see, thats a good thing !

<PackageReference Include="BepInEx.AssemblyPublicizer" Version="0.5.0-beta.1" ExcludeAssets="RUNTIME" />
<PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.5.0-beta.1" ExcludeAssets="RUNTIME" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<PackageReference Include="HarmonyX" Version="2.14.0" ExcludeAssets="RUNTIME" />
<PackageReference Include="MonoMod.Backports" Version="1.1.2" ExcludeAssets="RUNTIME" />
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HarmonyX is a modern fork which is an updated form of HarmonyLib. It maintains pretty much all HarmonyLib api endpoints but adds helpful items for transpilers. Generally speaking it is better maintained, and much cleaner for large patches.

Also it is from my plugin template.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BepInEx.AssemblyPublicizer - Prevents developers from having to manually publicize documents. Saves time and effort making contributions easier.

HarmonyX - More updated form of Harmony that makes patching safer and easier and fixes some of the older flaws of harmony.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HarmonyX is a modern fork which is an updated form of HarmonyLib. It maintains pretty much all HarmonyLib api endpoints but adds helpful items for transpilers. Generally speaking it is better maintained, and much cleaner for large patches.

Also it is from my plugin template.

but it's still use the default 0Harmony exiled dependency, right ?
Because i used HarmonyLib for this (to not have any dependance for EXILED version)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose with exiled problems may arise. Technically because HarmonyX contains all of the original stubs of HarmonyLib as long as players add HarmonyX instead of HarmonyLib it should work just fine. However if they do not do this problems could occur. It is likely best to remove it. On my servers I just use HarmonyX.

"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
"settings": {
"documentationRules": {
"companyName": "Skyfr0676 and Redforce04",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove "and Redforce04"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, I didn't know what you wanted the license to be. I would also recommend adding a license file.

@Redforce04
Copy link
Author

Redforce04 commented Jul 1, 2025

I can't compile (idk why your mmoved the whole "Compile" sequence in the .csproj)

This is because I converted the .csproj file to DotNet SDK style. It is cleaner but also has different csproj conventions meaning some of the XML is moved around.

Used file-scoped namespace instead of block-scoped namespace.

Can Do. I just had this in my default plugin template which is what this .csproj project sdk stems from.

Your name is in the "companyName"

Same thing with the previous item, stemmed from the .csproj project sdk template that I utilized.

NET v4.8.1 used instead of NET v4.8

I'm still confused as to why Net v4.8 works but not Net v4.8.1. I suppose this shouldn't change anything otherwise though.

Weird unused references added (like BepInEx)

The references are used to make contributions easier by removing the need to manually publicize items. Bepinex publicizer effectively is similar to an auto-publicizing source generator which automatically does the publicizing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants