Skip to content

Commit

Permalink
Merge pull request #5 from Digitalroot-Valheim/develop
Browse files Browse the repository at this point in the history
Update to platform agnostic thread safe Logger
  • Loading branch information
Digitalroot authored Aug 1, 2021
2 parents ed45dc5 + b5856aa commit 17da265
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 39 deletions.
4 changes: 2 additions & 2 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name-template: 'v$RESOLVED_VERSION'
name-template: 'Release v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
template: |
# What's Changed
## What's Changed
$CHANGES
categories:
- title: 'Breaking'
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI
on:
push:
paths:
- 'src/**'
- '.github/workflows/**'
pull_request:
jobs:
build:
if: ${{ false }} # disable for now
runs-on: ubuntu-latest
env:
SLN_FILE_NAME: Digitalroot.Valheim.PluginInfo.sln
NUGET_AUTH_TOKEN: ${{secrets.NUGET_PAT}}
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install dotnet
uses: actions/setup-dotnet@v1
with:
source-url: https://nuget.pkg.github.com/Digitalroot-Valheim/index.json
- name: Restore packages
run: dotnet restore src/${{ env.SLN_FILE_NAME }} --nologo
- name: Build
run: dotnet build src/${{ env.SLN_FILE_NAME }} -c Release --no-restore --nologo
- name: Test
run: dotnet test src/${{ env.SLN_FILE_NAME }} -c Release --no-build -l "trx;LogFileName=test-results.trx" --nologo
- uses: actions/upload-artifact@v2
if: always()
with:
path: ./src/UnitTests/TestResults/test-results.trx
name: test-results
retention-days: 1
42 changes: 42 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: NuGet Package
on:
push:
branches:
- main # Default release branch
paths:
- 'src/**'
- '.github/workflows/**'
jobs:
deploy:
if: ${{ false }} # disable for now
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
env:
SLN_FILE_NAME: Digitalroot.Valheim.PluginInfo.sln
PROJ: Digitalroot.Valheim.PluginInfo
NUGET_AUTH_TOKEN: ${{secrets.NUGET_PAT}}
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
#dotnet-version: '3.1.x' # SDK Version to use.
source-url: https://nuget.pkg.github.com/Digitalroot-Valheim/index.json
- name: Check out repository code
uses: actions/checkout@v2
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- name: Restore packages
run: dotnet restore src/${{ env.SLN_FILE_NAME }} --nologo
- name: Build
run: dotnet build src/${{ env.SLN_FILE_NAME }} -c Release --no-restore --nologo
- name: Test
run: dotnet test src/${{ env.SLN_FILE_NAME }} -c Release --no-build --nologo
- name: Create the package
run: dotnet pack src/${{ env.PROJ }}/${{ env.PROJ }}.csproj -c Release --no-restore --no-build --nologo
- name: Publish package to Digitalroot-Valheim nuget repository
run: dotnet nuget push src/${{ env.PROJ }}/bin/Release/*.nupkg --skip-duplicate
21 changes: 21 additions & 0 deletions .github/workflows/test-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: 'Test Report'
on:
workflow_run:
workflows: ['CI'] # runs after CI workflow
types:
- completed
jobs:
report:
if: ${{ false }} # disable for now
runs-on: ubuntu-latest
steps:
- uses: dorny/test-reporter@v1
with:
artifact: test-results # artifact name
name: NUnit Tests # Name of the check run which will be created
path: '*.trx' # Path to test results (inside artifact .zip)
reporter: dotnet-trx # Format of test results
path-replace-backslashes: 'true'
list-suites: 'all'
list-tests: 'failed'
max-annotations: '50'
17 changes: 16 additions & 1 deletion src/Digitalroot.Valheim.PluginInfo.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,23 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B6C936B0-4E6A-4AB8-A3FF-5AA2C1A0C59C}"
ProjectSection(SolutionItems) = preProject
..\.gitignore = ..\.gitignore
..\.github\workflows\drafter.yml = ..\.github\workflows\drafter.yml
..\LICENSE = ..\LICENSE
..\README.md = ..\README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{89E8E94A-90F4-4FD3-B72F-C558A9ED8BF9}"
ProjectSection(SolutionItems) = preProject
..\.github\release-drafter.yml = ..\.github\release-drafter.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{0B780DC6-CDC0-4FE8-93BD-2945C9B0B8A6}"
ProjectSection(SolutionItems) = preProject
..\.github\workflows\ci.yml = ..\.github\workflows\ci.yml
..\.github\workflows\drafter.yml = ..\.github\workflows\drafter.yml
..\.github\workflows\publish.yml = ..\.github\workflows\publish.yml
..\.github\workflows\test-report.yml = ..\.github\workflows\test-report.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -28,6 +39,10 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{89E8E94A-90F4-4FD3-B72F-C558A9ED8BF9} = {B6C936B0-4E6A-4AB8-A3FF-5AA2C1A0C59C}
{0B780DC6-CDC0-4FE8-93BD-2945C9B0B8A6} = {89E8E94A-90F4-4FD3-B72F-C558A9ED8BF9}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DBD9181E-33F5-4CBE-9C7D-06A9FDCEF711}
EndGlobalSection
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\ILMerge.Fody.1.16.0\build\ILMerge.Fody.props" Condition="Exists('..\packages\ILMerge.Fody.1.16.0\build\ILMerge.Fody.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand All @@ -13,6 +13,7 @@
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<LangVersion>latest</LangVersion>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
Expand Down Expand Up @@ -80,15 +81,15 @@
<HintPath>..\packages\Pfhoenix.Valheim.ModProjectReferences.1.0.6\lib\net46\bepinex.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Digitalroot.Valheim.Common.AssemblyInfo, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Digitalroot.Valheim.Common.AssemblyInfo.1.0.0\lib\net462\Digitalroot.Valheim.Common.AssemblyInfo.dll</HintPath>
<Reference Include="Digitalroot.Valheim.Common.AssemblyInfo, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Digitalroot.Valheim.Common.AssemblyInfo.1.0.1\lib\net462\Digitalroot.Valheim.Common.AssemblyInfo.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Digitalroot.Valheim.Common.Json, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Digitalroot.Valheim.Common.Json.1.0.2\lib\net462\Digitalroot.Valheim.Common.Json.dll</HintPath>
</Reference>
<Reference Include="Digitalroot.Valheim.Common.Log, Version=1.0.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Digitalroot.Valheim.Common.Log.1.0.3\lib\net462\Digitalroot.Valheim.Common.Log.dll</HintPath>
<Reference Include="Digitalroot.Valheim.Common.Log, Version=1.1.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Digitalroot.Valheim.Common.Log.1.1.4\lib\net462\Digitalroot.Valheim.Common.Log.dll</HintPath>
</Reference>
<Reference Include="fastJSON, Version=2.4.0.0, Culture=neutral, PublicKeyToken=6b75a806b86095cd, processorArchitecture=MSIL">
<HintPath>..\packages\fastJSON.2.4.0.4\lib\net40\fastJSON.dll</HintPath>
Expand Down
61 changes: 34 additions & 27 deletions src/Digitalroot.Valheim.PluginInfo/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,30 @@
namespace Digitalroot.Valheim.PluginInfo
{
[BepInPlugin(Guid, Name, Version)]
public class Main : BaseUnityPlugin
public class Main : BaseUnityPlugin, ITraceableLogging
{
public const string Version = "1.0.2";
public const string Name = "Digitalroot Plug-in Info";
private const string Guid = "digitalroot.mods.plugininfo";
public const string Namespace = nameof(PluginInfo);
private Harmony _harmony;
public const string Version = "1.1.0";
public const string Name = "Digitalroot Plug-in Info";
// ReSharper disable once MemberCanBePrivate.Global
public const string Guid = "digitalroot.mods.plugininfo";
public const string Namespace = "Digitalroot.Valheim." + nameof(PluginInfo);
public static Main Instance;

#region Implementation of ITraceableLogging

/// <inheritdoc />
public string Source => Namespace;

#endregion

public Main()
{
Log.SetSource(AssemblyInfo.Company);
#if DEBUG
Log.EnableTrace();
Log.RegisterSource(this, true);
#endif

Log.Trace($"{GetType().Namespace}.{GetType().Name}.{MethodBase.GetCurrentMethod().Name}()");
Log.Trace(this, $"{GetType().Namespace}.{GetType().Name}.{MethodBase.GetCurrentMethod().Name}()");
Instance = this;
}

Expand All @@ -37,47 +44,47 @@ private void Awake()
[UsedImplicitly]
private void OnDestroy()
{
Log.Trace($"{GetType().Namespace}.{GetType().Name}.{MethodBase.GetCurrentMethod().Name}()");
Log.Trace(this, $"{GetType().Namespace}.{GetType().Name}.{MethodBase.GetCurrentMethod().Name}()");
_harmony?.UnpatchSelf();
}

public void OnFejdStartupStart()
{
Log.Debug("******* [Digitalroot Plug-ins Loaded] *******");
Log.Debug(this, "******* [Digitalroot Plug-ins Loaded] *******");
foreach (KeyValuePair<string, BepInEx.PluginInfo> pluginInfo in BepInEx.Bootstrap.Chainloader.PluginInfos)
{
Log.Debug($"Key: {pluginInfo.Key}");
Log.Debug($"Value: {pluginInfo.Value}");
Log.Debug($"GUID: {pluginInfo.Value.Metadata.GUID}");
Log.Debug($"Name: {pluginInfo.Value.Metadata.Name}");
Log.Debug($"Version: {pluginInfo.Value.Metadata.Version}");
Log.Debug($"Location: {pluginInfo.Value.Location}");
Log.Debug(this, $"Key: {pluginInfo.Key}");
Log.Debug(this, $"Value: {pluginInfo.Value}");
Log.Debug(this, $"GUID: {pluginInfo.Value.Metadata.GUID}");
Log.Debug(this, $"Name: {pluginInfo.Value.Metadata.Name}");
Log.Debug(this, $"Version: {pluginInfo.Value.Metadata.Version}");
Log.Debug(this, $"Location: {pluginInfo.Value.Location}");

Log.Debug($"Dependencies:");
Log.Debug(this, $"Dependencies:");
foreach (BepInDependency dependency in pluginInfo.Value.Dependencies)
{
Log.Debug($"DependencyGUID: {dependency.DependencyGUID}");
Log.Debug($"Flags: {dependency.Flags}");
Log.Debug($"MinimumVersion: {dependency.MinimumVersion}");
Log.Debug(this, $"DependencyGUID: {dependency.DependencyGUID}");
Log.Debug(this, $"Flags: {dependency.Flags}");
Log.Debug(this, $"MinimumVersion: {dependency.MinimumVersion}");
}

Log.Debug($"Incompatibilities:");
Log.Debug(this, $"Incompatibilities:");
foreach (BepInIncompatibility incompatibility in pluginInfo.Value.Incompatibilities)
{
Log.Debug($"DependencyGUID: {incompatibility.IncompatibilityGUID}");
Log.Debug(this, $"DependencyGUID: {incompatibility.IncompatibilityGUID}");
}

Log.Debug($"Instance: {pluginInfo.Value.Instance}");
Log.Debug($"***************************************");
Log.Debug(this, $"Instance: {pluginInfo.Value.Instance}");
Log.Debug(this, $"***************************************");
}

Log.Debug($"DependencyErrors");
Log.Debug(this, $"DependencyErrors");
foreach (string dependencyError in BepInEx.Bootstrap.Chainloader.DependencyErrors)
{
Log.Debug($"{dependencyError}");
Log.Debug(this, $"{dependencyError}");
}

Log.Debug($"***************************************");
Log.Debug(this, $"***************************************");
}
}
}
4 changes: 2 additions & 2 deletions src/Digitalroot.Valheim.PluginInfo/Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public static void Postfix()
{
try
{
Log.Trace($"{Main.Namespace}.{MethodBase.GetCurrentMethod().DeclaringType?.Name}.{MethodBase.GetCurrentMethod().Name}");
Log.Trace(Main.Instance, $"{Main.Namespace}.{MethodBase.GetCurrentMethod().DeclaringType?.Name}.{MethodBase.GetCurrentMethod().Name}");

Main.Instance.OnFejdStartupStart();
}
catch (Exception e)
{
Log.Error(e);
Log.Error(Main.Instance, e);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Digitalroot.Valheim.PluginInfo/packages.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Digitalroot.Valheim.Common.AssemblyInfo" version="1.0.0" targetFramework="net462" />
<package id="Digitalroot.Valheim.Common.AssemblyInfo" version="1.0.1" targetFramework="net462" />
<package id="Digitalroot.Valheim.Common.Json" version="1.0.2" targetFramework="net462" />
<package id="Digitalroot.Valheim.Common.Log" version="1.0.3" targetFramework="net462" />
<package id="Digitalroot.Valheim.Common.Log" version="1.1.4" targetFramework="net462" />
<package id="ErrorProne.NET.CoreAnalyzers" version="0.1.2" targetFramework="net462" developmentDependency="true" />
<package id="fastJSON" version="2.4.0.4" targetFramework="net462" />
<package id="Fody" version="6.5.2" targetFramework="net462" developmentDependency="true" />
Expand Down

0 comments on commit 17da265

Please sign in to comment.