question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Analyzer doesn't read stylecop.json.

See original GitHub issue

Hello, sorry for bringing this one up again as I know it’s been addressed a few times, but I’m having issues getting stylecop.json to be recognized by my project. Here’s what I’ve tried:

  1. Adding the file in quick actions and fixing the csproj manually by using the steps at https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/EnableConfiguration.md.
  2. Changing the Build Action to be None, Additional Items, and Content; each time unloading and reloading the project. Unforunately, I haven’t had success with any of them. I did notice that when I use Additional Items, the Quick Actions no longer suggest an option for me to generate a stylecop.json file for the project. With the other Build Actions, it gives me this suggestion.
  3. Moving the <AdditionalItems /> element into its own <ItemGroup />.

In all cases I still get a quick action that suggests the fix which is to replace my header which looks like this:

// =======================================================================
// <copyright file="AnalyticsDataProvider.cs" company="LAMA, LLC">
// Copyright 2015 Lama, LLC
// </copyright>
// =======================================================================

To this:

// =======================================================================
// <copyright file="AnalyticsDataProvider.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
// =======================================================================

Here’s the contents of my stylecop.json file:

{
  "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json"
  "settings": {
    "documentationRules": {
      "companyName": "LAMA, LLC",
      "copyrightText": "Copyright 2015 {companyName}. All rights reserved."
    }
  }
}

I’m using Visual Studio Community 2015, version 4.6.00081 and RC3 of the analyzer. Any ideas are appreciated, thanks!

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bpraveen4ucommented, Mar 20, 2019

This issue still exists in .Net core projects.

1reaction
DirtyPiececommented, Jan 7, 2016

Hello and thanks for the suggestion. Apologies, I meant to say AdditionalFiles in my original post. Here’s what I’ve put in the csproj:

<ItemGroup>
    <AdditionalFiles Include="stylecop.json" />
  </ItemGroup>

When I double click stylecop.json in the solution explorer, it shows the correct file. It’s adjacent to the csproj file. Also, I noticed that AdditionalFiles is not an option I can normally select in the Properties window when the file is selected, although it does appear as an option once the csproj is manually updated to include the <AdditionalFiles/> section.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NET 6 StyleCop.Analyzers ignores "documentationCulture"
NET 6 SDK (6.0.400) and I have the simplest possible project involving StyleCop.Analyzers and stylecop.json: ClassLibrary1.csproj:
Read more >
Stylecop.json setting is ignored during code cleanup and ...
I have following stylecop.json file: { "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.
Read more >
StyleCop: A Detailed Guide to Starting and Using It
Agreeing on a style can be hard enough, so enforcrement shouldn't be manual. Learn how to use Stylecop to automate enforcement of code ......
Read more >
Unity and StyleCop.Analyzers
StyleCop.Analyzers is a handy NuGet package for keeping your code neat and tidy. However, Unity removes it every time it compiles.
Read more >
Linting C# in 2019 — StyleCop, Sonar, Resharper, Visual ...
To use StyleCop in 2019 you simply install the nuget package StyleCop.Analyzers . You can do this on a per-project basis or globally...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found