olsh / resharper-structured-logging

An extension for ReSharper and Rider that highlights structured logging templates and contains some useful analyzers
MIT License
141 stars 14 forks source link

Specified cast is not valid on reading `ConstantValue.StringValue` #83

Closed van800 closed 1 year ago

van800 commented 1 year ago

corresponding automatic exception report https://youtrack.jetbrains.com/issue/DEXP-708411/Analyzer-ReSharper.Structured.Logging.Analyzer.PropertiesNamingAnalyzer-threw-the-following-exception-Specified-cast-is-not

Similar fix in the Unity support plugin: https://github.com/JetBrains/resharper-unity/commit/e9df0000ed708d8250f5ede98f6685c4c4e9ac23

olsh commented 1 year ago

Hi @van800 Could you please attach the stack trace? Also, please specify the extension version. Is this only happens in the EAP or the stable version is affected too?

van800 commented 1 year ago

StackTraceString = “ at JetBrains.ReSharper.Psi.ConstantValue.get_StringValue() at ReSharper.Structured.Logging.Analyzer.PropertiesNamingAnalyzer.CheckPropertiesInContext(IInvocationExpression element, IHighlightingConsumer consumer, IContextBoundSettingsStore settingsStore, Regex ignoredPropertiesRegex) in C:\projects\resharper-structured-logging\src\ReSharper.Structured.Logging\Analyzer\PropertiesNamingAnalyzer.cs:line 92 at JetBrains.ReSharper.Feature.Services.Daemon.ElementProblemAnalyzerRegistrar.ElementAnalyzerDispatcher.Run(ITreeNode element, IHighlightingConsumer consumer) in Run.il:line IL_0063 mvid ABDB

van800 commented 1 year ago

I think this query on youtrack would show you all the related reports https://youtrack.jetbrains.com/issues?q=%22resharper-structured-logging%22%20JetBrains.ReSharper.Psi.ConstantValue.get_StringValue

olsh commented 1 year ago

Huh, this is a pretty old bug. I'll take a look. Thanks.

van800 commented 1 year ago

Previously this was never a problem, because only string was allowed for the attribute parameter value. New dotnet/langversion allows setting const or string interpolation there. Like in my case: image