Skip to content

Commit b4ed6a3

Browse files
authored
Merge pull request #6996 from sharwell/update-version
Update version used in tests
2 parents 80ac926 + 1f8488e commit b4ed6a3

File tree

6 files changed

+52
-24
lines changed

6 files changed

+52
-24
lines changed

eng/Versions.props

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@
6464
<MicrosoftCodeAnalysisForRoslynDiagnosticsAnalyzersVersion>3.11.0</MicrosoftCodeAnalysisForRoslynDiagnosticsAnalyzersVersion>
6565
<MicrosoftCodeAnalysisVersionForPublicApiAnalyzers>1.2.1</MicrosoftCodeAnalysisVersionForPublicApiAnalyzers>
6666
<MicrosoftCodeAnalysisVersionForBannedApiAnalyzers>3.11.0</MicrosoftCodeAnalysisVersionForBannedApiAnalyzers>
67-
<MicrosoftCodeAnalysisVersionForBannedApiAnalyzersTests>3.11.0</MicrosoftCodeAnalysisVersionForBannedApiAnalyzersTests>
6867
<MicrosoftCodeAnalysisVersionForPerfSensitiveAnalyzers>3.11.0</MicrosoftCodeAnalysisVersionForPerfSensitiveAnalyzers>
69-
<MicrosoftCodeAnalysisVersionForPerfSensitiveAnalyzersTests>3.11.0</MicrosoftCodeAnalysisVersionForPerfSensitiveAnalyzersTests>
7068
<MicrosoftCodeAnalysisVersionForResxSourceGenerators>4.0.1</MicrosoftCodeAnalysisVersionForResxSourceGenerators>
7169
<MicrosoftCodeAnalysisVersionForNetAnalyzers>3.11.0</MicrosoftCodeAnalysisVersionForNetAnalyzers>
7270
<MicrosoftCodeAnalysisVersionForTextAnalyzers>3.11.0</MicrosoftCodeAnalysisVersionForTextAnalyzers>

src/Microsoft.CodeAnalysis.BannedApiAnalyzers/UnitTests/Microsoft.CodeAnalysis.BannedApiAnalyzers.UnitTests.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
<TargetFramework>$(NetCurrent)</TargetFramework>
55
<ServerGarbageCollection>true</ServerGarbageCollection>
66
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
7-
<!-- These unit tests fail when run agains MicrosoftCodeAnalysisVersionForTests (4.6.0-final.1).
8-
https://github.com/dotnet/roslyn-analyzers/issues/6672. -->
9-
<MicrosoftCodeAnalysisVersion>$(MicrosoftCodeAnalysisVersionForBannedApiAnalyzersTests)</MicrosoftCodeAnalysisVersion>
7+
<MicrosoftCodeAnalysisVersion>$(MicrosoftCodeAnalysisVersionForTests)</MicrosoftCodeAnalysisVersion>
108
</PropertyGroup>
119
<ItemGroup>
1210
<PackageReference Include="Microsoft.CodeAnalysis" Version="$(MicrosoftCodeAnalysisVersion)" />

src/Microsoft.CodeAnalysis.BannedApiAnalyzers/UnitTests/RestrictedInternalsVisibleToAnalyzerTests.cs

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,21 +1039,21 @@ public C1(object o) { }
10391039
}";
10401040

