Skip to content

Commit

Permalink
Fix ReSharper/Rider inspection warnings
Browse files Browse the repository at this point in the history
The `serilog-settings-configuration.sln.DotSettings` file defines many custom inspection severities as error rendering the solution with many red squiggly lines when opened in Rider or in Visual Studio with ReSharper.
  • Loading branch information
0xced committed May 10, 2022
1 parent 406efa6 commit 7a1bb67
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;

using Microsoft.Extensions.Configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ bool TryCreateContainer(out object result)

var configurationElements = _section.GetChildren().ToArray();
result = Activator.CreateInstance(toType);

for (int i = 0; i < configurationElements.Length; ++i)
{
var argumentValue = ConfigurationReader.GetArgumentValue(configurationElements[i], _configurationAssemblies);
var value = argumentValue.ConvertTo(elementType, resolutionContext);
addMethod.Invoke(result, new object[] { value });
addMethod.Invoke(result, new[] { value });
}

return true;
Expand Down Expand Up @@ -164,7 +164,7 @@ where gr.All(z => z.argumentBindResult.success)
{
return false;
}

var ctorArguments = new List<Expression>();
foreach (var argumentValue in ctor.ArgumentValues)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,6 @@ public class DllScanningAssemblyFinderTests : IDisposable
const string BinDir2 = "bin2";
const string BinDir3 = "bin3";

readonly string _privateBinPath;

public DllScanningAssemblyFinderTests()
{
var d1 = GetOrCreateDirectory(BinDir1);
var d2 = GetOrCreateDirectory(BinDir2);
var d3 = GetOrCreateDirectory(BinDir3);

_privateBinPath = $"{d1.Name};{d2.FullName};{d3.Name}";

DirectoryInfo GetOrCreateDirectory(string name)
=> Directory.Exists(name) ? new DirectoryInfo(name) : Directory.CreateDirectory(name);
}

public void Dispose()
{
Directory.Delete(BinDir1, true);
Expand All @@ -45,6 +31,13 @@ public void ShouldProbeCurrentDirectory()
[Fact]
public void ShouldProbePrivateBinPath()
{
var d1 = GetOrCreateDirectory(BinDir1);
var d2 = GetOrCreateDirectory(BinDir2);
var d3 = GetOrCreateDirectory(BinDir3);

DirectoryInfo GetOrCreateDirectory(string name)
=> Directory.Exists(name) ? new DirectoryInfo(name) : Directory.CreateDirectory(name);

File.Copy("testdummies.dll", $"{BinDir1}/customSink1.dll", true);
File.Copy("testdummies.dll", $"{BinDir2}/customSink2.dll", true);
File.Copy("testdummies.dll", $"{BinDir3}/thirdpartydependency.dll", true);
Expand All @@ -53,7 +46,7 @@ public void ShouldProbePrivateBinPath()
new AppDomainSetup
{
ApplicationBase = AppDomain.CurrentDomain.BaseDirectory,
PrivateBinPath = _privateBinPath
PrivateBinPath = $"{d1.Name};{d2.FullName};{d3.Name}"
});

try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void ReadFromConfigurationSectionReadsFromAnArbitrarySection()
LogEvent evt = null;

var json = @"{
""NotSerilog"": {
""NotSerilog"": {
""Properties"": {
""App"": ""Test""
}
Expand Down Expand Up @@ -53,12 +53,12 @@ public void ReadFromConfigurationSectionReadsFromAnArbitrarySection()
public void ReadFromConfigurationSectionThrowsWhenTryingToCallConfigurationMethodWithIConfigurationParam()
{
var json = @"{
""NotSerilog"": {
""NotSerilog"": {
""Using"": [""TestDummies""],
""WriteTo"": [{
""Name"": ""DummyWithConfiguration"",
""Args"": {}
}]
}]
}
}";

Expand All @@ -84,20 +84,20 @@ public void ReadFromConfigurationSectionThrowsWhenTryingToCallConfigurationMetho
public void ReadFromConfigurationDoesNotThrowWhenTryingToCallConfigurationMethodWithIConfigurationParam()
{
var json = @"{
""NotSerilog"": {
""NotSerilog"": {
""Using"": [""TestDummies""],
""WriteTo"": [{
""Name"": ""DummyWithConfiguration"",
""Args"": {}
}]
}]
}
}";

var config = new ConfigurationBuilder()
.AddJsonString(json)
.Build();

var exception = new LoggerConfiguration()
_ = new LoggerConfiguration()
.ReadFrom.Configuration(config, "NotSerilog")
.CreateLogger();

Expand All @@ -108,12 +108,12 @@ public void ReadFromConfigurationDoesNotThrowWhenTryingToCallConfigurationMethod
public void ReadFromConfigurationSectionDoesNotThrowWhenTryingToCallConfigurationMethodWithOptionalIConfigurationParam()
{
var json = @"{
""NotSerilog"": {
""NotSerilog"": {
""Using"": [""TestDummies""],
""WriteTo"": [{
""Name"": ""DummyWithOptionalConfiguration"",
""Args"": {}
}]
}]
}
}";

Expand Down
4 changes: 0 additions & 4 deletions test/TestDummies/DummyThreadIdEnricher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ namespace TestDummies
{
public class DummyThreadIdEnricher : ILogEventEnricher
{
static DummyThreadIdEnricher()
{
}

public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
logEvent.AddPropertyIfAbsent(propertyFactory
Expand Down

0 comments on commit 7a1bb67

Please sign in to comment.