Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Name and Version const and use them in the plugin attribute #2

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions BepInEx.AutoPlugin/AutoPluginGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void Execute(GeneratorExecutionContext context)
var source = SourceText.From($@"// <auto-generated />
namespace {typeSymbol.ContainingNamespace.ToDisplayString()}
{{
[{attributeName}({typeSymbol.Name}.Id, ""{name}"", ""{version}"")]
[{attributeName}({typeSymbol.Name}.Id, {typeSymbol.Name}.Name, {typeSymbol.Name}.Version)]
public partial class {typeSymbol.Name}
{{
/// <summary>
Expand All @@ -133,12 +133,12 @@ public partial class {typeSymbol.Name}
/// <summary>
/// Gets the name of the <see cref=""{typeSymbol.Name}""/>.
/// </summary>
public static string Name => ""{name}"";
public const Name = ""{name}"";

/// <summary>
/// Gets the version of the <see cref=""{typeSymbol.Name}""/>.
/// </summary>
public static string Version => ""{version}"";
public const Version = ""{version}"";
}}
}}
", Encoding.UTF8);
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public partial class ExamplePlugin : BaseUnityPlugin
into

```cs
[BepInEx.BepInPlugin(ExamplePlugin.Id, "ExamplePlugin", "0.1.0")]
[BepInEx.BepInPlugin(ExamplePlugin.Id, ExamplePlugin.Name, ExamplePlugin.Version)]
public class ExamplePlugin : BaseUnityPlugin
{
public const string Id = "com.example.ExamplePlugin";
public static string Name => "ExamplePlugin";
public static string Version => "0.1.0";
public const string Name = "ExamplePlugin";
public const string Version = "0.1.0";
}
```
Loading