Open philipborg opened 2 years ago
What this means (just one example, and just to spell it out) is that this warning will never trigger for Azure Function
projects.
It would seem that related rule https://docs.microsoft.com/en-gb/dotnet/fundamentals/code-analysis/quality-rules/ca2017 is also broken in Azure Function
projects.
Still broken in the latest Microsoft.Azure.WebJobs version (3.0.37), any insights to share? At least an acknowledgement that this is a bug?
+1 on fixing this bug
Analyzer
Diagnostic ID: CA2254:
Template should be a static expression
Analyzer source
SDK: Built-in CA analyzers in .NET 5 SDK or later
Version: SDK 6.0.202
OR
NuGet Package: Microsoft.CodeAnalysis.NetAnalyzers
Version: 6.0.0 (Latest) and 7.0.0-preview1.22168.1 (Preview)
Describe the bug
CA2254 seemingly never gives any warnings even if all other rules seem to work if
Microsoft.Azure.WebJobs
version3.0.32
(latest) is installed. I have tried both the built-in CA analyzer, NuGet 6.0.0 and 7.0.0-preview1.22168.1, never works. I also tried loweringMicrosoft.Azure.WebJobs
to3.0.0
without success.Tried properties:
I have also tried to set AnalysisLevel to
6-all
andpreview-all
, with and without CA nuget package. Same issue persists.Steps To Reproduce
namespace CA2254POC;
public class Sample { public void LogExample(ILogger logger)
{
logger.LogInformation($"{logger.GetType().Assembly.Location}");
}
}
Microsoft.Azure.WebJobs
Expected behavior
CA2254 should trigger even with
Microsoft.Azure.WebJobs
installed.Actual behavior
CA2254 doesn't trigger with
Microsoft.Azure.WebJobs
installed.Additional context
I have tried just having each of the dependencies of
Microsoft.Azure.WebJobs
installed and the problem did not occur. I am thus pretty certain it's a problem withMicrosoft.Azure.WebJobs
specifically rather than any one of its dependencies. I initially discovered this issue whenMicrosoft.NET.Sdk.Functions
4.1.0
or4.0.0
(the version I tried) was installed and boiled it down to theMicrosoft.Azure.WebJobs
dependency.