diff --git a/src/ReSharper.Structured.Logging/Serilog/Parsing/MessageTemplateParser.cs b/src/ReSharper.Structured.Logging/Serilog/Parsing/MessageTemplateParser.cs index 19d302a..de21c87 100644 --- a/src/ReSharper.Structured.Logging/Serilog/Parsing/MessageTemplateParser.cs +++ b/src/ReSharper.Structured.Logging/Serilog/Parsing/MessageTemplateParser.cs @@ -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) { diff --git a/test/data/Analyzers/PropertiesNamingAnalyzer/SerilogInvalidNamedPropertyWithDot.cs b/test/data/Analyzers/PropertiesNamingAnalyzer/SerilogInvalidNamedPropertyWithDot.cs new file mode 100644 index 0000000..3797e32 --- /dev/null +++ b/test/data/Analyzers/PropertiesNamingAnalyzer/SerilogInvalidNamedPropertyWithDot.cs @@ -0,0 +1,12 @@ +using Serilog; + +namespace ConsoleApp +{ + public static class Program + { + public static void Main() + { + Log.Logger.Information("{My.Property}", 1); + } + } +} diff --git a/test/data/Analyzers/PropertiesNamingAnalyzer/SerilogInvalidNamedPropertyWithDot.cs.gold b/test/data/Analyzers/PropertiesNamingAnalyzer/SerilogInvalidNamedPropertyWithDot.cs.gold new file mode 100644 index 0000000..6e77908 --- /dev/null +++ b/test/data/Analyzers/PropertiesNamingAnalyzer/SerilogInvalidNamedPropertyWithDot.cs.gold @@ -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'. diff --git a/test/data/Analyzers/PropertiesNamingAnalyzer/SerilogInvalidNamedPropertyWithSpace.cs b/test/data/Analyzers/PropertiesNamingAnalyzer/SerilogInvalidNamedPropertyWithSpace.cs new file mode 100644 index 0000000..5f556af --- /dev/null +++ b/test/data/Analyzers/PropertiesNamingAnalyzer/SerilogInvalidNamedPropertyWithSpace.cs @@ -0,0 +1,12 @@ +using Serilog; + +namespace ConsoleApp +{ + public static class Program + { + public static void Main() + { + Log.Logger.Information("{My Property}", 1); + } + } +} diff --git a/test/data/Analyzers/PropertiesNamingAnalyzer/SerilogInvalidNamedPropertyWithSpace.cs.gold b/test/data/Analyzers/PropertiesNamingAnalyzer/SerilogInvalidNamedPropertyWithSpace.cs.gold new file mode 100644 index 0000000..4194375 --- /dev/null +++ b/test/data/Analyzers/PropertiesNamingAnalyzer/SerilogInvalidNamedPropertyWithSpace.cs.gold @@ -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'. diff --git a/test/src/Analyzer/PropertiesNamingAnalyzerTests.cs b/test/src/Analyzer/PropertiesNamingAnalyzerTests.cs index c9b3d5d..09ed495 100644 --- a/test/src/Analyzer/PropertiesNamingAnalyzerTests.cs +++ b/test/src/Analyzer/PropertiesNamingAnalyzerTests.cs @@ -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(); } }