Граф коммитов

9 Коммитов

Автор SHA1 Сообщение Дата
Rainer Sigwald ce39dd4094
Add readonly to struct methods (#8656)
In recent dogfood VS builds we've gotten many IDE0251 suggestions, some warnings escalated to errors in StringTools. Follow many of those suggestions, but bump the rule down to suggestion always, like the related IDE0250.
2023-04-24 17:24:27 +08:00
Jan Krivanek 344a18823a
Change IDE0055 (Fix Formatting) warning->message (#8630)
IDE0055 is currently too unspecific - opting out of it.

### Sample error:

```
C:\src\msbuild\src\Build.UnitTests\BackEnd\MSBuild_Tests.cs(796,59): error IDE0055: Fix formatting [C:\src\msbuild\src\Buil
d.UnitTests\Microsoft.Build.Engine.UnitTests.csproj::TargetFramework=net472]
```

(changed to message and not blocking the build after this change)
2023-04-05 14:35:10 -05:00
Ladi Prosek d131702c0a
Enable CA1852: Seal internal types (#8389)
Context
Types that are not designed to be inherited from should be sealed. This is general defensive goodness, and also has perf implications because it enables some runtime/JIT optimizations. A new analyzer was recently added for this.

Changes Made
Enabled the analyzer and fixed the code with dotnet format.

Testing
Manual review of the changes.

Notes
dotnet format also rectified our namespace imports. I don't believe there's any controversy in that and the change is low risk so I left it in. For the actual sealing:

It missed one class because it was ifdefed out in Core. I fixed it manually.
It resulted in a handful of build errors where the compiler didn't like protected members in sealed types. I fixed those manually.
The analyzer doesn't understand InternalsVisibleTo, by design. This is not causing any issues for us now as we don't derive from internal types in other assemblies. Our InternalsVisibleTo all point to our own assemblies built in this repo so this is a non-breaking change (unless hacks, reflection, etc. but the bar is certainly not that high).
I am not including changes to files under src/Deprecated in this PR.
2023-02-14 11:04:33 +08:00
Vlada Shubina 56087a9725
Added IDE analyzers checks and enabled certain checks (#8336)
* added IDE code style checks as warning, set the currently violated rules to suggestion

* auto-fixed IDE0011 - add braces to statement

* auto-fixed IDE0036 - Modifiers are not ordered

* auto fixed IDE0040 - Accessibility modifiers required

* auto-fixed IDE0055 - fix formatting

* auto-fixed SA1110 and SA1111 - parenthesis formatting

manually fixed unresolvable cases

* auto-fixed IDE0073 - A source file contains a header that does not match the required text

* moved IDE rules to .editorconfig as they need to be filtered

* added IDE0020 - use pattern matching to be excluded

* extra disable format due to chunk of code conditioned for DEBUG only

* added comment in Version line to bypass the check

clarified CTA on how to bypass the error

* extra disable format due to chunk of code conditioned for DEBUG only
2023-01-26 11:46:37 +01:00
Rainer Sigwald 99f6c4dd93 Disable RS0037 'annotate nullability in API'
The vast majority of our API is not nullable aware so disable this.
2021-11-05 13:29:19 -05:00
Lachlan Ennis 8c92d4c190
implement analyzers from runtime (#5656)
* implement analyzers from runtime

* use formatter from dotnet/runtime

* Update eng/CodeAnalysis.ruleset

Co-authored-by: Forgind <Forgind@users.noreply.github.com>

* Fix indentation
2021-08-10 16:30:54 +02:00
Paul Vick d23965918f Turn on warning for unused usings 2020-10-01 13:39:35 -07:00
Yannis Güdel 525d77424d Added editorconfig properties from corefx 2015-03-20 13:09:51 +01:00
Yannis Güdel 5c113697eb Added editorconfig 2015-03-20 13:08:08 +01:00