* 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
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.
Enable another batch of analyzers.
Make a pass cleaning up DesignerHost based on feedback from earlier PRs. (Modern patterns, duplicated docs not needed, etc.)
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`.
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
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.
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).
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.
- 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)
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.
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.
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.
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
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.
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
* 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.
* 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