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

39 Коммитов

Автор SHA1 Сообщение Дата
Paul M Cohen a8367c03a4
Update editorConfig with preferred C#/VB setting 1/3 (#11056)
* Update editorConfig with prefered values and separate C# from VB where they conflict.

* Add dotnet_separate_import_directive_groups = false to VB section

* Merge .editorConfig with main

* Merge editor.config
2024-03-22 09:28:13 -07:00
Jeremy Kuhne 66f0b18fd2
Remove redundant casts (#11088)
This enables another batch of analyzers. The vast majority of changes were adding the rule for redundant casts. Removing them was done with the code fix for the solution.
2024-03-20 13:42:15 -07:00
Jeremy Kuhne 4f1b6dbfc2
Enable more analyzers (#11081)
Enable another batch of analyzers.

Make a pass cleaning up DesignerHost based on feedback from earlier PRs. (Modern patterns, duplicated docs not needed, etc.)
2024-03-20 10:02:43 -07:00
Jeremy Kuhne 5c38a917d2
Enable more code analyzers (#11073)
Enable a number of additional code analyzers. One of the more impactful ones here is that we don't want to throw "runtime" exceptions or Exception itself. Changed a number of `Exception` instances to `InvalidOperationException`.
2024-03-19 10:39:50 -07:00
Jeremy Kuhne 5fe4b7d6a4
Remove unused code (#11057)
This enables a number of additional analyzers. The key one is turning unused code into warnings. Ends up we had quite a bit of unused parameters and fields.

I've tried to err on the side of caution when properties or methods might be used in the designer.

This also enforces using switch expressions when possible.

Other enablements (that didn't change much):

- Use keywords for types (int over System.Int) is now a warning
- Use null propagation is  now a warning
- Precompiled regex is now an error
- No protected members in sealed types
- Suppression format checks
2024-03-15 12:24:19 -07:00
Jeremy Kuhne 5dce90f12e
Clean up most of the analyzer info (#11050)
This turns a number of the code analyzers into warnings and fixes them. Most of the outstanding messages are fixed.

It wasn't particularly easy to break this up as the analyzers are pretty squidgy about reporting what is outstanding. Everything from this point should be much more focused.

We have significant weirdness with collection initialization syntax. It is ambiguous for most of our collection types and AddRange. Behavior varies between debug and release. Hopefully adding params of span overloads will address the ambiguity issue so that auto-fixes will actually create code that builds.
2024-03-14 10:46:43 -07:00
Jeremy Kuhne b1b2c543b0
Finish cleaning member naming (#11049)
This finishes addressing member names to allow making the analyzer a failure.

There is still room for improvement on some of these member names (notably abbreviations).

This change also makes specifying accessiblity modifiers an error and warns about adding the readonly modifier (not an error to facilitate iterating in VS).
2024-03-13 17:46:54 -07:00
Jeremy Kuhne e082b5e727
More naming fixes (#11045)
Bringing naming in-line with analyzers and adding appropriate suppressions where we can't satisfy the analyzer.

This is the first step. Trying to keep these to less than 100 files.
2024-03-12 22:13:06 -07:00
Jeremy Kuhne 31ca05ffca
More analyzer fixes. (#11044)
- Suppress naming inheritance for shipped API and make it an error.
- Fix qualification simplification and make it an error.
- Tweak some .Site service calls to use the helper (they were causing the analyzer to crash as written)
2024-03-13 00:13:51 +00:00
Jeremy Kuhne e14d056490
Use concrete types (#11043)
Fixes CA1859 and turns it into an error. Ignores it for test projects.

CA1859 Use concrete types when possible for improved performance
2024-03-12 16:33:58 -07:00
Jeremy Kuhne 76aaab4d74
Clean doc analyzer messages (#11042)
This cleans up doc analyzer messages and turns the <para> message into a failure.

It also suppresses CA1861 in tests, which accounts for over 4000 hits.

Lastly it suppresses the TheoryData message and opens an issue to track fixing these.
2024-03-12 20:45:32 +00:00
Lachlan Ennis f8f5465a5e
Enable `IDE0008` / `IDE0090` analyzers (#10502)
* Fix IDE0008 - Use explicit type instead of 'var'

* Fix IDE0090 - 'new' expression can be simplified

* Fix CS0436 error

* Undo ComScope changes

* Fix IDE0008 - Use explicit type instead of 'var'

* Fix IDE0090 - 'new' expression can be simplified

* Revert "Fix CS0436 error"
2024-01-04 16:00:55 -08:00
Jeremy Kuhne fc705dc07a
Move common dialogs to CsWin32 and clean printing (#10471)
We can't (yet) directly use CsWin32 directly for the common dialogs due to packing differences between 32 and 64 bit. We target AnyCPU and CsWin32 doesn't have the ability to force a particular platform definition. For now, I'm copying in CsWin32 defines from a platform targetted project.

Hopefully we'll eventually get .NET support for specifying packing per platform. Also investigating getting a feature added to CsWin32 to mitigate this for us.

This does a pass through all of the print code to clean to style guides.

Plan is to follow up with an attempt to update System.Drawing to CsWin32 code.
2023-12-13 11:40:54 -08:00
Jeremy Kuhne e05bc2fdcc
Add coding style documentation (#10441)
Add a more detailed document on our team coding style.

To demonstrate code to the style standard I've updated the code in the Buttons subfolder. Also updated a few files from Primitives. Informational messages in the updated files are now greatly reduced.

Some of the things done:

- Fix spelling
- Use ternary operators
- Use target-typed new
- Fix some internal parameter names
- Use expression bodies
- Use pattern matching
- Add argument names for bools and nulls
- Remove regions

Thread static naming and shipped public API naming issues aren't easily addressable without suppressions. Added a global suppression file to suppress these particular issues to make the code less difficult to read. We shouldn't put other types of suppressions in this file.

Note that for some reason RadioButton.PerformAutoUpdates was getting the TypeDescriptor to clear sibling RadioButtons. I've set the property directly as this is significantly more performant and friendly to trimming.

PaddingConverter was unnecessarily complicated in creating it's strings. `int` to string never is impacted by culture.
2023-12-07 14:32:15 -08:00
halgab eea628608e
Set file scoped namespace declaration in editorconfig (#10381) 2023-11-26 22:36:29 -08:00
Leaf Shi dd32e99efa
Update .editorconfig to add comment for file_header_template 2023-08-07 15:14:13 +08:00
Leaf Shi f38437894c
Update comment for file_header_template 2023-08-02 17:57:26 +08:00
Leaf Shi e93e2a97a7
Remove file_header_template from vb files
I always get the error ".dotnet\sdk\8.0.100-preview.6.23330.14\Roslyn\Microsoft.VisualBasic.Core.targets(43,5): error MSB6006: (NETCORE_ENGINEERING_TELEMETRY=Build) "vbc.dll" exited with code 1.", so try remove file_header_template from vb files firstly
2023-08-01 18:33:13 +08:00
Leaf Shi 2d00f66d59 Resolve conflicts 2023-07-31 23:39:32 -07:00
Leaf Shi ad0a844cca Changing all files to 2-line header 2023-07-31 23:13:38 -07:00
Tanya Solyanik f44bf753a4
IDE to report unused usings as errors. (#9604)
IDE will report unused usings as errors. CLI has warnings as errors enabled for most projects, thus the CLI build is less affected.
2023-07-31 10:08:26 -07:00
Leaf Shi f8c5d1a8dc Add file_header_template to .editorconfig file 2023-07-31 03:15:46 -07:00
Jeremy Kuhne c13add1ede
Cleanup for utilization of target new (#9527)
Tweaks the editor config settings to encourage behavior that matches our coding style:

- We prefer `Foo foo = new()` over `var foo =`.
- `var` for built in types is an error
- Expression bodied members are always ok

A number of the rules got added by just using the editor. I'll continue to iterate.

Changed a big chunk of the code to use target typed new using fixers and regexe's for the majority of the changes.
2023-07-20 16:37:36 -07:00
Jeremy Kuhne 0e9800d626
Final pass through PropertyGrid (#5312)
One last code cleanup pass for the PropertyGrid related code.
2021-07-22 13:27:03 -07:00
Jeremy Kuhne b80b266bbf Clean messages for PropertyGrid classes
Clean code to get to 0 messages in the Error List pane for most PropertyGrid related classes.

- Tweak var rules to only complain when using var for intrinsics
- Clean up comments
2021-07-02 22:14:48 -07:00
vladimir-krestov 64c7a3b78d
Adding a new code style rule (IDE0005) (#5052)
* Add a new code style rule (IDE0005)
Rule IDE0005 - "Remove unnecessary import"
It's necessary to have VS warnings, if there are forgotten extra usings in files.

To track files with this style issues,
it's necessary to add `EnforceCodeStyleInBuild` flag to all project files.
To do that Directory.Build.props is used.
If not to add this flag, there won't be warnings when building.
There will be warnings in VS only.
2021-06-11 13:21:32 -07:00
Igor Velikorossov 973db87dca
Editor Guidelines config (#4836)
https://marketplace.visualstudio.com/items?itemName=PaulHarrington.EditorGuidelines
2021-04-24 15:37:13 +10:00
Tanya Solyanik f57a55be64
ensure that editor config follows runtime coding style (vars when type is obvious) (#4334) 2020-12-08 10:21:07 +11:00
Adam Yoblick 5cca29c33c move .net diagnostic to the right area under *.cs 2020-10-09 17:32:24 -05:00
Klaus Löffelmann e6bc7b037f
Update Visual Basic Test-Template-Project (#3703) 2020-08-12 13:46:58 +10:00
Igor Velikorossov f2739b430f
Update Microsoft.CodeAnalysis.PublicApiAnalyzers (#3157) 2020-04-29 17:10:16 +10:00
Paul M Cohen bf62e48ad3 Delete comments that don't make sense, no code changes (#2718) 2020-01-15 10:37:42 -08:00
Paul M Cohen babe979883 Update .editorConfig to add support for VB and move all dotnet… (#2715) 2020-01-15 17:44:55 +11:00
Andrew Arnott 4126ab1b79 Enable several whitespace StyleCop rules (#2651)
Mostly the rules are around blank line placement. But I also enabled the 'no trailing whitespace' rule.
2020-01-07 13:21:11 +11:00
Judit Varsanyi Rozsa dc8f9774ca
add resx config (#548)
* add resx config

* add xlf config
2019-03-11 11:12:53 -07:00
Sam Harwell 558b0aed39 Verify copyright headers in CI (#213)
* Install StyleCop Analyzers and disable all rules

* Enable file header validation
2019-01-30 15:14:58 -08:00
Zachary Danz ac4aadf6a8
charset utf-8 (#205)
* charset utf-8

* bom tho

* Update .editorconfig to remove end_of_line

* move charset and insert_final_newline to *.cs section

* Update .editorconfig to handle case of multi-line string with intended spaces at end of line

* moving (*) section back to master except insert_final_newline
2018-12-11 09:53:27 -08:00
Adam Yoblick 8ad24619ae
Fix missing lines in editorconfig (#89) 2018-11-27 11:25:58 -06:00
Adam Yoblick fa3ecfdda4
added .editorconfig from corefx (#85) 2018-11-27 11:10:37 -06:00