Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 45671889c3 | |||
| 28be9bc539 | |||
| da1028388a | |||
| 7c4909b485 | |||
| 4523bf0d79 | |||
| 5c9c75e5ea | |||
| e6b57bb346 | |||
| eabfbae92d |
@@ -1,40 +0,0 @@
|
|||||||
name: Create Tag
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
tagName:
|
|
||||||
description: 'Tag name:'
|
|
||||||
type: string
|
|
||||||
required: true
|
|
||||||
run-name: "Generating changelog for Release v${{github.event.inputs.tagName}}"
|
|
||||||
jobs:
|
|
||||||
generate_changelog:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
ref: ${{ github.head_ref }}
|
|
||||||
token: ${{ secrets.TOKEN }}
|
|
||||||
- name: Setup .NET
|
|
||||||
uses: actions/setup-dotnet@v1
|
|
||||||
with:
|
|
||||||
dotnet-version: '8.0.x'
|
|
||||||
- name: Update Project Versions
|
|
||||||
run: sed -i "s/\(<Version>\)[0-9]\+\.[0-9]\+\.[0-9]\+/\1${{github.event.inputs.tagName}}/" "./OmegaLeo.HelperLib/OmegaLeo.HelperLib.csproj"
|
|
||||||
|
|
||||||
- name: Update Project Versions
|
|
||||||
run: sed -i "s/\(<Version>\)[0-9]\+\.[0-9]\+\.[0-9]\+/\1${{github.event.inputs.tagName}}/" "./OmegaLeo.HelperLib.Changelog/OmegaLeo.HelperLib.Changelog.csproj"
|
|
||||||
|
|
||||||
- name: Build and Run Changelog Generator
|
|
||||||
run: dotnet run --project "./OmegaLeo.HelperLib.ChangelogHandler/OmegaLeo.HelperLib.ChangelogHandler.csproj"
|
|
||||||
env:
|
|
||||||
UNITYFLOW_SECRET: ${{ secrets.TOKEN }}
|
|
||||||
- name: Create Tag
|
|
||||||
run: |
|
|
||||||
git config --local user.email "nunodiogo@omegaleo.pt"
|
|
||||||
git config --local user.name "Nuno Diogo"
|
|
||||||
git add .
|
|
||||||
git commit -m "Automatically generated changelog for v${{github.event.inputs.tagName}}"
|
|
||||||
git tag -a "${{ github.event.inputs.tagName }}" -m "Release ${{ github.event.inputs.tagName }}"
|
|
||||||
git push origin "${{ github.event.inputs.tagName }}"
|
|
||||||
@@ -2,7 +2,6 @@ name: Publish Nuget Packages
|
|||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
types: [created]
|
types: [created]
|
||||||
run-name: "Publish version v${{github.event.release.tag_name}} to nuget"
|
|
||||||
jobs:
|
jobs:
|
||||||
get-release:
|
get-release:
|
||||||
name: Get Release
|
name: Get Release
|
||||||
@@ -17,7 +16,7 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.TOKEN }}
|
||||||
outputs:
|
outputs:
|
||||||
upload_url: ${{ steps.get_release.outputs.upload_url }}
|
upload_url: ${{ steps.get_release.outputs.upload_url }}
|
||||||
publish-helper-lib:
|
publish_doc_helper:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [get-release]
|
needs: [get-release]
|
||||||
steps:
|
steps:
|
||||||
@@ -25,7 +24,7 @@ jobs:
|
|||||||
- name: Setup .Net Core
|
- name: Setup .Net Core
|
||||||
uses: actions/setup-dotnet@v1
|
uses: actions/setup-dotnet@v1
|
||||||
with:
|
with:
|
||||||
dotnet-version: '8.0.x'
|
dotnet-version: '7.0.x'
|
||||||
- name: Update Project Version
|
- name: Update Project Version
|
||||||
run: sed -i "s/\(<Version>\([0-9]\+\.\)\{2\}\)\([0-9]\+\)/\1${{ github.event.release.tag_name }}/" "./OmegaLeo.HelperLib/OmegaLeo.HelperLib.csproj"
|
run: sed -i "s/\(<Version>\([0-9]\+\.\)\{2\}\)\([0-9]\+\)/\1${{ github.event.release.tag_name }}/" "./OmegaLeo.HelperLib/OmegaLeo.HelperLib.csproj"
|
||||||
- name: Create Nuget Package
|
- name: Create Nuget Package
|
||||||
@@ -41,27 +40,3 @@ jobs:
|
|||||||
asset_path: ./OmegaLeo.HelperLib/bin/Release/OmegaLeo.HelperLib.${{ github.event.release.tag_name }}.nupkg
|
asset_path: ./OmegaLeo.HelperLib/bin/Release/OmegaLeo.HelperLib.${{ github.event.release.tag_name }}.nupkg
|
||||||
asset_name: OmegaLeo.HelperLib.${{ github.event.release.tag_name }}.nupkg
|
asset_name: OmegaLeo.HelperLib.${{ github.event.release.tag_name }}.nupkg
|
||||||
asset_content_type: application/zip
|
asset_content_type: application/zip
|
||||||
publish-changelog-lib:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: [ get-release ]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Setup .Net Core
|
|
||||||
uses: actions/setup-dotnet@v1
|
|
||||||
with:
|
|
||||||
dotnet-version: '8.0.x'
|
|
||||||
- name: Update Project Version
|
|
||||||
run: sed -i "s/\(<Version>\([0-9]\+\.\)\{2\}\)\([0-9]\+\)/\1${{ github.event.release.tag_name }}/" "./OmegaLeo.HelperLib.Changelog/OmegaLeo.HelperLib.Changelog.csproj"
|
|
||||||
- name: Create Nuget Package
|
|
||||||
run: dotnet pack "./OmegaLeo.HelperLib.Changelog/OmegaLeo.HelperLib.Changelog.csproj" -c Release /p:Version=${{ github.event.release.tag_name }} /p:PackageReleaseNotes="See https://github.com/omegaleo/OmegaLeo.HelperLib/releases/tag/${{ github.event.release.tag_name }}"
|
|
||||||
- name: Publish Nuget Package
|
|
||||||
run: dotnet nuget push ./OmegaLeo.HelperLib.Changelog/bin/Release/OmegaLeo.HelperLib.Changelog.${{ github.event.release.tag_name }}.nupkg --api-key ${{ secrets.nuget_api_key }} --source https://api.nuget.org/v3/index.json --skip-duplicate
|
|
||||||
- name: Upload assets to release
|
|
||||||
uses: actions/upload-release-asset@v1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ needs.get-release.outputs.upload_url }}
|
|
||||||
asset_path: ./OmegaLeo.HelperLib/bin/Release/OmegaLeo.HelperLib.Changelog.${{ github.event.release.tag_name }}.nupkg
|
|
||||||
asset_name: OmegaLeo.HelperLib.Changelog.${{ github.event.release.tag_name }}.nupkg
|
|
||||||
asset_content_type: application/zip
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
# 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.
|
|
||||||
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2024 Nuno "Omega Leo" Diogo
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
namespace OmegaLeo.HelperLib.Changelog.Models
|
|
||||||
{
|
|
||||||
public class Changelog
|
|
||||||
{
|
|
||||||
public string Target;
|
|
||||||
public string Description;
|
|
||||||
|
|
||||||
public Changelog(string target, string description)
|
|
||||||
{
|
|
||||||
Target = target;
|
|
||||||
Description = description;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
|
||||||
<ImplicitUsings>disable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<Title>Omega Leo's Helper Library - Changelog</Title>
|
|
||||||
<Authors>Nuno "Omega Leo" Diogo</Authors>
|
|
||||||
<Description>Package to help with Changelog generation</Description>
|
|
||||||
<PackageProjectUrl>https://github.com/omegaleo/HelperLib</PackageProjectUrl>
|
|
||||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
|
||||||
<RepositoryUrl>https://github.com/omegaleo/HelperLib</RepositoryUrl>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="README.md" Pack="true" PackagePath="\"/>
|
|
||||||
<None Include="CHANGELOG.md" Pack="true" PackagePath="\"/>
|
|
||||||
<None Include="LICENSE.md" Pack="true" PackagePath="\"/>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
# Omega Leo's Helper Library - Changelog
|
|
||||||
Package to help with Changelog generation by providing a new Changelog attribute and a tool to extract a dictionary of the changelogs or the markdown for CHANGELOG.md
|
|
||||||
|
|
||||||
Example attribute usage:
|
|
||||||
```cs
|
|
||||||
[Changelog("v1.0.0", "This is a test")]
|
|
||||||
[Changelog("v1.0.1", "This is another test")]
|
|
||||||
public class Test
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
```
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
|
||||||
<ImplicitUsings>disable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\OmegaLeo.HelperLib.Changelog\OmegaLeo.HelperLib.Changelog.csproj" />
|
|
||||||
<ProjectReference Include="..\OmegaLeo.HelperLib\OmegaLeo.HelperLib.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
// See https://aka.ms/new-console-template for more information
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Reflection;
|
|
||||||
using GameDevLibrary.Helpers;
|
|
||||||
using OmegaLeo.HelperLib.Changelog.Models;
|
|
||||||
using OmegaLeo.HelperLib.Changelog.Tools;
|
|
||||||
|
|
||||||
var root = GetSolutionRoot();
|
|
||||||
|
|
||||||
var changelogs = new Dictionary<string, Assembly>()
|
|
||||||
{
|
|
||||||
{Path.Join(root, "OmegaLeo.HelperLib.Changelog", "CHANGELOG.md"), typeof(Changelog).Assembly},
|
|
||||||
{Path.Join(root, "OmegaLeo.HelperLib", "CHANGELOG.md"), typeof(BenchmarkUtility).Assembly},
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach (var changelog in changelogs)
|
|
||||||
{
|
|
||||||
GenerateChangelog(changelog.Key, changelog.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GenerateChangelog(string path, Assembly libraryAssembly)
|
|
||||||
{
|
|
||||||
var changelogMarkdown = ChangelogTool.GetMarkdown(libraryAssembly);
|
|
||||||
|
|
||||||
File.WriteAllText(path,changelogMarkdown);
|
|
||||||
}
|
|
||||||
|
|
||||||
static string GetSolutionRoot()
|
|
||||||
{
|
|
||||||
string dir = AppContext.BaseDirectory;
|
|
||||||
|
|
||||||
while (!string.IsNullOrEmpty(dir))
|
|
||||||
{
|
|
||||||
if (Directory.GetFiles(dir, "*.sln").Length > 0)
|
|
||||||
return dir; // Found the solution root
|
|
||||||
|
|
||||||
dir = Directory.GetParent(dir)?.FullName; // Move up a directory
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Exception("Solution root not found.");
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OmegaLeo.HelperLib.Changelog\OmegaLeo.HelperLib.Changelog.csproj" />
|
|
||||||
<ProjectReference Include="..\OmegaLeo.HelperLib.Git\OmegaLeo.HelperLib.Git.csproj" />
|
<ProjectReference Include="..\OmegaLeo.HelperLib.Git\OmegaLeo.HelperLib.Git.csproj" />
|
||||||
<ProjectReference Include="..\OmegaLeo.HelperLib\OmegaLeo.HelperLib.csproj" />
|
<ProjectReference Include="..\OmegaLeo.HelperLib\OmegaLeo.HelperLib.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -2,11 +2,8 @@
|
|||||||
|
|
||||||
// /media/omegaleo/Development/Library Dev/HelperLib
|
// /media/omegaleo/Development/Library Dev/HelperLib
|
||||||
|
|
||||||
using System.Reflection;
|
|
||||||
using GameDevLibrary.Extensions;
|
using GameDevLibrary.Extensions;
|
||||||
using GameDevLibrary.Helpers;
|
|
||||||
using LibGit2Sharp;
|
using LibGit2Sharp;
|
||||||
using OmegaLeo.HelperLib.Changelog.Tools;
|
|
||||||
using OmegaLeo.HelperLib.Git;
|
using OmegaLeo.HelperLib.Git;
|
||||||
using OmegaLeo.HelperLib.Git.Models;
|
using OmegaLeo.HelperLib.Git.Models;
|
||||||
|
|
||||||
@@ -20,8 +17,6 @@ if (repo.IsNullOrEmpty())
|
|||||||
|
|
||||||
var git = new GitClient(repo);
|
var git = new GitClient(repo);
|
||||||
|
|
||||||
var result = BenchmarkUtility.Record(() =>
|
|
||||||
{
|
|
||||||
var changes = git.GetChanges();
|
var changes = git.GetChanges();
|
||||||
|
|
||||||
if (changes.FolderName.IsNotNullOrEmpty())
|
if (changes.FolderName.IsNotNullOrEmpty())
|
||||||
@@ -47,8 +42,7 @@ var result = BenchmarkUtility.Record(() =>
|
|||||||
msg = Console.ReadLine();
|
msg = Console.ReadLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
var signature = new Signature("Nuno 'Omega Leo' Diogo", "nunodiogo@omegaleo.pt",
|
var signature = new Signature("Nuno 'Omega Leo' Diogo", "nunodiogo@omegaleo.pt", DateTimeOffset.Now);
|
||||||
DateTimeOffset.Now);
|
|
||||||
git.Commit(msg, signature);
|
git.Commit(msg, signature);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -68,9 +62,6 @@ var result = BenchmarkUtility.Record(() =>
|
|||||||
{
|
{
|
||||||
Console.WriteLine("No changes found in specified repository");
|
Console.WriteLine("No changes found in specified repository");
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
Console.WriteLine($"Time for checking for changes: {result} ms");
|
|
||||||
|
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
using OmegaLeo.HelperLib.Changelog.Attributes;
|
|
||||||
|
|
||||||
namespace OmegaLeo.HelperLib.ConsoleApp;
|
|
||||||
|
|
||||||
[Changelog("v1.0.0", "Test")]
|
|
||||||
[Changelog("v1.0.1", "Test 1")]
|
|
||||||
public class TestClass
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -6,10 +6,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OmegaLeo.HelperLib.Git", "O
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OmegaLeo.HelperLib.ConsoleApp", "OmegaLeo.HelperLib.ConsoleApp\OmegaLeo.HelperLib.ConsoleApp.csproj", "{3B77B177-FD47-470A-B0EF-01EF8B30CE09}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OmegaLeo.HelperLib.ConsoleApp", "OmegaLeo.HelperLib.ConsoleApp\OmegaLeo.HelperLib.ConsoleApp.csproj", "{3B77B177-FD47-470A-B0EF-01EF8B30CE09}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OmegaLeo.HelperLib.Changelog", "OmegaLeo.HelperLib.Changelog\OmegaLeo.HelperLib.Changelog.csproj", "{378D8125-66B5-42B8-9881-33F951E5E04A}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OmegaLeo.HelperLib.ChangelogHandler", "OmegaLeo.HelperLib.ChangelogHandler\OmegaLeo.HelperLib.ChangelogHandler.csproj", "{359536F7-02DE-43E9-A383-D83853227B0F}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -28,13 +24,5 @@ Global
|
|||||||
{3B77B177-FD47-470A-B0EF-01EF8B30CE09}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{3B77B177-FD47-470A-B0EF-01EF8B30CE09}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{3B77B177-FD47-470A-B0EF-01EF8B30CE09}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{3B77B177-FD47-470A-B0EF-01EF8B30CE09}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{3B77B177-FD47-470A-B0EF-01EF8B30CE09}.Release|Any CPU.Build.0 = Release|Any CPU
|
{3B77B177-FD47-470A-B0EF-01EF8B30CE09}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{378D8125-66B5-42B8-9881-33F951E5E04A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{378D8125-66B5-42B8-9881-33F951E5E04A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{378D8125-66B5-42B8-9881-33F951E5E04A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{378D8125-66B5-42B8-9881-33F951E5E04A}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{359536F7-02DE-43E9-A383-D83853227B0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{359536F7-02DE-43E9-A383-D83853227B0F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{359536F7-02DE-43E9-A383-D83853227B0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{359536F7-02DE-43E9-A383-D83853227B0F}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASafeFileHandle_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Fomegaleo_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fc21672d0d37542808f219d7d1f059dc1b2e000_003Faf_003Fbed3a9b4_003FSafeFileHandle_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Fomegaleo_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fc61cc76f205b4535a5b4f40700c07900b2d200_003Fe5_003F6b3ec67e_003FThrowHelper_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Fomegaleo_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fc61cc76f205b4535a5b4f40700c07900b2d200_003Fe5_003F6b3ec67e_003FThrowHelper_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATreeChanges_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Fomegaleo_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F7478b0ce6362feb345e793626f5c504bd9d7ffeb748226521658c85fc4e29_003FTreeChanges_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATreeChanges_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Fomegaleo_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F7478b0ce6362feb345e793626f5c504bd9d7ffeb748226521658c85fc4e29_003FTreeChanges_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATreeEntryChanges_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Fomegaleo_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F2b7912eaeadb1d9a91a3f891a244b5cd4a856d9dde42694e941ee6a2994_003FTreeEntryChanges_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATreeEntryChanges_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003Fhome_003Fomegaleo_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F2b7912eaeadb1d9a91a3f891a244b5cd4a856d9dde42694e941ee6a2994_003FTreeEntryChanges_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# Changelog
|
|
||||||
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Cryptography;
|
|
||||||
|
|
||||||
namespace GameDevLibrary.Extensions
|
namespace GameDevLibrary.Extensions
|
||||||
{
|
{
|
||||||
@@ -118,30 +117,5 @@ namespace GameDevLibrary.Extensions
|
|||||||
{
|
{
|
||||||
return array[currentIndex++ % array.Count];
|
return array[currentIndex++ % array.Count];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Shuffle around items in a list.
|
|
||||||
/// Code obtained from https://stackoverflow.com/a/1262619
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="list"></param>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
public static IList<T> Shuffle<T>(this IList<T> list)
|
|
||||||
{
|
|
||||||
RNGCryptoServiceProvider provider = new RNGCryptoServiceProvider();
|
|
||||||
int n = list.Count;
|
|
||||||
while (n > 1)
|
|
||||||
{
|
|
||||||
byte[] box = new byte[1];
|
|
||||||
do provider.GetBytes(box);
|
|
||||||
while (!(box[0] < n * (Byte.MaxValue / n)));
|
|
||||||
int k = (box[0] % n);
|
|
||||||
n--;
|
|
||||||
(list[k], list[n]) = (list[n], list[k]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
|
|
||||||
namespace GameDevLibrary.Helpers
|
|
||||||
{
|
|
||||||
public class BenchmarkUtility
|
|
||||||
{
|
|
||||||
private static Dictionary<string, List<long>> _benchmarks = new Dictionary<string, List<long>>();
|
|
||||||
private static Dictionary<string, Stopwatch> _stopwatches = new Dictionary<string, Stopwatch>();
|
|
||||||
|
|
||||||
private static Stopwatch GetStopwatch(string key)
|
|
||||||
{
|
|
||||||
Stopwatch stopwatch = new Stopwatch();
|
|
||||||
|
|
||||||
if (_stopwatches.TryGetValue(key, out stopwatch))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
stopwatch = new Stopwatch();
|
|
||||||
_stopwatches.Add(key, stopwatch);
|
|
||||||
}
|
|
||||||
|
|
||||||
return stopwatch;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static long Record(Action actionToRecord)
|
|
||||||
{
|
|
||||||
var stopwatch = new Stopwatch();
|
|
||||||
stopwatch.Start();
|
|
||||||
|
|
||||||
actionToRecord.Invoke();
|
|
||||||
|
|
||||||
stopwatch.Stop();
|
|
||||||
return stopwatch.ElapsedMilliseconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static long RecordAndSaveToResults(string key, Action actionToRecord)
|
|
||||||
{
|
|
||||||
var stopwatch = new Stopwatch();
|
|
||||||
stopwatch.Start();
|
|
||||||
|
|
||||||
actionToRecord.Invoke();
|
|
||||||
|
|
||||||
stopwatch.Stop();
|
|
||||||
|
|
||||||
if (!_benchmarks.ContainsKey(key))
|
|
||||||
{
|
|
||||||
_benchmarks[key] = new List<long>();
|
|
||||||
}
|
|
||||||
|
|
||||||
_benchmarks[key].Add(stopwatch.ElapsedMilliseconds);
|
|
||||||
|
|
||||||
return stopwatch.ElapsedMilliseconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Start(string key)
|
|
||||||
{
|
|
||||||
GetStopwatch(key).Restart();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Stop(string key)
|
|
||||||
{
|
|
||||||
if (!_benchmarks.ContainsKey(key))
|
|
||||||
{
|
|
||||||
_benchmarks[key] = new List<long>();
|
|
||||||
}
|
|
||||||
|
|
||||||
GetStopwatch(key).Stop();
|
|
||||||
_benchmarks[key].Add(GetStopwatch(key).ElapsedMilliseconds);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<long> GetResults(string key)
|
|
||||||
{
|
|
||||||
return _benchmarks.ContainsKey(key) ? _benchmarks[key] : new List<long>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ClearResults()
|
|
||||||
{
|
|
||||||
_benchmarks.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Dictionary<string, List<long>> GetAllResults()
|
|
||||||
{
|
|
||||||
return new Dictionary<string, List<long>>(_benchmarks);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2024 Nuno "Omega Leo" Diogo
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace GameDevLibrary.Models
|
|
||||||
{
|
|
||||||
public abstract class InstancedObject<T> where T : class
|
|
||||||
{
|
|
||||||
public static T Instance { get; private set; }
|
|
||||||
|
|
||||||
protected InstancedObject()
|
|
||||||
{
|
|
||||||
if (Instance != null)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"An instance of {typeof(T).Name} already exists.");
|
|
||||||
}
|
|
||||||
|
|
||||||
Instance = this as T;
|
|
||||||
if (Instance == null)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"Failed to cast {GetType().Name} to {typeof(T).Name}.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
~InstancedObject()
|
|
||||||
{
|
|
||||||
if (Instance == this)
|
|
||||||
{
|
|
||||||
Instance = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -82,12 +82,9 @@ namespace GameDevLibrary.Models
|
|||||||
public NeoDictionaryItem<TKey, TValue>? LastOrDefault(Func<NeoDictionaryItem<TKey, TValue>, bool> predicate) =>
|
public NeoDictionaryItem<TKey, TValue>? LastOrDefault(Func<NeoDictionaryItem<TKey, TValue>, bool> predicate) =>
|
||||||
Items.LastOrDefault(predicate);
|
Items.LastOrDefault(predicate);
|
||||||
|
|
||||||
public IEnumerable<NeoDictionaryItem<TKey, TValue>> Select(Func<NeoDictionaryItem<TKey, TValue>, NeoDictionaryItem<TKey, TValue>> selector) =>
|
public IEnumerable<NeoDictionaryItem<TKey, TValue>> Select<TResult>(Func<NeoDictionaryItem<TKey, TValue>, NeoDictionaryItem<TKey, TValue>> selector) =>
|
||||||
Items.Select(selector);
|
Items.Select(selector);
|
||||||
|
|
||||||
public int IndexOf(NeoDictionaryItem<TKey, TValue> selector) =>
|
|
||||||
Items.IndexOf(selector);
|
|
||||||
|
|
||||||
public void Remove(TKey key)
|
public void Remove(TKey key)
|
||||||
{
|
{
|
||||||
var index = Items.FindIndex(x => x.Key.Equals(key));
|
var index = Items.FindIndex(x => x.Key.Equals(key));
|
||||||
|
|||||||
@@ -4,10 +4,9 @@
|
|||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<RootNamespace>GameDevLibrary</RootNamespace>
|
<RootNamespace>GameDevLibrary</RootNamespace>
|
||||||
<Version>1.1.1</Version>
|
<Version>0.0.2</Version>
|
||||||
<Title>Omega Leo's Helper Library</Title>
|
<Title>Omega Leo's Helper Library</Title>
|
||||||
<Authors>Nuno "Omega Leo" Diogo</Authors>
|
<Authors>Nuno "Omega Leo" Diogo</Authors>
|
||||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
|
||||||
<PackageProjectUrl>https://github.com/omegaleo/HelperLib</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/omegaleo/HelperLib</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://github.com/omegaleo/HelperLib</RepositoryUrl>
|
<RepositoryUrl>https://github.com/omegaleo/HelperLib</RepositoryUrl>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@@ -16,10 +15,4 @@
|
|||||||
<PackageReference Include="NetFlow.DocumentationHelper.Library" Version="1.1.2" />
|
<PackageReference Include="NetFlow.DocumentationHelper.Library" Version="1.1.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="README.md" Pack="true" PackagePath="\"/>
|
|
||||||
<None Include="CHANGELOG.md" Pack="true" PackagePath="\"/>
|
|
||||||
<None Include="LICENSE.md" Pack="true" PackagePath="\"/>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
# Omega Leo's Helper Lib
|
|
||||||
Reference in New Issue
Block a user