Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ZLogger #94 #96

Merged
merged 1 commit into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"items": {
"type": "string",
"enum": [
"Clean",
"Compile",
"Pack",
"PackRiderPlugin",
Expand All @@ -92,6 +93,7 @@
"items": {
"type": "string",
"enum": [
"Clean",
"Compile",
"Pack",
"PackRiderPlugin",
Expand Down
11 changes: 11 additions & 0 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ protected override void OnBuildInitialized()

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

[NuGetPackage(
packageId: "dotnet-cleanup",
packageExecutable: "cleanup.dll")]
readonly Tool DotNetCleanup;

string NuGetPackageFileName => $"{Project.Name}.{ExtensionVersion}.nupkg";

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

Target Clean => _ => _
.Executes(() =>
{
DotNetCleanup($"{Solution.Path} -y -v");
});

Target Compile => _ => _
.DependsOn()
.Executes(() =>
Expand Down
1 change: 1 addition & 0 deletions build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<PackageDownload Include="dotnet-sonarscanner" Version="[5.9.1]" />
<PackageDownload Include="NuGet.CommandLine" Version="[6.3.1]" />
<PackageDownload Include="NUnit.ConsoleRunner" Version="[3.16.0]" />
<PackageDownload Include="dotnet-cleanup" Version="[0.6.1]" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ protected override string CalculateInfo(ITypeMember attributesOwner, IEnumerable
return attributesOwner.ShortName == "BeginScope" ? "messageFormat" : "message";
}

if (className == "ZLogger.ZLoggerExtensions")
{
return "format";
}

return null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Microsoft.Extensions.Logging;
using ZLogger;

namespace ConsoleApp
{
class A
{
public A(ILogger<A> log)
{
log.ZLogInformation("{myProperty}", 1);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Microsoft.Extensions.Logging;
using ZLogger;

namespace ConsoleApp
{
class A
{
public A(ILogger<A> log)
{
log.ZLogInformation("|{myProperty}|(0)", 1);
}
}
}

---------------------------------------------------------
(0): ReSharper Warning: Property name 'myProperty' does not match naming rules. Suggested name is 'MyProperty'.
19 changes: 19 additions & 0 deletions test/src/Analyzer/PropertiesNamingAnalyzerDotNet6Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using JetBrains.ReSharper.TestFramework;

using NUnit.Framework;

using ReSharper.Structured.Logging.Tests.Constants;

namespace ReSharper.Structured.Logging.Tests.Analyzer
{
[TestNet60]
[TestPackages(
NugetPackages.ZLoggerLoggingPackage,
Inherits = true)]
public class PropertiesNamingAnalyzerDotNet6Tests : MessageTemplateAnalyzerTestBase
{
protected override string SubPath => "PropertiesNamingAnalyzerDotNet6";

[Test] public void TestZLoggerInvalidNamedProperty() => DoNamedTest2();
}
}
2 changes: 2 additions & 0 deletions test/src/Constants/NugetPackages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ internal static class NugetPackages
public const string MicrosoftLoggingPackage = "Microsoft.Extensions.Logging/1.0.0";

public const string NlogLoggingPackage = "NLog/4.5.11";

public const string ZLoggerLoggingPackage = "ZLogger/1.7.0";
}
}