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

Fix analyzer issue with properties with dot or space in name #79

Merged
merged 1 commit into from
Nov 6, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static bool IsValidInPropertyTag(char c)
c == ':';
}

static bool IsValidInPropertyName(char c) => char.IsLetterOrDigit(c) || c == '_';
static bool IsValidInPropertyName(char c) => char.IsLetterOrDigit(c) || c == '_' || c == '.' || c == ' ';

static bool TryGetDestructuringHint(char c, out Destructuring destructuring)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Serilog;

namespace ConsoleApp
{
public static class Program
{
public static void Main()
{
Log.Logger.Information("{My.Property}", 1);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Serilog;

namespace ConsoleApp
{
public static class Program
{
public static void Main()
{
Log.Logger.Information("|{My.Property}|(0)", 1);
}
}
}

---------------------------------------------------------
(0): ReSharper Warning: Property name 'My.Property' does not match naming rules. Suggested name is 'MyProperty'.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Serilog;

namespace ConsoleApp
{
public static class Program
{
public static void Main()
{
Log.Logger.Information("{My Property}", 1);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Serilog;

namespace ConsoleApp
{
public static class Program
{
public static void Main()
{
Log.Logger.Information("|{My Property}|(0)", 1);
}
}
}

---------------------------------------------------------
(0): ReSharper Warning: Property name 'My Property' does not match naming rules. Suggested name is 'MyProperty'.
4 changes: 4 additions & 0 deletions test/src/Analyzer/PropertiesNamingAnalyzerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@ public class PropertiesNamingAnalyzerTests : MessageTemplateAnalyzerTestBase
[Test] public void TestSerilogValidDestructuredNamedProperty() => DoNamedTest2();

[Test] public void TestSerilogContextInvalidNamedProperty() => DoNamedTest2();

[Test] public void TestSerilogInvalidNamedPropertyWithDot() => DoNamedTest2();

[Test] public void TestSerilogInvalidNamedPropertyWithSpace() => DoNamedTest2();
}
}