Microsoft.CodeAnalysis.FxCopAnalyzers
try
{
//something
}
catch (CustomException)
{
}
No warning
Warning CA1031 Modify 'MyFunction' to catch a more specific exception type, or rethrow the exception.
try
{
//something
}
catch (CustomException e)
{
}
Alternative
try
{
//something
}
catch (CustomException)
{
//something
throw;
}
Duplicate of https://github.com/dotnet/roslyn-analyzers/issues/2518. Verified this does not repro on 2.9.4 or 2.9.5-beta1.final packages.
@mavasani I don't know how you verified this but this is trivial to reproduce.
.Net Core 3, VS 2019 Preview 4

@fschlaef I opened your project in latest VS2019 16.3 preview drop and I don't see this:

Additionally, your screenshot shows the CA1031 squiggle spans the entire catch block, which was explicitly fixed to only span the catch keyword prior to version 2.9.4 of the analyzer package with https://github.com/dotnet/roslyn-analyzers/pull/2519. So you are almost certainly on an older package. Have you installed https://marketplace.visualstudio.com/items?itemName=VisualStudioPlatformTeam.MicrosoftCodeAnalysis2019 by any chance?
@mavasani spot on ! I had indeed installed this extension. After removal, no more warning.
Thank you very much ! 馃憤
Most helpful comment
@fschlaef I opened your project in latest VS2019 16.3 preview drop and I don't see this:
Additionally, your screenshot shows the CA1031 squiggle spans the entire catch block, which was explicitly fixed to only span the catch keyword prior to version 2.9.4 of the analyzer package with https://github.com/dotnet/roslyn-analyzers/pull/2519. So you are almost certainly on an older package. Have you installed https://marketplace.visualstudio.com/items?itemName=VisualStudioPlatformTeam.MicrosoftCodeAnalysis2019 by any chance?