Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fxcop] Fixes for Wox.Plugin (1of3) #7457

Merged
merged 31 commits into from
Oct 26, 2020

Conversation

avneet-kr
Copy link
Contributor

@avneet-kr avneet-kr commented Oct 21, 2020

Summary of the Pull Request

This PR includes fixes for most Fxcop errors from Wox.Plugin.
Note: Since this 1of3 PRs, I will add the commit to enable Fxcop for Wox.Plugin in the separate 3rd PR

PR Checklist

  • Applies to [Chore] Enable Static analysis (FxCopAnalyzers) on C# Projects #5129
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Requires documentation to be updated
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

Info on Pull Request

Changes included:

  1. Added CultureInfo (CA1307: Specify StringComparison for clarity / CA1304: Specify CultureInfo)
  2. Check arguments and throw ArgumentNullException (CA1062: Validate arguments of public methods)
  3. Changed url parameter from string to System.Uri and added null checks (CA1054: URI parameters should not be strings)
  4. Rethrow exception without specifying the exception explicitly (CA2200: Rethrow to preserve stack details)
  5. Changed from Collection property to methods for PluginMetadata::ActionKeywords (CA2227: Collection properties should be read only)
  6. Changed from Collection property to methods for Result::GetTitleHighlightData (CA2227: Collection properties should be read only)
  7. Made Collection property read-only and added parameter in constructor for Result::SubTitleHighlightData (CA2227: Collection properties should be read only)
  8. Made Collection property read only and added parameter in constructor for ResultUpdatedEventArgs::Results (CA2227: Collection properties should be read only)
  9. CA1507: Use nameof in place of string
  10. Removed initialization for ThemeManager::_disposed (CA1805: Do not initialize unnecessarily)
  11. Changed Query::Terms array property to ReadOnlyCollection and added private set (CA1819: Properties should not return arrays)
  12. CA1060: Move P/Invokes to NativeMethods class
  13. CA1806: Do not ignore method results
  14. CA2101: Specify marshaling for P/Invoke string arguments
  15. Removed unnecessary empty interface IFeatures (CA1040: Avoid empty interfaces)
  16. Added comments for CultureInfo (CA1307: Specify StringComparison for clarity / CA1304: Specify CultureInfo)

Validation Steps Performed

All changes were tested by building and running all unit tests

@avneet-kr avneet-kr requested a review from a team October 21, 2020 22:06
@avneet-kr avneet-kr changed the title [fxcop] Fixes for Wox.Plugin [fxcop] Fixes for Wox.Plugin (1of3) Oct 22, 2020
… (CA1054: URI parameters should not be strings)
…nKeywords (CA2227: Collection properties should be read only)
…ightData (CA2227: Collection properties should be read only)
… for Result::SubTitleHighlightData (CA2227: Collection properties should be read only)
… for ResultUpdatedEventArgs::Results (CA2227: Collection properties should be read only)
…rivate set (CA1819: Properties should not return arrays)
…terfaces)

- Removed IFeatures interface and references
- Renamed IFeatures.cs to IContextMenu.cs according to guidelines
@@ -51,9 +52,10 @@ public static void Copy(this string sourcePath, string targetPath)
#pragma warning restore CS0168 // Variable is declared but never used
{
#if DEBUG
throw e;
throw;
#else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I don't think we need these #if DEBUG throw statements.

@avneet-kr
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@crutkas
Copy link
Member

crutkas commented Oct 24, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@ryanbodrug-microsoft ryanbodrug-microsoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@avneet-kr avneet-kr merged commit ca1e5d1 into microsoft:master Oct 26, 2020
TobiasSekan pushed a commit to TobiasSekan/PowerToys that referenced this pull request Oct 28, 2020
* Added CultureInfo (CA1307: Specify StringComparison for clarity / CA1304: Specify CultureInfo)

* Check arguments and throw ArgumentNullException (CA1062: Validate arguments of public methods)

* Changed url parameter from string to System.Uri and added null checks (CA1054: URI parameters should not be strings)

* Rethrow exception without specifying the exception explicitly (CA2200: Rethrow to preserve stack details)

* Changed from Collection property to methods for PluginMetadata::ActionKeywords (CA2227: Collection properties should be read only)

* Changed from Collection property to methods for Result::GetTitleHighlightData (CA2227: Collection properties should be read only)

* Made Collection property read-only and added parameter in constructor for Result::SubTitleHighlightData (CA2227: Collection properties should be read only)

* Made Collection property read only and added parameter in constructor for ResultUpdatedEventArgs::Results (CA2227: Collection properties should be read only)

* CA1507: Use nameof in place of string

* Removed initialization for ThemeManager::_disposed (CA1805: Do not initialize unnecessarily)

* Changed Query::Terms array property to ReadOnlyCollection and added private set (CA1819: Properties should not return arrays)

* CA1060: Move P/Invokes to NativeMethods class

* CA1806: Do not ignore method results

* CA2101: Specify marshaling for P/Invoke string arguments

* Removed unnecessary empty interface IFeatures (CA1040: Avoid empty interfaces)

- Removed IFeatures interface and references
- Renamed IFeatures.cs to IContextMenu.cs according to guidelines

* Added comments for CultureInfo (CA1307: Specify StringComparison for clarity / CA1304: Specify CultureInfo)

* Added localization for Wox.Plugin and localized strings in FilesFolders.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants