Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 2019 22:31
    sharwell unlabeled #2391
  • Jan 31 2019 22:31
    sharwell labeled #2391
  • Jan 31 2019 22:31
    sharwell unlabeled #2865
  • Jan 31 2019 22:31
    sharwell unlabeled #1934
  • Jan 31 2019 22:31
    sharwell labeled #1934
  • Jan 31 2019 22:31
    sharwell unlabeled #2864
  • Jan 31 2019 22:31
    sharwell unlabeled #1923
  • Jan 31 2019 22:31
    sharwell labeled #1923
  • Jan 31 2019 22:30
    sharwell unlabeled #2867
  • Jan 31 2019 22:30

    sharwell on master

    Permanently disable SA1644 (Doc… Merge pull request #2866 from s… (compare)

  • Jan 31 2019 22:30
    sharwell closed #2866
  • Jan 31 2019 22:30
    sharwell closed #164
  • Jan 31 2019 22:30
    sharwell assigned #2866
  • Jan 31 2019 22:29
    sharwell unlabeled #2866
  • Jan 31 2019 22:29
    sharwell unlabeled #2866
  • Jan 31 2019 22:29
    sharwell edited #2866
  • Jan 31 2019 22:29
    sharwell unlabeled #164
  • Jan 31 2019 22:29
    sharwell assigned #164
  • Jan 31 2019 22:29
    sharwell labeled #164
  • Jan 31 2019 22:29
    sharwell labeled #164
Luis Carlos Moyano Medina
@luismoyano_gitlab
Can't find anything related to it
Joseph Musser
@jnm2
@luismoyano_gitlab Once you reference the analyzers in your project, they check your code on each compile. This applies to compiling during CI automatically.
https://github.com/DotNetAnalyzers/StyleCopAnalyzers#installation.
If you want the CI build to fail for all warnings, you can add this to the csproj or Directory.Build.props: <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Or specify it just in the CI build script: dotnet build /p:TreatWarningsAsErrors=true
/cc @sharwell in case there's a better way you recommend
Luis Carlos Moyano Medina
@luismoyano_fcm_gitlab
@jnm2 Thanks for the replying, the thing is that I have a Unity 3D project, so I'm looking for a way to run analyyzers without building since I'm not sure I can correctly build my .sln as I would do with a sole .Net project
Sam Harwell
@sharwell
:thought_balloon: someone should add that
Jose
@pepone
When using is to check a tuple like in if (Method() is (Foo foo, Bar bar)) I get a warning from warning SA1008: Opening parenthesis should not be preceded by a space shouldn't the analyzer detect this is a tuple and allow the space here? seems award to write ... is(Foo foo, Bar bar)
Sam Harwell
@sharwell
@pepone the space should be allowed there. can you file a bug for that?
Joseph Musser
@jnm2
@sharwell I think that might be DotNetAnalyzers/StyleCopAnalyzers#3141
Sam Harwell
@sharwell
I saw that one but I'm not absolutely sure it's the same
It might be the same but should probably get a bug filed and a specific test added
Joseph Musser
@jnm2
No repro for me on 1.2.0-beta.164 even though this is still a version that repros DotNetAnalyzers/StyleCopAnalyzers#3141:
internal class C
{
    private class Foo { }
    private class Bar { }

    private (object Foo, object Bar) Method() => default;

    public void M()
    {
        if (Method() is (Foo foo, Bar bar))
        {
        }
    }
}
Sam Harwell
@sharwell
Cool, I'll get a test added and update release
Mike Marynowski
@mikernet

@sharwell

i'm working on something similar in Roslyn, will see how I like theresult

This was in regards to having stylecop.json settings also configurable in .editorconfig a couple pages of messages above when I was trying to figure out the best way to do that. Did you get anywhere with that?

Mike Marynowski
@mikernet
How do I get SA1516 (ElementsMustBeSeparatedByBlankLine) not to apply to property/event accessors?
I've never seen a blank line used between get and set accessors
Joseph Musser
@jnm2
That is the one reason I can't turn on that rule. It's unusual and feels bad.
Jose
@pepone
Hey, is there an analyzer rule to find unused internal methods?
Sam Harwell
@sharwell
My initial recommendation would be a code coverage tool
But you could probably write an analyzer or modify an existing one to do it
Johan Larsson
@JohanLarsson
            _ = new C(
                // What is the compliant way to comment this argument?
                1);
Sam Harwell
@sharwell
typically extract local variable and document that
Johan Larsson
@JohanLarsson
Is there a way to configure SA1401 to allow internal fields?
I'm thinking maybe there is a flag that can be added to stylecop.json
I often have private classes with internal fields
nawfalhasan
@nawfalhasan

Can someone explain to me how SA1201 came to fruition the way it is now? I cant believe it is the standard.

Would like to know what's the rationale for putting certain types like classes and structs at the bottom where as certain other types like delegates, enums and interfaces come in between. And even there there is no consistency. I feel the current standard lacks distinction between nested types and type level members.

https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1201.md

@sharwell Do .NET team follow SA1201 in BCL code?
Sam Harwell
@sharwell
I'm not sure
This rule was grandfathered in from StyleCop Classic
nawfalhasan
@nawfalhasan
Haha OK.
Johan Larsson
@JohanLarsson
"documentInternalElements": false is ignored for internal interfaces, is this by design?
Sam Harwell
@sharwell
yes
Christian Seidlitz
@SeidChr

hey there!

just found out an odd behavior with the new Auto-Typed Constructor calls

when "new()" is used to create an instance, stylecop-analyzers complain that new should be followed by a space.
I would argue, that this is an exception to that rule, and in this case new is more of a method/constructor name.

What do you say?

Sam Harwell
@sharwell
I believe that is #3214
Christian Seidlitz
@SeidChr
absolutely. so using the beta will help?
Sam Harwell
@sharwell
it should yes
Christian Seidlitz
@SeidChr
i think ive asked this before, but can anyone think of a way to disable the analyzers in the normal "dotnet build" but keep it enabled it in the omnisharp design-time builds?
I want to get rid of the console output, and only have the highlighting in vscode
Mrchazaaa
@Mrchazaaa
Hello, does anyone know if its possible to use stylecop analyzers in vscode?
Christian Seidlitz
@SeidChr
@Mrchazaaa
sure it is
just add the nuget package as shown in the nuget-package page
https://www.nuget.org/packages/StyleCop.Analyzers/1.2.0-beta.321
and enable analyzers in omnisharp
image.png
This message was deleted
Victor S.
@transtrike
Hello. I'm apparently having problem with the analyzer detecting the configuration. For example, I configured the analyzer to use tabs, instead of spaces, but after restarting Omnisharp and reanalyzing the solution, the SA1027 still appears.
[Little Info]
OS: Linux
IDE*: VS Code
all csproj frameworks: .NET 5
Config placement: sln
Christian Seidlitz
@SeidChr

Hello. I'm apparently having problem with the analyzer detecting the configuration. For example, I configured the analyzer to use tabs, instead of spaces, but after restarting Omnisharp and reanalyzing the solution, the SA1027 still appears.
[Little Info]
OS: Linux
IDE*: VS Code
all csproj frameworks: .NET 5
Config placement: sln

oh no, not TABS :see_no_evil:
have you tried an external config file?

Sam Harwell
@sharwell
@transtrike did you configure the use of tabs in stylecop.json? Currently StyleCop Analyzers cannot detect the setting if you only specify it in .editorconfig.
Jose
@pepone
Getting lots of false positives with CA1508, is this a known issue?
Jose
@pepone
seems it is related to the use of range operator

No warning here:

string transportName = uri.Scheme.Substring(4); 
if (transportName == "universal")

Warning here

string transportName = uri.Scheme[4..]; 
if (transportName == "universal")
Jose
@pepone
a separate issue I see after updating to RoslynAnalyzers , warning CA2007 doesn't show up in Visual Studio error list, but it shows up in build output, and it is displayed as a warning with dotnet command line build