|
6 | 6 | namespace StyleCop.Analyzers.ReadabilityRules |
7 | 7 | { |
8 | 8 | using System; |
9 | | - using System.Collections.Concurrent; |
10 | 9 | using System.Collections.Immutable; |
11 | 10 | using Microsoft.CodeAnalysis; |
12 | 11 | using Microsoft.CodeAnalysis.CSharp; |
@@ -153,17 +152,19 @@ public override void Initialize(AnalysisContext context) |
153 | 152 |
|
154 | 153 | private static void HandleCompilationStart(CompilationStartAnalysisContext context) |
155 | 154 | { |
156 | | - Analyzer analyzer = new Analyzer(context.Compilation.GetOrCreateUsingAliasCache()); |
| 155 | + Analyzer analyzer = new Analyzer(context.Compilation.GetOrCreateUsingAliasCache(), context.Compilation.SupportsNativeSizedIntegers()); |
157 | 156 | context.RegisterSyntaxNodeAction(analyzer.HandleIdentifierNameSyntax, SyntaxKind.IdentifierName); |
158 | 157 | } |
159 | 158 |
|
160 | 159 | private sealed class Analyzer |
161 | 160 | { |
162 | 161 | private readonly UsingAliasCache usingAliasCache; |
| 162 | + private readonly bool supportsNativeSizedIntegers; |
163 | 163 |
|
164 | | - public Analyzer(UsingAliasCache usingAliasCache) |
| 164 | + public Analyzer(UsingAliasCache usingAliasCache, bool supportsNativeSizedIntegers) |
165 | 165 | { |
166 | 166 | this.usingAliasCache = usingAliasCache; |
| 167 | + this.supportsNativeSizedIntegers = supportsNativeSizedIntegers; |
167 | 168 | } |
168 | 169 |
|
169 | 170 | public void HandleIdentifierNameSyntax(SyntaxNodeAnalysisContext context, StyleCopSettings settings) |
@@ -230,6 +231,7 @@ public void HandleIdentifierNameSyntax(SyntaxNodeAnalysisContext context, StyleC |
230 | 231 | case nameof(UInt16): |
231 | 232 | case nameof(UInt32): |
232 | 233 | case nameof(UInt64): |
| 234 | + case nameof(IntPtr) or nameof(UIntPtr) when this.supportsNativeSizedIntegers: |
233 | 235 | break; |
234 | 236 |
|
235 | 237 | default: |
@@ -266,6 +268,7 @@ public void HandleIdentifierNameSyntax(SyntaxNodeAnalysisContext context, StyleC |
266 | 268 | case SpecialType.System_UInt16: |
267 | 269 | case SpecialType.System_UInt32: |
268 | 270 | case SpecialType.System_UInt64: |
| 271 | + case SpecialType.System_IntPtr or SpecialType.System_UIntPtr when this.supportsNativeSizedIntegers: |
269 | 272 | break; |
270 | 273 |
|
271 | 274 | default: |
|
0 commit comments