Dev changes (#3)
* Fixed dependency * Updates to NeoDictionary * Changes to NeoDictionary * Started working on a Git implementation to integrate into Game Engines in the future * Added commit functionality to the git library * New changes * Added select for NeoDictionary.cs * Fixed issue with previous new method * Added a Benchmarking Tool to be used mostly in game engines * Added IndexOf to NeoDictionary.cs * Added new method for BenchmarkUtility.cs * added an instacedobject class * Added a new shuffle method for lists * fixed return type * Added new Changelog generator
This commit was merged in pull request #3.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
|
||||
namespace OmegaLeo.HelperLib.Changelog.Attributes
|
||||
{
|
||||
[Changelog("v1.0.0", "Created ChangelogAttribute to be used to register changes in the code.")]
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = true)]
|
||||
public class ChangelogAttribute : Attribute
|
||||
{
|
||||
public string Version { get; }
|
||||
public string Description { get; }
|
||||
|
||||
public ChangelogAttribute(string version, string description)
|
||||
{
|
||||
Version = version;
|
||||
Description = description;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# Changelog
|
||||
|
||||
## Version v1.0.0
|
||||
|
||||
- **Class: ChangelogTool**: Created the class ChangelogTool to extract changelogs via attributes
|
||||
- **Class: ChangelogAttribute**: Created ChangelogAttribute to be used to register changes in the code.
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace OmegaLeo.HelperLib.Changelog.Models
|
||||
{
|
||||
public class Changelog
|
||||
{
|
||||
public string Target;
|
||||
public string Description;
|
||||
|
||||
public Changelog(string target, string description)
|
||||
{
|
||||
Target = target;
|
||||
Description = description;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,63 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using OmegaLeo.HelperLib.Changelog.Attributes;
|
||||
|
||||
namespace OmegaLeo.HelperLib.Changelog.Tools
|
||||
{
|
||||
[Changelog("v1.0.0", "Created the class ChangelogTool to extract changelogs via attributes")]
|
||||
public class ChangelogTool
|
||||
{
|
||||
public static Dictionary<string, List<Models.Changelog>> ExtractChangelog(Assembly assembly)
|
||||
{
|
||||
var changelogByVersion = new Dictionary<string, List<Models.Changelog>>();
|
||||
|
||||
foreach (var type in assembly.GetTypes())
|
||||
{
|
||||
foreach (var attr in type.GetCustomAttributes<ChangelogAttribute>())
|
||||
{
|
||||
AddChangelogEntry(changelogByVersion, attr.Version, $"Class: {type.Name}", attr.Description);
|
||||
}
|
||||
|
||||
foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static))
|
||||
{
|
||||
foreach (var attr in method.GetCustomAttributes<ChangelogAttribute>())
|
||||
AddChangelogEntry(changelogByVersion, attr.Version, $"Method: {type.Name}.{method.Name}()", attr.Description);
|
||||
}
|
||||
}
|
||||
|
||||
changelogByVersion = new Dictionary<string, List<Models.Changelog>>(changelogByVersion.OrderByDescending(x => x.Key));
|
||||
|
||||
return changelogByVersion;
|
||||
}
|
||||
|
||||
public static string GetMarkdown(Assembly assembly)
|
||||
{
|
||||
var changelog = ExtractChangelog(assembly);
|
||||
|
||||
var sb = new StringBuilder();
|
||||
|
||||
sb.AppendLine("# Changelog\n");
|
||||
foreach (var version in changelog)
|
||||
{
|
||||
sb.AppendLine($"## Version {version.Key}\n");
|
||||
foreach (var entry in version.Value)
|
||||
{
|
||||
sb.AppendLine($"- **{entry.Target}**: {entry.Description}");
|
||||
}
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static void AddChangelogEntry(Dictionary<string, List<Models.Changelog>> changelog, string version, string target, string description)
|
||||
{
|
||||
if (!changelog.ContainsKey(version))
|
||||
changelog[version] = new List<Models.Changelog>();
|
||||
|
||||
changelog[version].Add(new Models.Changelog(target, description));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user