Commit Graph
32 Commits
Author SHA1 Message Date
Stephen ToubandViktor Hofer cd0b3ef669 Update NetAnalyzers version (#54511)
* Update NetAnalyzers version

* Add NetAnalyzers to dependency flow

Co-authored-by: Viktor Hofer <[email protected]>
2021-06-23 08:34:38 +02:00
Stephen Toub 72ff0df463 Enable recently added Microsoft.CodeAnalysis.NetAnalyzers rules (#53158) 2021-05-28 14:46:46 -04:00
Tlakaelel Axayakatl Ceja aad916c711 Enable single file analyzer in the runtime (#50894)
Summary:
Enables single file analyzer in the runtime by adding the ILLink.Analyzers package and the property EnableSingleFileAnalyzer equals to true
Deletes entries IL3000 and IL3001 in the CodeAnalysis.ruleset so the analyzer can actually produce these warnings otherwise the analyzer execution would be skipped. *Note*: tests warnings are controlled by CodeAnalysis.test.ruleset (this PR adds IL3002 to the CodeAnalysis.test.ruleset to disable the warning on tests)
Resolve warnings on single file dangerous patterns by:
- Annotating incompatible single file patterns with RequiresAssemblyFiles
- Suppressing the warning (because there is code that handles the incompatible code)
- Fixing the issue on code (remove the incompatible code and replace it with something that won't fail)
- Opening an issue to track fix and either annotate/suppress the current behavior
2021-05-19 13:04:03 -07:00
Stephen Toub 4a2a44a617 Update analyzer versions (#51696) 2021-04-23 14:20:21 -07:00
Stephen Toub 184a5b103c Enable CA1052 (static holder types should be static) (#50047)
* Enable CA1052 (static holder types should be static)

* Fix a few additional warnings in 'all configurations'
2021-03-23 10:04:52 -04:00
Stephen Toub 877a8df671 Enable new CA1839 and CA1840 Environment rules (#49393) 2021-03-11 06:50:25 -05:00
Stephen Toub 3394fd580a Update analyzers (#48427) 2021-03-01 13:58:42 -05:00
Carlos Sanchezandcarlossanlop 7565d60891 CA1200 -> Info (#48612)
Co-authored-by: carlossanlop <[email protected]>
2021-02-22 19:29:54 -08:00
Stephen Toub c7fda3b94a Add Thread.UnsafeStart (#47056) 2021-01-16 13:52:21 -05:00
xtqqczze 8baa26360e Upgrade StyleCopAnalyzers to v1.2.0-beta.261 (#45562)
* Upgrade StyleCopAnalyzers to v1.2.0-beta.261

https://github.com/DotNetAnalyzers/StyleCopAnalyzers/releases/tag/1.2.0-beta.261

* Disable SA1142

* Enable SA1142 except in tests
2020-12-04 00:02:32 +00:00
Stephen Toub 838fde64be Fix xunit analyzers to run on library test projects (#43459)
We don't want most analyzers running over our test code currently (some rules could be enabled with varying degrees of effort), but we do want the xunit analyzers running, and they haven't been.  Fix that by creating a new ruleset specific to library tests, and switching over to use it when building library test projects.
2020-10-16 22:21:45 -04:00
Stephen Toub 6b5b9f7242 Enable several more IDE analyzer warnings (#42692)
* Enable IDE0062: Make local functions static

* Enable IDE0079: Remove unnecessary suppression

* Enable IDE0082: Convert typeof to nameof

* Enable IDE0043: Validate format string

* Enable IDE0041: Use is null check
2020-09-25 06:33:07 -04:00
Stephen Toub 3b6600cbef Add IDE warnings to code analysis ruleset (#42566)
- Add all IDEXXXX warnings to ruleset, but as hidden for now
- Enable IDE0073: file header mismatch
2020-09-23 22:26:31 -04:00
Tanner Gooding 23919a4b58 Enabling CA1416: Validate platform compatibility (#41760)
* Enabling CA1416

* Resolving PR feedback

* Updating the .NET analyzers to 5.0.0-rc2.20458.2

* Resolving compilation errors on full framework

* Fixing two more tfm issues with the platform compat checks

* Adjusting various platform compat checks to work with netstandard and netfx
2020-09-10 10:51:09 -07:00
Jeff Handley def5b48f55 Disable the Platform Compat Analyzer until #41354 is fixed (#41367) 2020-08-26 04:14:29 +00:00
David Cantu bcf3bd30ad Fix concurrent collections CA1836 rule violations (#40629)
* Fix concurrent collections CA1836 rule violations

* Update dogfood analyzer version
2020-08-10 18:12:52 -07:00
Stephen Toub aa5fdab965 Update Microsoft.CodeAnalysis.NetAnalyzers to 3.3.0-beta3.20407.4 (#40560) 2020-08-09 05:32:44 -04:00
Carlos Sanchez Lopez 7f34be5319 Apply CA2016: Forward CancellationToken to methods that can take it (#37607)
* Forward CancellationToken to methods that can take it

* Address suggestions

* address suggestions

* Revert using

* Make rule 2016 a warning in runtime

* Extra cases found

* Revert changes that should not pass a token, change rule to info to verify build and test CI results

* Pass CancellationToken.None to base.CreateContentReadStreamAsync, as in its default overload

* Address stack overflow in MultipartContent

* HostingAbstractionsHostExtensions address using

* Update nuget package version to latest, Info->Warning again, fix one more case.

* System.Diagnostics.ProcessWaitState.Unix token

* Remove two unnecessary tokens
2020-07-15 13:10:46 -07:00
Stephen Toub 68eb040669 Enable SA1404 Code analysis suppression should have justification (#38537) 2020-07-02 20:45:55 -04:00
buyaa-n 06fa9410a8 Turn on argument exception analyzer on runtime, fix warnings found (#38578)
* Turn on argument exception analyzer on runtime, fix failures found
2020-07-01 18:36:56 -07:00
Stephen Toub 3c9fcce29d Disable P/Invoke analyzer (#38550) 2020-06-29 18:06:21 -04:00
Stephen Toub 0ab928b27b Enable CA1805 (#38471) 2020-06-27 16:15:36 -04:00
Stephen Toub 8b36909054 Switch to new Microsoft.CodeAnalysis.NetAnalyzers package (#38346)
And update to the latest beta bits available.
2020-06-25 14:01:46 -04:00
Levi Broderick 997539e7d3 Obsolete PrincipalPermissionAttribute ctor as error (#37536) 2020-06-17 18:57:32 -07:00
buyaa-n ee0aadc3da Fix argument exception warnings on runtime (#35717)
* Fix argument exception warnings on runtime

* Apply feedback

* Addressing feedback and test fix

* Fix test failures

* Fix tests for NetFx run

* Fix suppressed warning for socket.SendAsyn(e) and fix corresponding tests

* Applied feedback
2020-05-15 16:55:30 -04:00
Stephen Toub 83e56c474a Update to v3.0.0 of Microsoft.CodeAnalysis.FxCopAnalyzers (#36318) 2020-05-13 17:07:11 -04:00
Alex Villarreal 61733e21bb Enable xunit1024 (#34512)
* Enable analyzer rule xUnit1024

* Remove redundant test in System.Text.Json

The very next method is a Theory with inline data that tests this
exact scenario.

* Rename test methods in System.Text.Json

* Rename test methods in System.ComponentModel.Annotations

* Private methods -> local functions in System.Text.Json

* Rename test methods in System.Collections.Immutable

For RemoveNonExistingTest, just moved the logic from the single-use
helper into the method with the Fact attribute.

* Rename test methods in System.Globalization

* Rename test methods in System.Runtime.Extensions

In Math.cs, removed Round_Decimal_Digits Fact which manually tested
cases included in the MemberData of a Theory with the same name.

* Rename test methods in System.Private.Uri

* Rename test methods in System.Runtime.WindowsRuntime.UI.Xaml

* Rename test methods in System.Security.Cryptography.X509Certificates

* Rename test methods in System.Reflection

* Remove redundant test in System.IO.FileSystem.Watcher

Theory EndInit_ResumesPausedEnableRaisingEvents alredy tests
the same scenario as the removed Fact of the same name.

* Rename test methods in System.IO.FileSystem.Watcher

* Rename test methods in System.Composition.Runtime

* Rename test methods in System.Drawing.Primitives

* Rename test methods in System.Reflection.Emit

* Rename test methods in System.Text.RegularExpressions

* Private methods -> local functions in System.Threading.Tasks.Parallel

* Rename test methods in System.Threading.Tasks.Parallel

* Rename test methods in System.Threading.Tasks

* Simplify tests in System.Threading

* Rename test methods in System.Threading

* Rename test methods in Microsoft.VisualBasic.Core

* Rename test methods in System.DirectoryServices.AccountManagement

* Private methods -> local functions in System.Text.Encoding

* Rename test methods in System.Text.Encoding

* Rename test methods in System.Security.Cryptography.Primitives

* Rename test methods in System.Runtime.Numeric

* Rename test methods in System.CodeDom.Tests

* Rename test methods in System.Reflection.Emit.ILGeneration

* Rename test methods in System.Composition.AttributedModel

* Rename test methods in System.Data.DataSetExtensions

* Rename test methods in System.Runtime

* Rename test methods in System.Runtime.InteropServices

* Remove redundant test in System.ServiceModel.Syndication

* Rename test methods in System.ServiceModel.Syndication

* Rename test methods in System.Data.Common

* Rename test methods in System.Security.Cryptography.Xml

* Private methods -> local functions in System.Security.Cryptography.Xml

* Simplify tests in System.Security.Cryptography.ProtectedData

* Replace private methods with local functions...

In System.Security.Cryptography.Algorithms

* Rename test methods in System.Security.Cryptography.Algorithms

* Simplify tests code in System.Collections.Concurrent

* Rename test methods in System.Drawing.Common

* Rename test methods in System.Data.OleDb

* Rename test methods in System.ComponentModel.TypeConverter

* Rename test methods in System.Web.HttpUtility

* Rename test methods in System.Linq

* Private method -> local function in System.Linq

* Rename test methods in System.Memory

* Rename test methods in System.IO.IsolatedStorage

* Rename test methods in System.DirectoryServices.Protocols

* Rename test methods in System.Globalization.Extensions

* Private methods -> local functions in System.Globalization.Extensions

* Rename test methods in System.IO.Compression

* Rename test methods in System.Security.Cryptography.Encoding

* Rename test methods in Microsoft.Win32.Registry

* Rename test methods in System.IO.UnmanagedMemoryStream

* Rename test methods in System.Collections

* Rename test methods in System.Collections.Specialized

* Rename test methods in System.Private.Xml

* Rename test methods in System.IO.FileSystem

* Rename test methods in System.Diagnostics.StackTrace

* Rename test methods in System.Diagnostics

* Improve some test method renames

* Minor nit fixing

* More improvements to test method names
2020-04-08 06:58:54 -04:00
Stephen Toub d1006ce950 Update analyzer versions and fix violations (#34041) 2020-03-24 22:00:45 -04:00
Stephen Toub 864b84f6af Re-disable CA2010 (#32872)
Apparently there were missed warnings that are now being treated as errors due to a PR that raced with mine yesterday to update the CodeAnalysis.ruleset file.
2020-02-26 11:33:53 -05:00
Stephen Toub 359f19db96 Update CodeAnalysis.ruleset to list every roslyn analyzers rule (#32814) 2020-02-25 16:58:19 -05:00
Stephen Toub 5d9c9daf0d Enable CA1827 (use Any() instead of Count() compared to 0) (#31983) 2020-02-08 20:01:59 -05:00
Viktor Hofer 6afe96cc2e Converge common msbuild properties and targets (#338)
* Converge common msbuild properties and targets

Moving common msbuild properties and targets into the repo root.

* Consolidate analyzers logic into the repo root

Consolidating msbuild analyzers logic centrally in the repo root and
adding a property switch `EnableAnalyzers` to enable analyzers. We
still need to import the Analyzers.props file unconditionally as
libraries currently doesn't use the PackageReference logic in ref and
src projects and instead uses a depproj to create a props file
dynamically.

* More cleanup to fix CoreLib build
2019-12-01 11:01:39 +01:00