Giter Site home page Giter Site logo

stylecop.resharper's Introduction

Obsolete

Warning

This extension is deprecated and won't receive any updates (except for compatibility) due to the discontinuation of the original StyleCop project. Please visit their repository for further considerations.

StyleCop for ReSharper

ReSharper

StyleCop analyzes C# source code to enforce a set of style and consistency rules. StyleCop for ReSharper is an extension for ReSharper that will run StyleCop analysis as you type, display the violations inline in the editor and provide quick fixes for some violations. It will also configure ReSharper to use default settings that match StyleCop rules.

Gitter

About this repo

The code in this repo is the ReSharper extension taken from the GitHub StyleCop repo, which is itself an unofficial fork of the StyleCop project hosted at CodePlex.

The CodePlex project was maintained by Andy Reeves for several years, and was on indefinite hiatus from March 2014 until recently, when @csdahlberg took over and restarted development.

The GitHub fork and the CodePlex fork have been independently developed, although the changes don't appear to overlap. The GitHub repo concentrated on updating the ReSharper extension, while the CodePlex repo has been making changes to StyleCop itself. Hopefully, these changes can be reconciled (it's more complicated than just a pull request - for example, the CodePlex repo is still on Mercurial).

stylecop.resharper's People

Contributors

citizenmatt avatar matkoch avatar plr108 avatar sanjayguntur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stylecop.resharper's Issues

Installation Error with latest StyleCop Extension (2019.3.0)

image

Installation errors shows:

Completed with 5 errors.
05:20:10.659 |E| Error resolving type StyleCop.Rule from assembly “StyleCop, Version=6.1.0.0, Culture=neutral, PublicKeyToken=f904653c63bc2738”, request originating from assembly “ReSharperPlugin.StyleCop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”. Could not find a referenced assembly by the TT_ASSEMBLYREF token.
05:20:10.735 |E| Error resolving type StyleCop.Violation from assembly “StyleCop, Version=6.1.0.0, Culture=neutral, PublicKeyToken=f904653c63bc2738”, request originating from assembly “ReSharperPlugin.StyleCop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”. Could not find a referenced assembly by the TT_ASSEMBLYREF token.
05:20:10.741 |E| Error resolving type StyleCop.StyleCopCore from assembly “StyleCop, Version=6.1.0.0, Culture=neutral, PublicKeyToken=f904653c63bc2738”, request originating from assembly “ReSharperPlugin.StyleCop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”. Could not find a referenced assembly by the TT_ASSEMBLYREF token.
05:20:10.743 |E| Error resolving type StyleCop.StyleCopCore from assembly “StyleCop, Version=6.1.0.0, Culture=neutral, PublicKeyToken=f904653c63bc2738”, request originating from assembly “ReSharperPlugin.StyleCop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”. Could not find a referenced assembly by the TT_ASSEMBLYREF token.
05:20:10.744 |E| Error resolving type StyleCop.Rule from assembly “StyleCop, Version=6.1.0.0, Culture=neutral, PublicKeyToken=f904653c63bc2738”, request originating from assembly “ReSharperPlugin.StyleCop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”. Could not find a referenced assembly by the TT_ASSEMBLYREF token.

Code clean up adds explicit lambda expression parameter types

I talked with the Resharper support and they said I should opene an issue on the StyleCope.Resharper extension.

The problem is that if I have installed the StyleCop.Resharper extension every time I do a code cleanup explicit types are added for lambda expression. But on the other hand stylecop says, redundant explicit type parameter on lambda. (I like the implicit using as it was before. Actual I found no option to configure the old behavior.)

image

image

Example Project and Video
Aufzeichnung 2023-10-26 082844.zip

XML Header comment does not appear

I report this issue here because the support team of Resharper recommends me.
Since I updated my Resharper to version 2019.2.3 there is no hint (light bulb) about missing header comment.
Usually I get a hint and then I just need to press "Ctrl"-"." to see the list of hints and choose "Insert header comment". See attachment. I use also extension "StyleCop By Jetbrains" version 2019.2.

What I did was, I installed VS2019 and Resharper 2018.3 together with StyleCop By Jetbrains version 2018 and then I installed VS2017 because of an old TFS tool that runs only on VS2017.
The Resharper worked well (can detect and add header comment) at that time.
After I installed the ReSharper update 2019.2.3. and also StyleCop 2019.2. I get the issue.
All of my team members experience also the same issue.

How can I get that feature back, so Resharper can generate the header comment for me.
Please help. Thank you in advance.

Extensions
NoHint
StyleCopOptionInResharper

This is the context menu looks like if I deactivate in Project Build Property the option "XML documentation file"
XmlDocumentationFileOff

This is the context menu looks like if I activate in Project Build Property the option "XML documentation file"
XmlDocumentationFileOn

But if I choose the option "add xml-doc" it will generate empty comment like following (because the option is from Visual Studio not from StyleCop!)
CommentEmptyHeader

SA1009 False positive for ValueTuple

The following code causes 2 false positives for SA1009:
public static List<(string, string)> GetValueTuple()
{
return new List<(string, string)>();
}

switch pattern problem

Is it possible to mute only this errors type somehow? I've tried mute it by "Ignore all such Errors" - but it doesn't help me.

