File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 33
44namespace StyleCop . Analyzers . Test . CSharp9 . ReadabilityRules
55{
6+ using System . Threading ;
7+ using System . Threading . Tasks ;
8+ using Microsoft . CodeAnalysis . Testing ;
69 using StyleCop . Analyzers . Test . CSharp8 . ReadabilityRules ;
10+ using Xunit ;
11+ using static StyleCop . Analyzers . Test . Verifiers . StyleCopDiagnosticVerifier < StyleCop . Analyzers . ReadabilityRules . SA1125UseShorthandForNullableTypes > ;
712
813 public partial class SA1125CSharp9UnitTests : SA1125CSharp8UnitTests
914 {
15+ [ Theory ]
16+ [ InlineData ( "System.Nullable<nint>" ) ]
17+ [ InlineData ( "Nullable<IntPtr>" ) ]
18+ [ InlineData ( "System.Nullable<nuint>" ) ]
19+ [ InlineData ( "Nullable<UIntPtr>" ) ]
20+ [ WorkItem ( 3969 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3969" ) ]
21+ public async Task TestNativeSizedNullableTypesAsync ( string nullableForm )
22+ {
23+ var testCode = @"
24+ using System;
25+
26+ class TestClass
27+ {
28+ {|#0:" + nullableForm + @"|} value;
29+ }" ;
30+
31+ await VerifyCSharpDiagnosticAsync ( testCode , Diagnostic ( ) . WithLocation ( 0 ) , CancellationToken . None ) . ConfigureAwait ( false ) ;
32+ }
33+
34+ [ Fact ]
35+ [ WorkItem ( 3969 , "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3969" ) ]
36+ public async Task TestNativeSizedNullableAliasesDoNotReportAsync ( )
37+ {
38+ var testCode = @"
39+ class TestClass
40+ {
41+ nint? nativeInt;
42+ nuint? nativeUInt;
43+ }" ;
44+
45+ await VerifyCSharpDiagnosticAsync ( testCode , DiagnosticResult . EmptyDiagnosticResults , CancellationToken . None ) . ConfigureAwait ( false ) ;
46+ }
1047 }
1148}
You can’t perform that action at this time.
0 commit comments