This starts moving the tests to a single test root folder. That plays
better with `Directory.*` files, `.editorconfig` files, etc. (where we
can better align these with WPF). This will also help a bit with
`MAX_PATH`.
Moved tests are picking up the default Microsoft Shared key. The intent,
however, is to move all tests to the Open Shared key when the move is
complete.
There were a few marked as TODO. This makes them back into warnings with the exception of IDE0059 which is "Unnecessary assignment of a value". That is now a suggestion. Some of the fixes for IDE0059 are in this commit, others will follow as there are a lot of failures on that one.
Also remove test global suppression files
CA1508 finds these, but it has many false positives from native calls and Debug asserts.
I've fixed a batch of real issues and tweaked some code to not get false positives. Won't be able to turn this one on by default, but I'll make a few more passes to find real places where there are issues. (There are over 200 hits.)
Considering making this one a suggestion, but still leaning towards no because of the false positives.
This removes code that was only used by tests historically. MAUI as mentioned in the code is an internal legacy test stack piece.
Also enable a number of other analyzers and delete some unused code in PlatformDetection.
Our code styles were in a number of files. Consolodate into .editorconfig for discoverability.
I've also tried to deviate as little as possible in tests. This required fixing a number of analyzer issues in test code.
Also add some more build related solution folders for clarity and discoverability.
Want to keep false positives to a minimum, even in "Messages". The var message was coming up a lot when editing files where we wouldn't want to "fix" it, so I've silenced it.
There are a lot of "if statement can be simplified" messages in our files. I went through and fixed a bunch that came up when I was working on other things to validate the usefulness. It is the better choice at least 80% of the time, so I'm leaving it on.
Changes were primariliy made using the automated fixes. Flipped a few conditional blocks, again with the tooling.
Updates to the latest release of CSWin32 and updates code where necessary.
Also add back explicit span casts where VS IntelliSense is unable to differentiate. Without this contributors would need to have access to internal preview feeds.
* Moved to SDK RC2 to get the same build errors in VS and CLI build and be able to fix them.
Before this change the IntPreview version of VS was correctly complaining about a redundant cast(IDE0004) in ToolStrip.cs
g.DrawLines(SystemPens.ControlText, (ReadOnlySpan<Point>)
[
new(verticalBeamStart, _lastInsertionMarkRect.Y), new(verticalBeamStart, _lastInsertionMarkRect.Bottom - 1),
new(verticalBeamStart + 1, _lastInsertionMarkRect.Y), new(verticalBeamStart + 1, _lastInsertionMarkRect.Bottom - 1)
]);
But the CLI build required this cast.
After the upgrade to RC2, IDE0300 - Collection initialization can be simplified - became more robust and required code fixes that use collection expressions applied to the solution.
* Fix editorConfig for VB
# IDE0001: severity = silent
# IDE0002: severity = silent
* Split files and cleanup
* Clean up comments and fix errors for Option OptionExplicit On
Ignore ExceptionUtils and Utils they are being completely replaced and VbUtils is temporary it will be replaced by ExUtils
* Update src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/CantStartSingleInstanceException.vb
Co-authored-by: Loni Tra <lonitra@microsoft.com>
* Update src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/ConsoleApplicationBase.vb
Co-authored-by: Loni Tra <lonitra@microsoft.com>
* Update src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/User.vb
Co-authored-by: Loni Tra <lonitra@microsoft.com>
* Update src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/Helpers/NativeTypes.vb
Co-authored-by: Loni Tra <lonitra@microsoft.com>
* Update src/Microsoft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/ConsoleApplicationBase.vb
Co-authored-by: Loni Tra <lonitra@microsoft.com>
* Replace douple quote ("") where String.Empty
* Sync PR Feedback
* Fix comments and PR feedback
* Replace "" with String.Empty
* Fix XML Comments
* Add See Cref's
* Minor Cleanup of ExceptionUtils
* Update src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/NetworkTests.cs
Co-authored-by: Loni Tra <lonitra@microsoft.com>
* Update src/Microsoft.VisualBasic/tests/UnitTests/Microsoft/VisualBasic/Devices/NetworkTests.cs
Co-authored-by: Loni Tra <lonitra@microsoft.com>
* Fix extra paren from PR Review
* Remove comment download is test now
* Remove Option statement from VB because its in Project file
* Rename Utils to Utils1 to avoid temporary name clash. Class will be remove in future PR
* Revert rename of Utils back to Util
---------
Co-authored-by: Loni Tra <lonitra@microsoft.com>
* 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