Skip to content

Commit ee48913

Browse files
committed
Updated after comments
1 parent 9f42261 commit ee48913

5 files changed

Lines changed: 50 additions & 32 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/ReadabilityResources.Designer.cs

Lines changed: 26 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/ReadabilityResources.resx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,16 +526,16 @@
526526
<value>Qualify using directive</value>
527527
</data>
528528
<data name="SA1135Description" xml:space="preserve">
529-
<value>All using directives must be qualified.</value>
529+
<value>All using directives should be qualified.</value>
530530
</data>
531531
<data name="SA1135MessageFormatNamespace" xml:space="preserve">
532-
<value>Using directive for namespace '{0}' must be qualified</value>
532+
<value>Using directive for namespace '{0}' should be qualified</value>
533533
</data>
534534
<data name="SA1135MessageFormatType" xml:space="preserve">
535-
<value>Using directive for type '{0}' must be qualified</value>
535+
<value>Using directive for type '{0}' should be qualified</value>
536536
</data>
537537
<data name="SA1135Title" xml:space="preserve">
538-
<value>Using directives must be qualified</value>
538+
<value>Using directives should be qualified</value>
539539
</data>
540540
<data name="SX1101CodeFix" xml:space="preserve">
541541
<value>Remove 'this.' prefix</value>

StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1135UsingDirectivesMustBeQualified.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ private static void CheckUsingDeclaration(SyntaxNodeAnalysisContext context, Usi
7777
return;
7878
}
7979

80-
string usingString = usingDirective.Name.ToString();
81-
if (usingString.IndexOf("::", StringComparison.Ordinal) >= 0)
80+
if (usingDirective.HasNamespaceAliasQualifier())
8281
{
8382
// global qualified namespaces are OK.
8483
return;
@@ -92,6 +91,7 @@ private static void CheckUsingDeclaration(SyntaxNodeAnalysisContext context, Usi
9291
}
9392

9493
string symbolString = symbol.ToString();
94+
string usingString = usingDirective.Name.ToString();
9595
if ((symbolString != usingString) && !usingDirective.StartsWithAlias(context.SemanticModel, context.CancellationToken))
9696
{
9797
switch (symbol.Kind)

StyleCop.Analyzers/StyleCop.Analyzers/StyleCop.Analyzers.csproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,19 @@
3737
<None Include="**\*.json" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
3838
</ItemGroup>
3939

40+
<ItemGroup>
41+
<Compile Update="ReadabilityRules\ReadabilityResources.Designer.cs">
42+
<DesignTime>True</DesignTime>
43+
<AutoGen>True</AutoGen>
44+
<DependentUpon>ReadabilityResources.resx</DependentUpon>
45+
</Compile>
46+
</ItemGroup>
47+
48+
<ItemGroup>
49+
<EmbeddedResource Update="ReadabilityRules\ReadabilityResources.resx">
50+
<Generator>ResXFileCodeGenerator</Generator>
51+
<LastGenOutput>ReadabilityResources.Designer.cs</LastGenOutput>
52+
</EmbeddedResource>
53+
</ItemGroup>
54+
4055
</Project>

documentation/SA1135.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ A using directive is not qualified.
2222
## Rule description
2323

2424
A violation of this rule occurs when a using directive is contained within a namespace and is not qualified.
25+
Note that alias definitions of classes within the same namespace do not need to be qualified.
2526

2627
For example, the following code would produce a violation of this rule:
2728

@@ -40,6 +41,8 @@ namespace System.Threading
4041
{
4142
using System.IO;
4243
using System.Threading.Tasks;
44+
45+
using T = Thread;
4346
}
4447
```
4548

0 commit comments

Comments
 (0)