Skip to content

Commit

Permalink
ToString() should also include the Guid for plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
sven-n committed Dec 13, 2023
1 parent ef3b746 commit bd6b7a7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// <copyright file="PlugInConfiguration.Custom.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>

namespace MUnique.OpenMU.Persistence.EntityFramework.Model;

/// <summary>
/// Custom additions to the generated <see cref="PlugInConfiguration"/>.
/// </summary>
internal partial class PlugInConfiguration
{
/// <inheritdoc />
public override string ToString()
{
return $"{base.ToString()} ({this.Id})";
}
}
23 changes: 17 additions & 6 deletions src/PlugIns/PlugInConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,26 @@ public string? CustomConfiguration
}
}

/// <summary>
/// Gets the (display) name of this plugin.
/// </summary>
public string Name
{
get
{
var plugInType = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(assembly => assembly.DefinedTypes)
.FirstOrDefault(t => t.GUID == this.TypeId);
var plugInAttribute = plugInType?.GetCustomAttribute<PlugInAttribute>();

return plugInAttribute?.Name ?? this.TypeId.ToString();
}
}

/// <inheritdoc/>
public override string ToString()
{
var plugInType = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(assembly => assembly.DefinedTypes)
.FirstOrDefault(t => t.GUID == this.TypeId);
var plugInAttribute = plugInType?.GetCustomAttribute<PlugInAttribute>();

return plugInAttribute?.Name ?? this.TypeId.ToString();
return this.Name;
}

/// <summary>
Expand Down

0 comments on commit bd6b7a7

Please sign in to comment.