Skip to content

Commit

Permalink
2.0.27
Browse files Browse the repository at this point in the history
  • Loading branch information
Critical-Impact committed Sep 26, 2024
1 parent b08a2bb commit 0ecadda
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Removed

## [2.0.27] - 2024-09-26

### Added

- Use MS logging for mocks

## [2.0.26] - 2024-08-20

### Added
Expand Down
2 changes: 1 addition & 1 deletion DalaMock.Host/DalaMock.Host.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<LangVersion>12.0</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Version>2.0.26</Version>
<Version>2.0.27</Version>
<PackageProjectUrl>https://github.com/Critical-Impact/DalaMock</PackageProjectUrl>
<RepositoryUrl>https://github.com/Critical-Impact/DalaMock</RepositoryUrl>
<Authors>Critical-Impact</Authors>
Expand Down
2 changes: 1 addition & 1 deletion DalaMock.Sample/DalaMock.Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Nullable>enable</Nullable>
<LangVersion>12.0</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Version>2.0.26</Version>
<Version>2.0.27</Version>
<PackageProjectUrl>https://github.com/Critical-Impact/DalaMock</PackageProjectUrl>
<RepositoryUrl>https://github.com/Critical-Impact/DalaMock</RepositoryUrl>
<Authors>Critical-Impact</Authors>
Expand Down
2 changes: 1 addition & 1 deletion DalaMock.Shared/DalaMock.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<LangVersion>12.0</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Version>2.0.26</Version>
<Version>2.0.27</Version>
<PackageProjectUrl>https://github.com/Critical-Impact/DalaMock</PackageProjectUrl>
<RepositoryUrl>https://github.com/Critical-Impact/DalaMock</RepositoryUrl>
<Authors>Critical-Impact</Authors>
Expand Down
2 changes: 1 addition & 1 deletion DalaMock/DalaMock.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<LangVersion>12.0</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Version>2.0.26</Version>
<Version>2.0.27</Version>
<PackageProjectUrl>https://github.com/Critical-Impact/DalaMock</PackageProjectUrl>
<RepositoryUrl>https://github.com/Critical-Impact/DalaMock</RepositoryUrl>
<Authors>Critical-Impact</Authors>
Expand Down
11 changes: 6 additions & 5 deletions DalaMock/Mocks/MockDalamudPluginInterface.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Microsoft.Extensions.Logging;

namespace DalaMock.Core.Mocks;

using System;
Expand All @@ -22,7 +24,6 @@ namespace DalaMock.Core.Mocks;
using Dalamud.Plugin.Ipc;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using Serilog;

public class MockDalamudPluginInterface : IDalamudPluginInterface, IDisposable
{
Expand Down Expand Up @@ -286,7 +287,7 @@ public void RemoveChatLinkHandler()
/// <inheritdoc/>
public T? Create<T>(params object[] scopedObjects) where T : class
{
var logger = this.componentContext.Resolve<ILogger>();
var logger = this.componentContext.Resolve<ILogger<T>>();
var mockServices = this.componentContext.Resolve<IEnumerable<IMockService>>();
Dictionary<Type, object> mockServicesDict = new();
foreach (var mockService in mockServices)
Expand Down Expand Up @@ -349,7 +350,7 @@ public void RemoveChatLinkHandler()
if (newInstance == null)
{
// If no suitable constructor is found, return null
logger.Error($"No suitable constructor found for type '{typeToCreate.FullName}' that can be resolved with the provided mock services.");
logger.LogError($"No suitable constructor found for type '{typeToCreate.FullName}' that can be resolved with the provided mock services.");
return null;
}

Expand All @@ -366,7 +367,7 @@ public void RemoveChatLinkHandler()
}
else
{
logger.Error($"No matching mock service found for property '{property.Name}' of type '{propertyType.FullName}' in object of type '{newInstance.GetType().FullName}'.");
logger.LogError($"No matching mock service found for property '{property.Name}' of type '{propertyType.FullName}' in object of type '{newInstance.GetType().FullName}'.");
}
}

Expand Down Expand Up @@ -414,7 +415,7 @@ public bool Inject(object instance, params object[] scopedObjects)
}
else
{
logger.Error($"No matching mock service found for property '{property.Name}' of type '{propertyType.FullName}' in object of type '{instance.GetType().FullName}'.");
logger.LogError($"No matching mock service found for property '{property.Name}' of type '{propertyType.FullName}' in object of type '{instance.GetType().FullName}'.");
}
}

Expand Down
1 change: 0 additions & 1 deletion DalaMock/Mocks/MockPluginLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ namespace DalaMock.Core.Mocks;

using System;
using Dalamud.Plugin.Services;
using Serilog;
using Serilog.Events;

public class MockPluginLog : IPluginLog, IMockService
Expand Down
10 changes: 8 additions & 2 deletions DalaMock/Plugin/PluginLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class PluginLoader : IPluginLoader
private readonly MockContainer mockContainer;
private readonly MockDalamudConfiguration mockDalamudConfiguration;
private readonly ILogger<PluginLoader> logger;
private readonly ILoggerFactory loggerFactory;

/// <summary>
/// Has the plugin's state changed, has it started or stopped?
Expand Down Expand Up @@ -50,11 +51,12 @@ public class PluginLoader : IPluginLoader
/// </summary>
/// <param name="mockContainer">The global DI container.</param>
/// <param name="logger">The serilog logger.</param>
public PluginLoader(MockContainer mockContainer, MockDalamudConfiguration mockDalamudConfiguration, ILogger<PluginLoader> logger)
public PluginLoader(MockContainer mockContainer, MockDalamudConfiguration mockDalamudConfiguration, ILogger<PluginLoader> logger, ILoggerFactory loggerFactory)
{
this.mockContainer = mockContainer;
this.mockDalamudConfiguration = mockDalamudConfiguration;
this.logger = logger;
this.loggerFactory = loggerFactory;
this.loadedPlugins = new Dictionary<Type, MockPlugin>();
}

Expand Down Expand Up @@ -96,7 +98,7 @@ public bool StartPlugin(MockPlugin mockPlugin)
public bool StartPlugin(MockPlugin plugin, PluginLoadSettings pluginLoadSettings)
{
var assemblyName = plugin.PluginType.BaseType?.Assembly.GetName().Name ?? plugin.PluginType.Assembly.GetName().Name ?? plugin.PluginType.Name;

if (plugin.IsLoaded)
{
this.logger.LogInformation(
Expand Down Expand Up @@ -142,6 +144,10 @@ public bool StartPlugin(MockPlugin plugin, PluginLoadSettings pluginLoadSettings
var uiBuilder = new MockUiBuilder(scene);
builder.RegisterInstance(uiBuilder);
builder.RegisterInstance(pluginLoadSettings);
builder.RegisterInstance(this.loggerFactory).ExternallyOwned();
builder.RegisterGeneric(typeof(Logger<>))
.As(typeof(ILogger<>))
.SingleInstance();
builder.RegisterInstance(this);
builder.Register<MockDalamudPluginInterface>(c =>
new MockDalamudPluginInterface(
Expand Down
4 changes: 2 additions & 2 deletions DalaMock/Windows/MockMockWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public MockMockWindow(IEnumerable<IMockWindow> mockWindows)
: base("Service Mocks")
{
this.mockWindows = mockWindows;
this.IsOpen = false;
this.IsOpen = true;
}

public override void Draw()
Expand All @@ -34,4 +34,4 @@ public override void Draw()
}
}
}
}
}

0 comments on commit 0ecadda

Please sign in to comment.