|
nwein
Posts: 577
Joined: 2011-03-28
|
I've noticed that ADX projects seem to ignore any rules defined in the .editorconfig file; this is true for top level editorconfig and even project level.
It is really easy to reproduce with a blank add-in. Just create one, add some empty try..catch(Exception ex) anywhere in it which should raise the CA1031 validation.
Add an .editorconfig to either the solution or the project, like so:
[*.cs]
# CA1031: Do not catch general exception types
dotnet_diagnostic.CA1031.severity = error
Observe that regardless of the severity you apply to the validation, VS doesn't seem to respect that.
I thought it might be a VS issue, but it seems to only affect ADX projects, so perhaps it's something in the way you guys have implemented the ADX project template, not sure.
You can see that if you add any other project type to the solution, that project respect the editorconfig settings.
I'm seeing this behaviour with Visual Studio Enterprise 2019 Preview Version 16.7.0 Preview 1.0, but pretty sure it's the same with other versions of VS 2019 that supports editorconfig. |
|
Posted 25 May, 2020 11:14:06
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18823
Joined: 2006-05-11
|
Hello Nir,
nwein writes:
which should raise the CA1031 validation
I get an error whether I use an .editorconfig or not. VS 2019 16.6. Could you send me a class library project that shows a suggestion rather than error? I may do something wrong as I've never used .editorconfig files.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 26 May, 2020 02:02:05
|
|
Top
|
|
nwein
Posts: 577
Joined: 2011-03-28
|
No problem, just sent you guys a complete solution showcasing the issue. |
|
Posted 26 May, 2020 07:57:53
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18823
Joined: 2006-05-11
|
Thank you, Nir.
I cannot get CA1031 on your solution using VS 2019 16.6. I've tried building the solution/projects and also running Analyze | Run Code Analysis | On Solution: no CA1031.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 26 May, 2020 08:34:04
|
|
Top
|
|
nwein
Posts: 577
Joined: 2011-03-28
|
Ok, just installed fresh VS 19.6.6 without any add-ins and you're right, the CA1031 doesn't get triggered, but you can still see how it works quite easily by adding this to .editorconfig:
dotnet_diagnostic.IDE0059.severity = error
It should highlight and identify the '(Exception ex)' in the Class1 as an error but doesn't do the same in the AddinModule |
|
Posted 26 May, 2020 09:00:05
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18823
Joined: 2006-05-11
|
Hello Nir,
I've reproduced the issue. We look into this.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 26 May, 2020 09:46:17
|
|
Top
|
|
nwein
Posts: 577
Joined: 2011-03-28
|
I actually found the reason for it. For some odd reason, it is the placement of this line:
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
in the csproj.
If you place it as the last line (before the \project of course) then it works fine.
Currently, the ADX template places that line just before the ItemGroup section.
Would it be possible for you to alter your template to include that in the bottom? I find it weird, but it seems to work. |
|
Posted 26 May, 2020 10:09:41
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18823
Joined: 2006-05-11
|
Hello Nir,
We would need to investigate if your find can be used. I've written that issue under #17986 in our issue-tracking DB. Will let you know once I have anything from our guys.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 26 May, 2020 10:35:05
|
|
Top
|
|
nwein
Posts: 577
Joined: 2011-03-28
|
|
Posted 26 May, 2020 10:40:52
|
|
Top
|
|