10411041
var apiConsumerSource = @"
1042-
[{|#0:N1.C1|}(typeof({|#1:N1.C1|}))]
1042+
[{|#16:{|#0:N1.C1|}(typeof({|#1:N1.C1|}))|}]
10431043
class C2
10441044
{
1045-
[{|#2:N1.C1|}(typeof({|#3:N1.C1|}))]
1045+
[{|#17:{|#2:N1.C1|}(typeof({|#3:N1.C1|}))|}]
10461046
private readonly int field;
10471047
1048-
[{|#4:N1.C1|}(typeof({|#5:N1.C1|}))]
1049-
private int Property { [{|#6:N1.C1|}(typeof({|#7:N1.C1|}))] get; }
1048+
[{|#18:{|#4:N1.C1|}(typeof({|#5:N1.C1|}))|}]
1049+
private int Property { [{|#19:{|#6:N1.C1|}(typeof({|#7:N1.C1|}))|}] get; }
10501050
1051-
[{|#8:N1.C1|}(typeof({|#9:N1.C1|}))]
1051+
[{|#20:{|#8:N1.C1|}(typeof({|#9:N1.C1|}))|}]
10521052
private event System.EventHandler X;
10531053
1054-
[{|#10:N1.C1|}(typeof({|#11:N1.C1|}))]
1055-
[return: {|#12:N1.C1|}(typeof({|#13:N1.C1|}))]
1056-
int M([{|#14:N1.C1|}(typeof({|#15:N1.C1|}))]object c)
1054+
[{|#21:{|#10:N1.C1|}(typeof({|#11:N1.C1|}))|}]
1055+
[return: {|#22:{|#12:N1.C1|}(typeof({|#13:N1.C1|}))|}]
1056+
int M([{|#23:{|#14:N1.C1|}(typeof({|#15:N1.C1|}))|}]object c)
10571057
{
10581058
return 0;
10591059
}
@@ -1075,7 +1075,15 @@ await VerifyCSharpAsync(apiProviderSource, apiConsumerSource,
10751075
GetCSharpResultAt(12, "N1.C1", "N2"),
10761076
GetCSharpResultAt(13, "N1.C1", "N2"),
10771077
GetCSharpResultAt(14, "N1.C1", "N2"),
1078-
GetCSharpResultAt(15, "N1.C1", "N2")
1078+
GetCSharpResultAt(15, "N1.C1", "N2"),
1079+
GetCSharpResultAt(16, "N1.C1.C1", "N2"),
1080+
GetCSharpResultAt(17, "N1.C1.C1", "N2"),
1081+
GetCSharpResultAt(18, "N1.C1.C1", "N2"),
1082+
GetCSharpResultAt(19, "N1.C1.C1", "N2"),
1083+
GetCSharpResultAt(20, "N1.C1.C1", "N2"),
1084+
GetCSharpResultAt(21, "N1.C1.C1", "N2"),
1085+
GetCSharpResultAt(22, "N1.C1.C1", "N2"),
1086+
GetCSharpResultAt(23, "N1.C1.C1", "N2")
10791087
);
10801088
}
10811089

@@ -1095,19 +1103,19 @@ End Class
10951103
End Namespace";
10961104

10971105
var apiConsumerSource = @"
1098-
<{|#0:N1.C1|}(GetType({|#1:N1.C1|}))>
1106+
<{|#14:{|#0:N1.C1|}(GetType({|#1:N1.C1|}))|}>
10991107
Class C2
1100-
<{|#2:N1.C1|}(GetType({|#3:N1.C1|}))>
1108+
<{|#15:{|#2:N1.C1|}(GetType({|#3:N1.C1|}))|}>
11011109
Private ReadOnly field As Integer
11021110
1103-
<{|#4:N1.C1|}(GetType({|#5:N1.C1|}))>
1111+
<{|#16:{|#4:N1.C1|}(GetType({|#5:N1.C1|}))|}>
11041112
Private ReadOnly Property [Property] As Integer
11051113
1106-
<{|#6:N1.C1|}(GetType({|#7:N1.C1|}))>
1114+
<{|#17:{|#6:N1.C1|}(GetType({|#7:N1.C1|}))|}>
11071115
Private Event X As System.EventHandler
11081116
1109-
<{|#8:N1.C1|}(GetType({|#9:N1.C1|}))>
1110-
Private Function M(<{|#10:N1.C1|}(GetType({|#11:N1.C1|}))> ByVal c As Object) As <{|#12:N1.C1|}(GetType({|#13:N1.C1|}))> Integer
1117+
<{|#18:{|#8:N1.C1|}(GetType({|#9:N1.C1|}))|}>
1118+
Private Function M(<{|#19:{|#10:N1.C1|}(GetType({|#11:N1.C1|}))|}> ByVal c As Object) As <{|#20:{|#12:N1.C1|}(GetType({|#13:N1.C1|}))|}> Integer
11111119
Return 0
11121120
End Function
11131121
End Class";
@@ -1126,7 +1134,14 @@ await VerifyBasicAsync(apiProviderSource, apiConsumerSource,
11261134
GetBasicResultAt(10, "N1.C1", "N2"),
11271135
GetBasicResultAt(11, "N1.C1", "N2"),
11281136
GetBasicResultAt(12, "N1.C1", "N2"),
1129-
GetBasicResultAt(13, "N1.C1", "N2")
1137+
GetBasicResultAt(13, "N1.C1", "N2"),
1138+
GetBasicResultAt(14, "N1.C1.New", "N2"),
1139+
GetBasicResultAt(15, "N1.C1.New", "N2"),
1140+
GetBasicResultAt(16, "N1.C1.New", "N2"),
1141+
GetBasicResultAt(17, "N1.C1.New", "N2"),
1142+
GetBasicResultAt(18, "N1.C1.New", "N2"),
1143+
GetBasicResultAt(19, "N1.C1.New", "N2"),
1144+
GetBasicResultAt(20, "N1.C1.New", "N2")
11301145
);
11311146
}
11321147

src/Microsoft.CodeAnalysis.BannedApiAnalyzers/UnitTests/SymbolIsBannedAnalyzerTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,7 @@ class D : C { }
966966
var bannedText = @"T:BannedAttribute";
967967

968968
await VerifyCSharpAnalyzerAsync(source, bannedText,
969+
GetCSharpResultAt(0, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "BannedAttribute", ""),
969970
GetCSharpResultAt(0, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "BannedAttribute", ""));
970971
}
971972

@@ -987,6 +988,7 @@ class C
987988
var bannedText = @"T:BannedAttribute";
988989

989990
await VerifyCSharpAnalyzerAsync(source, bannedText,
991+
GetCSharpResultAt(0, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "BannedAttribute", ""),
990992
GetCSharpResultAt(0, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "BannedAttribute", ""));
991993
}
992994

@@ -1005,6 +1007,7 @@ class BannedAttribute : Attribute { }
10051007
var bannedText = @"T:BannedAttribute";
10061008

10071009
await VerifyCSharpAnalyzerAsync(source, bannedText,
1010+
GetCSharpResultAt(0, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "BannedAttribute", ""),
10081011
GetCSharpResultAt(0, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "BannedAttribute", ""));
10091012
}
10101013

@@ -1023,6 +1026,7 @@ class BannedAttribute : Attribute { }
10231026
var bannedText = @"T:BannedAttribute";
10241027

10251028
await VerifyCSharpAnalyzerAsync(source, bannedText,
1029+
GetCSharpResultAt(0, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "BannedAttribute", ""),
10261030
GetCSharpResultAt(0, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "BannedAttribute", ""));
10271031
}
10281032

@@ -1093,11 +1097,13 @@ class D {}
10931097
await VerifyCSharpAnalyzerAsync(
10941098
source,
10951099
bannedText1,
1100+
GetCSharpResultAt(0, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "BannedAttribute.BannedAttribute()", ""),
10961101
GetCSharpResultAt(0, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "BannedAttribute.BannedAttribute()", ""));
10971102

10981103
await VerifyCSharpAnalyzerAsync(
10991104
source,
11001105
bannedText2,
1106+
GetCSharpResultAt(1, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "BannedAttribute.BannedAttribute(int)", ""),
11011107
GetCSharpResultAt(1, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "BannedAttribute.BannedAttribute(int)", ""));
11021108
}
11031109

@@ -1812,6 +1818,7 @@ End Class
18121818
var bannedText = @"T:BannedAttribute";
18131819

18141820
await VerifyBasicAnalyzerAsync(source, bannedText,
1821+
GetBasicResultAt(0, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "BannedAttribute", ""),
18151822
GetBasicResultAt(0, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "BannedAttribute", ""));
18161823
}
18171824

@@ -1834,6 +1841,7 @@ End Class
18341841
var bannedText = @"T:BannedAttribute";
18351842

18361843
await VerifyBasicAnalyzerAsync(source, bannedText,
1844+
GetBasicResultAt(0, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "BannedAttribute", ""),
18371845
GetBasicResultAt(0, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "BannedAttribute", ""));
18381846
}
18391847

@@ -1854,6 +1862,7 @@ End Class
18541862
var bannedText = @"T:BannedAttribute";
18551863

18561864
await VerifyBasicAnalyzerAsync(source, bannedText,
1865+
GetBasicResultAt(0, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "BannedAttribute", ""),
18571866
GetBasicResultAt(0, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "BannedAttribute", ""));
18581867
}
18591868

@@ -1874,6 +1883,7 @@ End Class
18741883
var bannedText = @"T:BannedAttribute";
18751884

18761885
await VerifyBasicAnalyzerAsync(source, bannedText,
1886+
GetBasicResultAt(0, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "BannedAttribute", ""),
18771887
GetBasicResultAt(0, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "BannedAttribute", ""));
18781888
}
18791889

@@ -1940,11 +1950,13 @@ End Class
19401950
await VerifyBasicAnalyzerAsync(
19411951
source,
19421952
bannedText1,
1953+
GetBasicResultAt(0, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "Public Sub New()", ""),
19431954
GetBasicResultAt(0, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "Public Sub New()", ""));
19441955

19451956
await VerifyBasicAnalyzerAsync(
19461957
source,
19471958
bannedText2,
1959+
GetBasicResultAt(1, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "Public Sub New(Banned As Integer)", ""),
19481960
GetBasicResultAt(1, SymbolIsBannedAnalyzer.SymbolIsBannedRule, "Public Sub New(Banned As Integer)", ""));
19491961
}
19501962

src/PerformanceSensitiveAnalyzers/Core/ExplicitAllocationAnalyzer.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Collections.Immutable;
55
using Analyzer.Utilities;
66
using Analyzer.Utilities.Extensions;
7+
using Analyzer.Utilities.Lightup;
78
using Microsoft.CodeAnalysis.Diagnostics;
89
using Microsoft.CodeAnalysis.Operations;
910

@@ -89,6 +90,12 @@ protected override void AnalyzeNode(OperationAnalysisContext context, in Perform
8990

9091
if (context.Operation is IObjectCreationOperation or ITypeParameterObjectCreationOperation)
9192
{
93+
if (context.Operation.Parent?.Kind == OperationKindEx.Attribute)
94+
{
95+
// Don't report attribute usage as creating a new instance
96+
return;
97+
}
98+
9299
if (context.Operation.Type?.IsReferenceType == true)
93100
{
94101
context.ReportDiagnostic(context.Operation.CreateDiagnostic(ObjectCreationRule, EmptyMessageArgs));

src/PerformanceSensitiveAnalyzers/UnitTests/Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers.UnitTests.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
<NoWarn>$(NoWarn);CA2007</NoWarn>
1010

1111
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
12-
<!-- These unit tests fail when run agains MicrosoftCodeAnalysisVersionForTests (4.6.0-final.1).
13-
https://github.com/dotnet/roslyn-analyzers/issues/6672. -->
14-
<MicrosoftCodeAnalysisVersion>$(MicrosoftCodeAnalysisVersionForPerfSensitiveAnalyzersTests)</MicrosoftCodeAnalysisVersion>
12+
<MicrosoftCodeAnalysisVersion>$(MicrosoftCodeAnalysisVersionForTests)</MicrosoftCodeAnalysisVersion>
1513
</PropertyGroup>
1614
<ItemGroup>
1715
<PackageReference Include="Microsoft.CodeAnalysis" Version="$(MicrosoftCodeAnalysisVersion)" />

0 commit comments

Comments
 (0)