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

StyleCop.Resharper + Code Cleanup + StyleCop rules #13

Open
sguryev opened this issue Nov 19, 2018 · 5 comments
Open

StyleCop.Resharper + Code Cleanup + StyleCop rules #13

sguryev opened this issue Nov 19, 2018 · 5 comments

Comments

@sguryev
Copy link

sguryev commented Nov 19, 2018

Hi there.
I have a pretty simple task and last 4 hours I have been trying to implement it with almost no luck.
I hope you will be able to advise me and help.

My config is:
VS2017 15.9.1
R# Ultimate 2018.2.3
StyleCop by JetBrains 2018.2.0

StyleCop settings:
image
image

Code Cleanup profile:
image

My goals are:

  1. Generate the header for each file
  2. Generate the doc stubs for each (public) member
  3. Enable build errors for related (1, 2) StyleCop issues

My steps (story):
I have installed the StyleCop R# extension and restart the VS. I have got the StyleCop Code Cleanup profile and enabled the Create XML doc stub option. After the cleanup I was able to get the header and member docs. Unfortunately there was no company name int the header and it was not complained with one of the StyleCop rule. So I have started searching a way to resolve it.

I have realized that there is no other way for comfortable editing the Settings.StyleCop file except installing the VS StyleCop extension (by right mouse button click on a project). I was able to update the company name and copyright text there. After running the code cleanup again I have lost the summary section of the header (which has been generated as copy of the doc for the class in the file). I have tried to play with the R# header settings but it looks like StyleCop wins over the R# for header config. Based on the pretty old blog post here there was a setting:
image
allowed to configure the header cleanup. But it has gone.

My questions are:

  1. How to config the header in order to add the summary and copyright (both are generated) at the same time with Code Cleanup?
  2. Should I install StyleCop as the separate VS extension or not in order to use the R# one?
  3. How can I fix this error during opening the StyleCop settings (exception occurred while loading one of the StyleCop add-ins TypeLoadException from assembly TestPlatform.ObjectModel)
    image.
    Right now I have to disable the VS StyleCop, restart the VS, enable the plugin and restart again. It works till the next VS restart.

I have noticed that Alt+Enter R# fix add the full header (copyright + summary):
image
image
But the Code Cleanup one add a copyright only:
image
And Code Cleanup replaces the full header with the short one during the cleanup process.

Thank you!

@sguryev
Copy link
Author

sguryev commented Nov 19, 2018

UPD: After R# repairing I can't run the VS StyleCop even after reinstalling the extension

@sguryev
Copy link
Author

sguryev commented Nov 19, 2018

2277 | ERROR | LegacySitePackage failed for package [StyleCop.VisualStudio.StyleCopVSPackage, StyleCop.VisualStudio, Version=5.0.0.0, Culture=neutral, PublicKeyToken=f904653c63bc2738]Source: 'mscorlib' Description: Could not load type 'Microsoft.VisualStudio.TestPlatform.ObjectModel.InProcDataCollector.InProcDataCollection' from assembly 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. System.TypeLoadException: Could not load type 'Microsoft.VisualStudio.TestPlatform.ObjectModel.InProcDataCollector.InProcDataCollection' from assembly 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.   at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)   at System.Reflection.RuntimeAssembly.GetExportedTypes()   at StyleCop.StyleCopCore.LoadAddins(String path, Byte[] publicKey)   at StyleCop.StyleCopCore.Initialize(ICollection`1 addInPaths, Boolean loadFromDefaultPath)   at StyleCop.VisualStudio.StyleCopVSPackage.InitializeMenus()   at StyleCop.VisualStudio.StyleCopVSPackage.Initialize()   at Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsPackage.SetSite(IServiceProvider sp) | {629EB7CC-69C2-43AC-9BC9-482B0F810C4E} | 80131522 | VisualStudio | 2018/11/19 20:35:07.976
-- | -- | -- | -- | -- | -- | --
2278 | ERROR | SetSite failed for package [StyleCop.VisualStudio.StyleCopVSPackage, StyleCop.VisualStudio, Version=5.0.0.0, Culture=neutral, PublicKeyToken=f904653c63bc2738](null) | {629EB7CC-69C2-43AC-9BC9-482B0F810C4E} | 80131522 | VisualStudio | 2018/11/19 20:35:07.979
2279 | ERROR | End package load [StyleCop.VisualStudio.StyleCopVSPackage, StyleCop.VisualStudio, Version=5.0.0.0, Culture=neutral, PublicKeyToken=f904653c63bc2738] | {629EB7CC-69C2-43AC-9BC9-482B0F810C4E} | 80131522 | VisualStudio | 2018/11/19 20:35:07.984

@sguryev
Copy link
Author

sguryev commented Nov 19, 2018

Generated by Code Cleanup:
image

Generated by Alt+Enter:
image
image

First one doesn't match the rule SA1623 PropertySummaryDocumentationMustMatchAccessors

@matkoch
Copy link
Collaborator

matkoch commented Dec 10, 2018

Hey Sergey, sorry for the delay. Could you clarify where these settings are coming from? image

@sguryev
Copy link
Author

sguryev commented Dec 10, 2018

Hey @matkoch, thank you for the reply!
I have inserted the link to the initial comment:
image

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

No branches or pull requests

2 participants