Skip to content

Commit 3a366b9

Browse files
authored
Add support for ZLogger #94 (#96)
1 parent aaa4b68 commit 3a366b9

File tree

8 files changed

+69
-0
lines changed

8 files changed

+69
-0
lines changed

.nuke/build.schema.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"items": {
7171
"type": "string",
7272
"enum": [
73+
"Clean",
7374
"Compile",
7475
"Pack",
7576
"PackRiderPlugin",
@@ -92,6 +93,7 @@
9293
"items": {
9394
"type": "string",
9495
"enum": [
96+
"Clean",
9597
"Compile",
9698
"Pack",
9799
"PackRiderPlugin",

build/Build.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ protected override void OnBuildInitialized()
5353

5454
[LocalPath("./gradlew.bat")] readonly Tool Gradle;
5555

56+
[NuGetPackage(
57+
packageId: "dotnet-cleanup",
58+
packageExecutable: "cleanup.dll")]
59+
readonly Tool DotNetCleanup;
60+
5661
string NuGetPackageFileName => $"{Project.Name}.{ExtensionVersion}.nupkg";
5762

5863
string NuGetPackagePath => RootDirectory / NuGetPackageFileName;
@@ -90,6 +95,12 @@ protected override void OnBuildInitialized()
9095
AppVeyor.Instance.UpdateBuildVersion(ExtensionVersion);
9196
});
9297

98+
Target Clean => _ => _
99+
.Executes(() =>
100+
{
101+
DotNetCleanup($"{Solution.Path} -y -v");
102+
});
103+
93104
Target Compile => _ => _
94105
.DependsOn()
95106
.Executes(() =>

build/_build.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<PackageDownload Include="dotnet-sonarscanner" Version="[5.9.1]" />
1919
<PackageDownload Include="NuGet.CommandLine" Version="[6.3.1]" />
2020
<PackageDownload Include="NUnit.ConsoleRunner" Version="[3.16.0]" />
21+
<PackageDownload Include="dotnet-cleanup" Version="[0.6.1]" />
2122
</ItemGroup>
2223

2324
</Project>

src/ReSharper.Structured.Logging/Caching/TemplateParameterNameAttributeProvider.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ protected override string CalculateInfo(ITypeMember attributesOwner, IEnumerable
3535
return attributesOwner.ShortName == "BeginScope" ? "messageFormat" : "message";
3636
}
3737

38+
if (className == "ZLogger.ZLoggerExtensions")
39+
{
40+
return "format";
41+
}
42+
3843
return null;
3944
}
4045

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Microsoft.Extensions.Logging;
2+
using ZLogger;
3+
4+
namespace ConsoleApp
5+
{
6+
class A
7+
{
8+
public A(ILogger<A> log)
9+
{
10+
log.ZLogInformation("{myProperty}", 1);
11+
}
12+
}
13+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Microsoft.Extensions.Logging;
2+
using ZLogger;
3+
4+
namespace ConsoleApp
5+
{
6+
class A
7+
{
8+
public A(ILogger<A> log)
9+
{
10+
log.ZLogInformation("|{myProperty}|(0)", 1);
11+
}
12+
}
13+
}
14+
15+
---------------------------------------------------------
16+
(0): ReSharper Warning: Property name 'myProperty' does not match naming rules. Suggested name is 'MyProperty'.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using JetBrains.ReSharper.TestFramework;
2+
3+
using NUnit.Framework;
4+
5+
using ReSharper.Structured.Logging.Tests.Constants;
6+
7+
namespace ReSharper.Structured.Logging.Tests.Analyzer
8+
{
9+
[TestNet60]
10+
[TestPackages(
11+
NugetPackages.ZLoggerLoggingPackage,
12+
Inherits = true)]
13+
public class PropertiesNamingAnalyzerDotNet6Tests : MessageTemplateAnalyzerTestBase
14+
{
15+
protected override string SubPath => "PropertiesNamingAnalyzerDotNet6";
16+
17+
[Test] public void TestZLoggerInvalidNamedProperty() => DoNamedTest2();
18+
}
19+
}

test/src/Constants/NugetPackages.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ internal static class NugetPackages
77
public const string MicrosoftLoggingPackage = "Microsoft.Extensions.Logging/1.0.0";
88

99
public const string NlogLoggingPackage = "NLog/4.5.11";
10+
11+
public const string ZLoggerLoggingPackage = "ZLogger/1.7.0";
1012
}
1113
}

0 commit comments

Comments
 (0)