I use next settings in the stylecop.json with StyleCop Analyzers 1.1.0-beta001:
{
"documentationRules": {
"documentationCulture": "ru-RU"
}
}
StyleCop warns me SA1642 (Constructor summary documentation must begin with standard text) when I use such comment:
/// <summary>
/// ΠΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·ΠΈΡΡΠ΅Ρ Π½ΠΎΠ²ΡΠΉ ΡΠΊΠ·Π΅ΠΌΠΏΠ»ΡΡ <see cref="MyClass"/> .
/// </summary>
public MyClass()
{
}
But DocumentationResources.ru-RU.resx contains:
<data name="NonPrivateConstructorStandardTextFirstPart" xml:space="preserve">
<value>ΠΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·ΠΈΡΡΠ΅Ρ Π½ΠΎΠ²ΡΠΉ ΡΠΊΠ·Π΅ΠΌΠΏΠ»ΡΡ {0} </value>
</data>
<data name="NonPrivateConstructorStandardTextSecondPart" xml:space="preserve">
<value />
</data>
My comment matches it even in last space. I think "documentationCulture": "ru-RU" is ignored because when I used English comment SA1642 warning was gone:
/// <summary>
/// Initializes a new instance of the <see cref="MyClass"/> class.
/// </summary>
public MyClass()
{
}
No warning. But it's suspicious that DocumentationResources.resx contains "Initializes a new instance of the {0}" instead of "Initializes a new instance of the {0} class":
<data name="NonPrivateConstructorStandardTextFirstPart" xml:space="preserve">
<value>Initializes a new instance of the </value>
</data>
<data name="NonPrivateConstructorStandardTextSecondPart" xml:space="preserve">
<value> {0}</value>
</data>
Working comment doesn't matches English resource file.
Can you verify your settings file content? The top-level object in the file should be a settings object, like the following:
{
"settings": {
"documentationRules": {
"documentationCulture": "ru-RU"
}
}
}
:bulb: If you add a $schema property, you'll get IntelliSense information to help you write a file in the correct form. See the file we use for this project itself here.
Full version of my stylecop.json:
{
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
"settings": {
"documentationRules": {
"documentationCulture": "ru-RU",
"xmlHeader": false
},
"layoutRules": {
"allowConsecutiveUsings": false,
"newlineAtEndOfFile": "require"
},
"maintainabilityRules": {
"topLevelTypes": [
"class",
"delegate",
"enum",
"interface",
"struct"
]
},
"orderingRules": {
"blankLinesBetweenUsingGroups": "require",
"elementOrder": [
"accessibility",
"kind",
"constant",
"static",
"readonly"
]
}
}
}
I have the same issue when setting the culture to en-GB.
{
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
"settings": {
"documentationRules": {
"documentationCulture": "en-GB"
}
}
}
Regarding the comment about suspicious resource strings: The summary comment is expected to be
Setting the culture to ru-RU works fine for me with the beta, so just to make sure...
Have you added your configuration file according to the instructions in https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/Configuration.md and https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/EnableConfiguration.md?
If you think you have, can you please try to make a change in the configuration file, other than the culture, and see if it has any effect?
Please try it with en-GB.
I'm in a .net core project, therefore I have configured it like documented in https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/DotNetCli.md
The ruleset definitely takes effect, because the words added to the dictionary and custom ruleset work as expected. The stylecop.json (which is located in the same, solution-wide folder as the ruleset) does not seem to have any effect (only tested changing the documentation culture).
Have you added your configuration file according to the instructions...
Yes.
My stylecop.json is above.
My project.json is below:
{
"version": "0.1.0",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true,
"additionalArguments": [
"/ruleset: rules.ruleset",
"/additionalfile: stylecop.json"
],
"xmlDoc": "true"
},
"dependencies": {
"StyleCop.Analyzers":
{
"version": "1.1.0-beta001",
"type": "build"
}
},
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
}
},
"imports": "dnxcore50"
}
}
}
And rules.ruleset:
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="StyleCop.Analyzers rules" ToolsVersion="14.0">
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<!--
<Rule Id="SA1623" Action="Hidden" />
<Rule Id="SA1636" Action="Hidden" />
-->
</Rules>
</RuleSet>
Any changes in those files takes effect. Most of rules works.
Ah, two .NET Core projects... I tried to get a project working, but it breaks down completely for me when I add the "additionalArguments" part. No idea what I'm doing wrong, but I'm giving up!
@pdelvo You did the initial experimentation on how to get .NET Core projects working, right? Any ideas to why it doesn't work for them?
I just created a project.json and a (new) msbuild based dotnet core project that both contain ruleset and stylecop.json files:
https://github.com/pdelvo/StyleCopCliProject
https://github.com/pdelvo/StyleCopCoreProject
Msbuild-based is not going to help us yet because the recommendation (iirc) still is to use project.json
@nick-korsakov You have a space in your /additionalfile: argument. Does it work if you remove that space? Are other customized settings, e.g. "xmlHeader": false, working properly for you?
Excerpt of my project.json
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true,
"debugType": "portable",
"compile": {
"exclude": [
"node_modules"
]
},
"additionalArguments": [ "/ruleset:../_stylecop/StyleCopRules.ruleset", "/additionalfile:../_stylecop/stylecop.json" ],
"xmlDoc": true
},
You have a space in your
/additionalfile:argument.
There isn't space in my real file. Spece is a format error. Sorry.
Was there any movement on this? I really want to roll out analysers but my team with throw seven fits if they are stuck with 'z' in 'Initialises'. Ghastly! en-GB not working for me. I've followed the recommended steps (doctoring csproj file, adding stylecop.json).
csproj:
<AdditionalFiles Include="stylecop.json" />
stylecop.json:
{
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
"settings": {
"documentationRules": {
"documentPrivateFields": true,
"documentPrivateElements": true,
"documentationCulture": "en-GB"
}
}
}
@Gusdor So it turns out if you install the pre-release version it does appear to work as expected. v1.1.0-beta001 for reference
Most helpful comment
@Gusdor So it turns out if you install the pre-release version it does appear to work as expected.
v1.1.0-beta001for reference