Or will be much better, if I can configure StyleCop rules to work with switch patterns. Cause there is now error, this is correct code.

image

Analysis not disabled when referencing StyleCop.Analyzers

I have a project using the StyleCop.Analyzers package in order to use newer c# language features. Here are my NuGet references.
Untitled
However when using unsupported langauge features the ReSharper StyleCop plugin will still mark it as a syntax error.
Untitled
In the StyleCop options menu in ReSharper it states that analysis would be disabled when StyleCop.Analyzers is referenced, so i had expected that it would not analyze the code.

Generic Type Aliases removed

The StyleCop Resharper plugin is removing the generic types in my generic type alias. Even with all rules turned off, when I run the resharper "cleanup" with the only item in the cleanup tasks being the "fix stylecop violations" the cleanup removes the types on my generic alias:

namespace TG.Gateway.Tests.Translator.Victim
{
    using ExpectedActionsGenerator = Func<VictimScenario, InboundMessage, IReadOnlyCollection<VictimScenario.ExpectedCrossTrackeeAction>>;

is turned into

namespace TG.Gateway.Tests.Translator.Victim
{
    using ExpectedActionsGenerator = Func;

Which causes compilation errors.

If you could reproduce this issue or tell me how to disable this behaviour I'd be very appreciative.

Ability to disable SA0102 in resharper settings

Often new language features come out and there's a lag time before this extension gets the update, and it has false positives and shows compile errors.

It would be nice to be able to disable this one, since during these times (as of this writing, it is C#8 and inline usings) we can turn off the false positive. Instead I have to uninstall the extension and just try to remember to check in periodically until those things are addressed.

Since this is a resharper extension inside of visual studio, both of which are more than capable of catching compile errors, this is a rather unnecessary addition anyway, so it makes sense for it to be an option.

Editing becomes slow in VS with StyleCop plugin

For some reason Resharper started using 2GB of memory every keystroke. This causes me wait a few seconds between each keystroke

Snapshot details:

100.00%   Execute  •  18,835 ms  •  StyleCop.ReSharper.Core.StyleCopRunnerInt.Execute(IProjectFile, IDocument, ICSharpFile)
  100.00%   RunStyleCop  •  18,835 ms  •  StyleCop.ReSharper.Core.StyleCopRunnerInt.RunStyleCop(IDocument)
    100.00%   FullAnalyze  •  18,835 ms  •  StyleCop.StyleCopCore.FullAnalyze(IList)
      100.00%   Analyze  •  18,835 ms  •  StyleCop.StyleCopCore.Analyze(IList, Boolean, String)
        100.00%   RunWorkerThreads  •  18,835 ms  •  StyleCop.StyleCopCore.RunWorkerThreads(Data, Int32)
          100.00%   DoWork  •  18,835 ms  •  StyleCop.StyleCopThread.DoWork(Object)
            100.00%   ParseAndAnalyzeDocument  •  18,835 ms  •  StyleCop.StyleCopThread.ParseAndAnalyzeDocument(SourceCode, DocumentAnalysisStatus)
              100.00%   ParseFile  •  18,835 ms  •  StyleCop.CSharp.CsParser.ParseFile(SourceCode, Int32, ref CodeDocument)
                1.87%   OutOfBounds  •  353 ms  •  StyleCop.ItemList`1.OutOfBounds(Node)
                0.78%   ItemList`1..ctor  •  148 ms  •  StyleCop.ItemList`1..ctor(MasterList, Node, Node)
#stacktrace

"Fix StyleCop violations" removes "using static"

When i run Cleanup Code with Fix StyleCop violations enabled all using static directives are converted into normal using directives, resulting in compile errors.

namespace MyNamespace
{
   using static ClassWithStaticMethods;

becomes

namespace MyNamespace
{
   using ClassWithStaticMethods;

2019.2.0 Showing new and incorrect warnings in several cases

After upgrading I'm suddenly seeing inspection warnings that haven't existed before.

Examples:

  • adding parentheses for non-obvious references
  • Blank lines are redundant
  • Constructor 'xx' is never used, even though it's decorated with [UsedImplicitly]
  • Expression is always null

When the StyleCop plugin is active, those are always showing up as warnings.
It's impossible to control them via any kind of ReSharper settings.

When I choose "Disable StyleCop support" via the icon in the VS status bar, those warnings behave as configured in the ReSharper settings (and disappear when configured to do so).

But with the StyleCop plugin active, there is no way to disable those from showing as warnings.

This is a severe regression from the previous version (2019.1).

Previously all our code files "were green". Now it is no longer possible to determine the required adjustments to achieve code style compliance.

I'm not quite sure though, whether this is a bug in ReSharper or in this StyleCop plugin..?

C# 8.0

Are there any plans of supporting the new syntax of C# 8.0?
For example, if I try to use compound assignment, I get a SA0102 error.

ReSharper always prefixes members with "this"

After installing the StyleCop.ReSharper extension, i noticed that ReSharper always prefixes members with the "this" keyword after i type them, even if i disabled this setting both in the StyleCop file and in ReSharper. I found no way of disabling this behaviour, short of uninstalling the StyleCop.ReSharper extension.

Errors occur while installing StyleCop when using R# 2021.3 EAP 7

Install completed with 3 errors.
  16:27:42.761 ReSharperPlatformVs17_6011e5b0: Error resolving type JetBrains.VsIntegration.Shell.Zones.IVisualStudioEnvZone from assembly “JetBrains.Platform.VisualStudio.Core, Version=777.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325”, request originating from assembly “JetBrains.Platform.VisualStudio.Core, Version=777.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325”. Could not find the type by its FQN. Is assembly qualification specified? True! Is it of our own assembly? True! Is looking into referenced assemblies allowed? False! Was the qualified referenced assembly encountered during lookup? False! Tried loading an implicitly-referenced assembly? False! Were following a forwarder exported type's assembly ref? No!
  16:27:43.236 ReSharperPlatformVs17_6011e5b0: The type “JetBrains.VsIntegration.Shell.Zones.IVisualStudioEnvZone, JetBrains.Platform.VisualStudio.Core, Version=777.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325” is not a module zone because it does not derive from the JetBrains.Application.BuildScript.Application.Zones.IZone interface.
  16:27:43.976 ReSharperPlatformVs17_6011e5b0: The type “JetBrains.VsIntegration.Shell.Zones.IVisualStudioEnvZone, JetBrains.Platform.VisualStudio.Core, Version=777.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325” is not a module zone because it does not derive from the JetBrains.Application.BuildScript.Application.Zones.IZone interface.

https://youtrack.jetbrains.com/issue/RSRP-486818

Support for default without type

When writing return default; instead of return default(T); there is a StyleCop syntax error (SA0102).

I am using the latest verion (2018.3.0).

Code Cleanup with Fix StyleCop violoations do not work.

I don't know who's problem between ReSharper and StyeCop Extension, I will post an issue to ReSharper issue tracker at the same time.

Example as followed image:

All static public classes must be placed before non-static public classes

ReSharper version: 2019.3.1
Visual Studio versions: 2013, 2017, 2019
StyleCop Extension version: 2019.3.1

StyleCop.Resharper + Code Cleanup + StyleCop rules

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!

ReSharper does not apply file header specified in ReSharper options if StyleCop is installed

File Header Text is specified in ReSharper options as:

------------------------------------------------------------------------------------------------------
- $SOLUTION$
- $PROJECT$
- $FILENAME$
- $CURRENT_MONTH$/$CURRENT_DAY$/$CURRENT_YEAR$ $CURRENT_TIME$
- Copyright (c) Abc, Inc. All Rights Reserved
------------------------------------------------------------------------------------------------------

but the generated header is :

// --------------------------------------------------------------------------------------------------------------------
// <copyright company="" file="Class.cs">
//   
// </copyright>
// <summary>
//   
// </summary>
// 
// --------------------------------------------------------------------------------------------------------------------

VS 2019, ReSharper 2021.3.2, StyleCop by JetBrains 2021.3.0

StyleCop.ReSharper doesn't install on the latest build

When installing the extension on ReSharper -> Manage Extensions, the extension no longer installs on 2021.3

Install completed with 3 errors.
  14:02:32.316 ReSharperPlatformVs17_3654ab68: Error resolving type JetBrains.VsIntegration.Shell.Zones.IVisualStudioEnvZone from assembly “JetBrains.Platform.VisualStudio.Core, Version=777.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325”, request originating from assembly “JetBrains.Platform.VisualStudio.Core, Version=777.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325”. Could not find the type by its FQN. Is assembly qualification specified? True! Is it of our own assembly? True! Is looking into referenced assemblies allowed? False! Was the qualified referenced assembly encountered during lookup? False! Tried loading an implicitly-referenced assembly? False! Were following a forwarder exported type's assembly ref? No!
  14:02:32.360 ReSharperPlatformVs17_3654ab68: The type “JetBrains.VsIntegration.Shell.Zones.IVisualStudioEnvZone, JetBrains.Platform.VisualStudio.Core, Version=777.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325” is not a module zone because it does not derive from the JetBrains.Application.BuildScript.Application.Zones.IZone interface.
  14:02:32.583 ReSharperPlatformVs17_3654ab68: The type “JetBrains.VsIntegration.Shell.Zones.IVisualStudioEnvZone, JetBrains.Platform.VisualStudio.Core, Version=777.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325” is not a module zone because it does not derive from the JetBrains.Application.BuildScript.Application.Zones.IZone interface.

Update StyleCop plugin to ReSharper 2021.3 release version

ReShaper code analysis becomes disabled with the installed StyleCop 2021.3.0-eap7 version. There's a bunch of exceptions in the log:

13:30:24.647 |I| AddVsVersionToLogs            | :1                 | JetBrains ReSharper 2021.3 Build 213.0.20211207.74952
13:30:24.654 |I| AddVsVersionToLogs            | :1                 | Running in Visual Studio Professional 2022, Version 17.0.2 (17.0.31919.166), Hive: 17.0_328e9ea2
13:30:24.660 |I| AddVsVersionToLogs            | :1                 | Running on Windows 10 Pro 20H2, build 19042.1348, Professional, Client (Microsoft Windows NT 10.0.19042.0)
13:30:27.447 |I| DpaProtocolServerConnector    | :1                 | Starting frontend
13:30:27.463 |I| DpaProtocolServerConnector    | :1                 | Server created at 52157 port
13:30:27.465 |I| DpaProtocolServerConnector    | :1                 | Running backend from C:\Users\Angelina.Elycheva\AppData\Local\JetBrains\Installations\ReSharperPlatformVs17_328e9ea2\JetBrains.DPA.Ide.VS.Backend.exe at 127.0.0.1:52157 IsInternal:False
13:30:27.466 |I| LogFilesProviderComponent     | :1                 | log file: C:\Users\Angelina.Elycheva\AppData\Local\Temp\JetLogs\JetBrainsLog.JetBrains.2021-12-09T13-29-59.devenv#32732-DPA.Backend.log
13:30:33.265 |I| VsSolutionManager15           | :1                 | VSSolutionManager::OnAfterOpenSolution
13:30:41.147 |W| VsReSharperMainMenuFixesSinceVs16| :1                 | ReSharper menu is not found in the main VS menu.
13:30:41.354 |E| AsyncDescriptorBase           | :1                 | Component StyleCop.ReSharper.Options.HighlightingRegistering construction has failed Exception has been thrown by the target of an invocation. Method not found: 'Void JetBrains.ReSharper.Feature.Services.Daemon.ConfigurableSeverityItem..ctor(System.String, System.String, System.String, System.String, System.String, JetBrains.ReSharper.Feature.Services.Daemon.Severity, Boolean, Boolean, System.String, System.String, System.String)'.

--- EXCEPTION #1/3 [MissingMethodException]
Message = “Method not found: 'Void JetBrains.ReSharper.Feature.Services.Daemon.ConfigurableSeverityItem..ctor(System.String, System.String, System.String, System.String, System.String, JetBrains.ReSharper.Feature.Services.Daemon.Severity, Boolean, Boolean, System.String, System.String, System.String)'.”
ExceptionPath = Root.InnerException.InnerException
ClassName = System.MissingMethodException
Data.ThreadLocalDebugInfo = “DelayedInitializationStrategy.Dispatch: JetBrains.ReSharper.Psi.impl.EditorConfig.EditorConfigService”
HResult = COR_E_MISSINGMETHOD=80131513
Source = StyleCop.StyleCop
StackTraceString = “
  at StyleCop.ReSharper.Options.HighlightingRegistering.Register(StyleCopCore core)
     at StyleCop.ReSharper.Options.HighlightingRegistering.<>c__DisplayClass2_0.<.ctor>b__0(Lifetime temporaryLifetime) in Z:\buildAgent\work\fc1bcfed6a14b2e5\src\dotnet\StyleCop.StyleCop\Options\HighlightingRegistering.cs:line 74
     at JetBrains.Lifetimes.Lifetime.Using(Action`1 action)
”

--- Outer ---

--- EXCEPTION #2/3 [TargetInvocationException]
Message = “Exception has been thrown by the target of an invocation.”
ExceptionPath = Root.InnerException
ClassName = System.Reflection.TargetInvocationException
Data.ThreadLocalDebugInfo = “DelayedInitializationStrategy.Dispatch: JetBrains.ReSharper.Psi.impl.EditorConfig.EditorConfigService”
InnerException = “Exception #1 at Root.InnerException.InnerException”
HResult = COR_E_TARGETINVOCATION=80131604
Source = mscorlib
StackTraceString = “
  at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
     at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
     at JetBrains.Application.Components.ConstructiorBindigns.Activate(ISingletonDescriptor descriptor, Object[] dependencies)
     at JetBrains.Application.Components.SingletonDescriptor`1.CreateInstance(Object[] dependencies)
     at JetBrains.Application.Components.AsyncDescriptorBase.ActivatingComponentState.TryGetSyncImpl()
”

--- Outer ---

--- EXCEPTION #3/3 [LoggerException]
Message = “Component StyleCop.ReSharper.Options.HighlightingRegistering construction has failed Exception has been thrown by the target of an invocation.”
ExceptionPath = Root
ClassName = JetBrains.Util.LoggerException
Data.ManagedThreadName = <NULL>
InnerException = “Exception #2 at Root.InnerException”
HResult = COR_E_APPLICATION=80131600
StackTraceString = “
  at JetBrains.Util.ILoggerEx.LogException(ILogger this, LoggingLevel level, Exception exception, ExceptionOrigin exceptionOrigin, String comment)
     at JetBrains.Util.ILoggerEx.Error(ILogger this, Exception ex, String message)
     at JetBrains.Application.Components.AsyncDescriptorBase.SetCorruptedState(Exception e)
     at JetBrains.Application.Components.AsyncDescriptorBase.ActivatingComponentState.TryGetSyncImpl()
     at JetBrains.Application.Components.AsyncDescriptorBase.StateWithPriorityCache`1.TryGetSync()
     at JetBrains.Application.Components.AsyncDescriptorBase.TryActivate(Object[] dependencyValues)
     at JetBrains.Application.Components.AsyncDescriptorBase.TryGetOrCreateValue()
     at JetBrains.Application.Components.AsyncDescriptorBase.InitializingDependenciesComponentState.TryGetSyncUnsafe()
     at JetBrains.Application.Components.AsyncDescriptorBase.InitializingDependenciesComponentState.TryGetSyncImpl()
     at JetBrains.Application.Components.AsyncDescriptorBase.StateWithPriorityCache`1.TryGetSync()
     at JetBrains.Application.Components.AsyncDescriptorBase.TryGetDependencyValues()
     at JetBrains.Application.Components.AsyncDescriptorBase.TryGetOrCreateValue()
     at JetBrains.Application.Components.AsyncDescriptorBase.GetValue()
     at JetBrains.Application.Components.ComponentContainerEx.GetComponents[TInterface](IComponentContainer container)
     at JetBrains.ReSharper.Feature.Services.Daemon.HighlightingSettingsManagerImpl..ctor(Lifetime lifetime, ShellPartCatalogSet partsCatalogueSet, ILanguages allLanguages, ISettingsStore settingsStore, SettingsCacheManager cacheManger, ILogger logger, HighlightingDefaultSettingValuesProvider defaultSettingValuesProvider, ICalculatedSettingsSchema calculatedSettingsSchema)
     at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
     at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
     at JetBrains.Application.Components.ConstructiorBindigns.Activate(ISingletonDescriptor descriptor, Object[] dependencies)
     at JetBrains.Application.Components.SingletonDescriptor`1.CreateInstance(Object[] dependencies)
     at JetBrains.Application.Components.AsyncDescriptorBase.ActivatingComponentState.CreateInstanceWithReadLock()
     at JetBrains.Application.Components.AsyncDescriptorBase.ActivatingComponentState.TryGetSyncImpl()
     at JetBrains.Application.Components.AsyncDescriptorBase.StateWithPriorityCache`1.TryGetSync()
     at JetBrains.Application.Components.AsyncDescriptorBase.TryActivate(Object[] dependencyValues)
     at JetBrains.Application.Components.AsyncDescriptorBase.TryGetOrCreateValue()
     at JetBrains.Application.Components.AsyncDescriptorBase.InitializingDependenciesComponentState.TryGetSyncUnsafe()
     at JetBrains.Application.Components.AsyncDescriptorBase.InitializingDependenciesComponentState.TryGetSyncImpl()
     at JetBrains.Application.Components.AsyncDescriptorBase.StateWithPriorityCache`1.TryGetSync()
     at JetBrains.Application.Components.AsyncDescriptorBase.TryGetDependencyValues()
     at JetBrains.Application.Components.AsyncDescriptorBase.TryGetOrCreateValue()
     at JetBrains.Application.Components.AsyncDescriptorBase.InitializingDependenciesComponentState.TryGetSyncUnsafe()
     at JetBrains.Application.Components.AsyncDescriptorBase.InitializingDependenciesComponentState.TryGetSyncImpl()
     at JetBrains.Application.Components.AsyncDescriptorBase.StateWithPriorityCache`1.TryGetSync()
     at JetBrains.Application.Components.AsyncDescriptorBase.TryGetDependencyValues()
     at JetBrains.Application.Components.AsyncDescriptorBase.TryGetOrCreateValue()
     at JetBrains.Application.Components.AsyncDescriptorBase.InitializingDependenciesComponentState.TryGetSyncUnsafe()
     at JetBrains.Application.Components.AsyncDescriptorBase.InitializingDependenciesComponentState.TryGetSyncImpl()
     at JetBrains.Application.Components.AsyncDescriptorBase.StateWithPriorityCache`1.TryGetSync()
     at JetBrains.Application.Components.AsyncDescriptorBase.TryGetDependencyValues()
     at JetBrains.Application.Components.AsyncDescriptorBase.TryGetOrCreateValue()
     at JetBrains.Application.Components.AsyncDescriptorBase.InitializingDependenciesComponentState.TryGetSyncUnsafe()
     at JetBrains.Application.Components.AsyncDescriptorBase.InitializingDependenciesComponentState.TryGetSyncImpl()
     at JetBrains.Application.Components.AsyncDescriptorBase.StateWithPriorityCache`1.TryGetSync()
     at JetBrains.Application.Components.AsyncDescriptorBase.TryGetDependencyValues()
     at JetBrains.Application.Components.AsyncDescriptorBase.TryGetOrCreateValue()
     at JetBrains.Application.Components.AsyncDescriptorBase.GetValue()
     at JetBrains.Application.Components.DelayedInitializationStrategy.<Dispatch>b__8_1()
     at JetBrains.Util.Concurrency.ExecutionContextEx.<>c__DisplayClass0_0.<Run>b__0(Object _)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
     at JetBrains.Util.Concurrency.ExecutionContextEx.Run(ExecutionContext context, ContextCallback callback, Object state)
     at JetBrains.Threading.ReentrancyGuard.Execute(String name, Action action)
     at JetBrains.Threading.ReentrancyGuard.ExecutePendingActions()
     at JetBrains.Util.Concurrency.ExecutionContextEx.<>c__DisplayClass0_0.<Run>b__0(Object _)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
     at JetBrains.Util.Concurrency.ExecutionContextEx.Run(ExecutionContext context, ContextCallback callback, Object state)
     at JetBrains.Threading.JetDispatcher.Closure.Execute()
     at JetBrains.Util.Concurrency.WinJetDispatcher.ProcessQueue(Int32 nMinBucket)
     at JetBrains.Util.Concurrency.WinJetDispatcher.ExternalIdleProcessing.OnExternalDriverIdle()
     at JetBrains.VsIntegration.Shell.VsDoIdleDispatcherSink.Microsoft.VisualStudio.OLE.Interop.IOleComponent.FDoIdle(UInt32 grfidlef)
”

13:30:43.225 |E| AsyncDescriptorBase           | :1                 | Component JetBrains.ReSharper.Feature.Services.EditorConfig.EditorConfigHighlightingConverter construction has failed Exception has been thrown by the target of an invocation. Object reference not set to an instance of an object.

StyleCop + ReSharper's cleanup = extra space in razor @helper

Hi, it looks like StyleCop causes ReSharper's code cleanup to insert an extra space into Razor's @Helper block:

Before:
@helper DrawIcon(string title, string url) { <li> <a href="@url" title="@title"></a> </li> }

After:

@Helper DrawIcon(string title, string url)
{ <li> <a href="@ url" title="@ title"></a> </li> }

Couldn't reproduce this behaviour with StyleCop uninstalled or 'Fix stylecop violations' disabled. Please advise.
The original issue in ReSharper's tracker: https://youtrack.jetbrains.com/issue/RSRP-469808

C# version supported

Hi guys!
I'm sorry but I can't find wich C# versions are supported in the current release.
I've encoutered problems with C# 8.0 and C# 9.0.

Anyone can point out thw supported versions or how configure c# versions on the extension?

Thank you

Support for ReSharper 2019.2

After upgrading to ReSharper Ultimate 2019.2, I cannot find the plugin anymore.
Is an update of the extension required? Any timeline available?

Extension does not consider rules in stylecop.json

I have following stylecop.json file where it is declared that using directives should be outside of namespace. However every time I let R# import directives it places them within namespace. How can this be fixed?

{
"$schema":
"https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
"settings": {
"orderingRules": {
"usingDirectivesPlacement": "outsideNamespace"
},
"documentationRules": {
"xmlHeader": false,
"documentInterfaces": false,
"documentInternalElements": false,
"documentExposedElements": false,
"excludeFromPunctuationCheck": [
"seealso",
"param",
"returns",
"summary"
]
}
}
}

Support for C# 8

I've started encountering many instances of SA0102 after applying ReSharper recommendations to optimize my syntax due to C# 8 features not being supported by StyleCop causing those lines to be marked as red line.

Code cleanup moves comments

From: https://youtrack.jetbrains.com/issue/RSRP-475757

Beginning with the following code block:

        private static Dictionary<int, object> Diseases = new Dictionary<int, object>()
                                                              {
                                                                  { 1, null }, // 1
                                                                  { 2, null }, // 2
                                                                  { 3, null }, // 3
                                                                  { 4, null }, // 4
                                                                  { 5, null }, // 5
                                                                  { 6, null }, // 6
                                                                  { 7, null }, // 7
                                                              };

after reformat code:

        private static Dictionary<int, object> Diseases = new Dictionary<int, object>()
                                                              {
                                                                  { 1, null },
                                                                  { 2, null }, // 2
                                                                  { 3, null }, // 3
                                                                  { 4, null }, // 4
                                                                  { 5, null }, // 5
                                                                  { 6, null }, // 6
                                                                  { 7, null }, // 7
                                                                  // 1
                                                              };

after reformat code again:

        private static Dictionary<int, object> Diseases = new Dictionary<int, object>()
                                                              {
                                                                  { 1, null },
                                                                  { 2, null }, 
                                                                  { 3, null }, // 3
                                                                  { 4, null }, // 4
                                                                  { 5, null }, // 5
                                                                  { 6, null }, // 6
                                                                  { 7, null }, // 7
                                                                  // 2
                                                                  // 1
                                                              };

after reformat code again multiple times:

        private static Dictionary<int, object> Diseases = new Dictionary<int, object>()
                                                              {
                                                                  { 1, null },
                                                                  { 2, null },
                                                                  { 3, null },
                                                                  { 4, null },
                                                                  { 5, null },
                                                                  { 6, null },
                                                                  { 7, null }, // 7
                                                                  // 6
                                                                  // 5
                                                                  // 4
                                                                  // 3
                                                                  // 2
                                                                  // 1
                                                              };

The formatting doesn't appear to work with the resharper CLI.

I have done the following:

At first I got a file not found error regarding JetBrains.Platform.VisualStudio.Core.dll so I also copied in the package JetBrains.Platform.VisualStudio.183.0.20190304.43214.

Then I got this:


--- EXCEPTION #1/2 [NullReferenceException]
Message = "Object reference not set to an instance of an object."
ExceptionPath = Root.InnerException
ClassName = System.NullReferenceException
HResult = E_POINTER=COR_E_NULLREFERENCE=80004003
Source = JetBrains.ReSharper.Psi.CSharp
StackTraceString = "
  at JetBrains.ReSharper.Psi.CSharp.Impl.Tree.ArrayCreationExpression.SetArrayType(IArrayType arrayType)
     at StyleCop.ReSharper.CodeCleanup.Rules.ReadabilityRules.SwapArrayCreationToBuiltInType(IArrayCreationExpression arrayCreationExpression)
     at StyleCop.ReSharper.CodeCleanup.Rules.ReadabilityRules.SwapToBuiltInTypeAlias(ITreeNode node)
     at StyleCop.ReSharper.CodeCleanup.Rules.ReadabilityRules.SwapToBuiltInTypeAlias(ITreeNode node)
     at StyleCop.ReSharper.CodeCleanup.Rules.ReadabilityRules.SwapToBuiltInTypeAlias(ITreeNode node)
     at StyleCop.ReSharper.CodeCleanup.Rules.ReadabilityRules.SwapToBuiltInTypeAlias(ITreeNode node)
     at StyleCop.ReSharper.CodeCleanup.Rules.ReadabilityRules.SwapToBuiltInTypeAlias(ITreeNode node)
     at StyleCop.ReSharper.CodeCleanup.Rules.ReadabilityRules.SwapToBuiltInTypeAlias(ITreeNode node)
     at StyleCop.ReSharper.CodeCleanup.Rules.ReadabilityRules.SwapToBuiltInTypeAlias(ITreeNode node)
     at StyleCop.ReSharper.CodeCleanup.Rules.ReadabilityRules.SwapToBuiltInTypeAlias(ITreeNode node)
     at StyleCop.ReSharper.CodeCleanup.Rules.ReadabilityRules.SwapToBuiltInTypeAlias(ITreeNode node)
     at StyleCop.ReSharper.CodeCleanup.Rules.ReadabilityRules.SwapToBuiltInTypeAlias(ITreeNode node)
     at StyleCop.ReSharper.CodeCleanup.Rules.ReadabilityRules.SwapToBuiltInTypeAlias(ITreeNode node)
     at StyleCop.ReSharper.CodeCleanup.Rules.ReadabilityRules.ExecuteAll(ICSharpFile file, Settings settings)
     at StyleCop.ReSharper.CodeCleanup.StyleCopCodeCleanupModule.<>c__DisplayClass11_0.<InternalProcess>b__0(Lifetime lifetime)
     at JetBrains.DataFlow.Lifetimes.Using(Action`1 ?)
     at JetBrains.ReSharper.Psi.Transactions.PsiTransactions.Execute(String commandName, Action handler)
"

--- Outer ---

--- EXCEPTION #2/2 [LoggerException]
Message = "Object reference not set to an instance of an object."
ExceptionPath = Root
ClassName = JetBrains.Util.LoggerException
InnerException = "Exception #1 at Root.InnerException"
HResult = COR_E_APPLICATION=80131600
StackTraceString = "
  at JetBrains.Util.Logging.Logger.LogException(Exception ex)
     at JetBrains.ReSharper.Psi.Transactions.PsiTransactions.Execute(String commandName, Action handler)
     at StyleCop.ReSharper.CodeCleanup.StyleCopCodeCleanupModule.Process(IPsiSourceFile projectFile, IRangeMarker rangeMarker, CodeCleanupProfile profile, IProgressIndicator progressIndicator)
     at JetBrains.ReSharper.Feature.Services.CodeCleanup.CodeCleanup.Run(IPsiSourceFile sourceFile, DocumentRange range, Int32& caret, CodeCleanupProfile profile, IProgressIndicator progressIndicator)
     at JetBrains.ReSharper.Features.Altering.CodeCleanup.CodeCleanupRunner.CleanupFilesWithProgress(ISolution solution, IList`1 files, CodeCleanupProfile cleanupProfile, IProgressIndicator progressIndicator)
     at JetBrains.ReSharperAutomationTools.CommandLine.Common.Console.BatchTool.Progress.ToolTaskExecutor.ExecuteTask(String taskName, TaskCancelable cancelable, Action`1 task)
     at JetBrains.ReSharper.Features.Altering.CodeCleanup.CodeCleanupRunner.CleanupFiles(ICodeCleanupFilesProvider cleanupFilesCollector, CodeCleanupProfile cleanupProfile)
     at JetBrains.Application.Threading.IShellLocksEx.ExecuteWithReadLock(IShellLocks th?s, Action F)
     at JetBrains.Threading.ReentrancyGuard.Execute(String name, Action action)
     at JetBrains.Threading.ReentrancyGuard.TryExecute(String name, Action action)
     at JetBrains.Threading.ReentrancyGuardEx.ExecuteOrQueue(ReentrancyGuard th?s, Lifetime lifetime, String name, Action F, TaskPriority priority)
     at JetBrains.CommandLine.CleanupCode.Unattended.CodeEditing.CleanupCodeLauncher.Run()
     at JetBrains.CommandLine.CleanupCode.Unattended.ConsoleCodeEditing.CleanupCodeProductMain.Main(Lifetime lifetime, IThreading invocator, IComponentContainer container, IShellLocks shellLocks, ILogger logger, ICleanupCodeSettings settings, IProductCommandLineArguments argumentsRaw)
     at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
     at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
     at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
     at JetBrains.Application.Environment.RunsPublicStaticIntMain.<>c__DisplayClass0_0.<.ctor>b__0()
     at JetBrains.Util.Logging.Logger.Catch(Action action)
     at JetBrains.Threading.JetDispatcher.Closure.Execute()
     at JetBrains.Util.Concurrency.WinJetDispatcher.ProcessQueue(Int32 nMinBucket)
     at System.Windows.Threading.DispatcherOperation.InvokeDelegateCore()
     at System.Windows.Threading.DispatcherOperation.InvokeImpl()
     at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
     at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
     at System.Windows.Threading.DispatcherOperation.Invoke()
     at System.Windows.Threading.Dispatcher.ProcessQueue()
     at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
     at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
     at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
     at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
     at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
     at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
     at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
     at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
     at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
     at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
     at JetBrains.DataFlow.Lifetimes.Using(Action`1 ?)
     at JetBrains.Application.Environment.IJetHostEx.RunHostMessageLoop(IComponentContainer containerEnv)
     at JetBrains.Application.Environment.HostParameters.JetHostParametersCaller.RunMainLoop(ComponentContainer containerEnv)
     at JetBrains.Application.Environment.JetEnvironment.InternalRun(JetHostParametersCaller host, ComponentContainer containerEnv)
     at JetBrains.Application.Environment.JetEnvironment.CreateAndRun(Full hostparams)
     at JetBrains.ReSharperAutomationTools.CommandLine.Common.Application.CommandLineProgram.Main(Assembly assembly, Type environmentZoneType, HostInfo hostInfo, ICommandLineProductInfo productInfo, String[] args, IJetHostMixin[] mixins)
     at JetBrains.ReSharperAutomationTools.CommandLine.Common.Application.CommandLineProgram.Run[TZone,TProductInfo](String productHostShortName, String[] args)
     at JetBrains.CommandLine.CleanupCode.CleanupCodeProgram.Main(String[] args)
"

When I look at the diff I can see less changes than when I do a code cleanup within visual studio.

Support for Switch Expressions

If I use a switch expression, StyleCop Rule SA0102 gets triggered.

Example Code:

var value = myEnum switch
  {
     customEnum.ValueA => "A",
     customEnum.ValueB => "B",
        _ => "C",
  };

Please enable support for switch expressions.

Plugin not detected

I have two different VMs with Resharper and the Stylecop extensions, but the plugin is actually working only on one of the two (the older one).

I don't remember if I installed something specific on the first VM, but if I search for stylecop in the options I see different results.
The most notable difference is that the first VM (the working one) displays a stylecop entry under tools, with some information like the plugin dll version.

Should I install something else on the second VM to make the plugin work?

Update for 2021.1.1

Hello,

Could you please deploy a version for 2021.1.1 ?
Using Resharper 2021.1.1, I can't use this plugin in version 2021.1.0

I hope #42 helps

Thanks for your work

Support for nested deconstruction

I have the latest release installed (2018.3.0). When doing a nested deconstruction, I get the following error:

A syntax error has been discovered in file xxx.cs on line xxx. [StyleCop Rule: SA0102]

Mistake in the file layout.

This is the result of code clean up for the file layout's extension.

public class TestResharperLayout
{
    public const int PublicConst = 5;

    public readonly int PublicReadOnlyField;

    public int PublicField;

    private const int PrivateConst = 5;

    private readonly int privateReadOnlyField;

    private int privateField;
}

There is an error

SA1202 : CSharp.Ordering : All private fields must be placed after all public fields.

for private const int PrivateConst = 5; It has to be after public int PublicField;

Using with R#9.2 and VS2013

Hi, for various reasons that I won't go into, some of our team need to use VS2013 and R# 9.2. At one time we would install a R# extension called simply "StyleCop" (v4.7), and everything would just work. This extension seems to have vanished, and yours is now the only one that appears in the list.

I have installed this, along with the Visual Studio StyleCop extension (v6.0). After restarting VS I can now see the StyleCop settings page within the Resharper options dialog, however I'm not seeing any warning squiggles in the code editor. Am I missing something, or is this simply not possible due to incompatibilities between the components that I have installed?

Is There Any Way to Get This Synced with the StyleCop Analyzers Library?

I love the productivity enhancements of this library especially for generating comments. Some on my teams don't like comments. However, I like flyover comments even if they are generic.

The lack of support for new language features makes it difficult to use this anymore.

We use the open source StyleCopy.Analyzers NuGet to help with most rules. We also can't afford ReSharper for everyone. It would be nice to more easily get the productivity back, especially the reformat.

Is this a possibility? Could the productivity enhancements be pulled out or do they exist in another extension? Would I need to become a contributor to help?

image

StyleCop.Resharper does not support feature of C# 9.0 (is not null)

I use:
JetBrains ReSharper 2021.2.1 Build 212.0.20210826.105310 built on 2021-08-26
ReSharper 2021.2.20210826.112029
StyleCop.Resharper 2021.2.0 (see attachment)
Screenshot_8

(see code example attachment)
I do null check of an object with "is not null"
and I got error warning.
Screenshot_9

if I uninstall the StyleCop.Resharper from Resharper, I get no error warning anymore.
I like to use StyleCop.Resharper due to its ability to generate header comment intelligently.
Please integrate the features of C# 9 in StyleCop as soon as possible.
Note: C# 9.0 is not very new since it is released on May 2020!
Thank you in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.