Skip to content

Commit 844702d

Browse files
committed
Merge branch 'main' of ../linker into main
2 parents 00c60e4 + a14e2a8 commit 844702d

37 files changed

+425
-113
lines changed

src/tools/illink/illink.sln

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.30524.135
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.5.33209.295
55
MinimumVisualStudioVersion = 15.0.26124.0
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mono.Linker", "src\linker\Mono.Linker.csproj", "{DD28E2B1-057B-4B4D-A04D-B2EBD9E76E46}"
77
EndProject
@@ -33,16 +33,21 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "tlens", "src\tlens\tlens.cs
3333
EndProject
3434
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ILLink.CodeFixProvider", "src\ILLink.CodeFix\ILLink.CodeFixProvider.csproj", "{6D20F334-B7E4-4585-854B-8A0E2B29B4AA}"
3535
EndProject
36-
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ILLink.Shared", "src\ILLink.Shared\ILLink.Shared.shproj", "{92F5E753-2179-46DC-BDCE-736858C18DC7}"
36+
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ILLink.Shared", "src\ILLink.Shared\ILLink.Shared.shproj", "{FF598E93-8E9E-4091-9F50-61A7572663AE}"
3737
EndProject
3838
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ILLink.RoslynAnalyzer.Tests.Generator", "test\ILLink.RoslynAnalyzer.Tests.Generator\ILLink.RoslynAnalyzer.Tests.Generator.csproj", "{3DDE7064-4B68-4979-8843-FDF4CE5A5140}"
3939
EndProject
40+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "external", "external", "{8FD57ADB-B449-4960-A141-845C1E2E26EC}"
41+
EndProject
42+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil", "external\cecil\Mono.Cecil.csproj", "{7C068318-84AF-4861-9E5F-6F8A3BF38C9D}"
43+
EndProject
44+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cecil", "cecil", "{223B8007-F26C-4E28-B28D-E43C97F7EE23}"
45+
EndProject
46+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "symbols", "symbols", "{19C783E3-B710-4F25-A977-0ADDA4D2CFEE}"
47+
EndProject
48+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil.Pdb", "external\cecil\symbols\pdb\Mono.Cecil.Pdb.csproj", "{AF7722A0-D1A7-4294-A181-B88B6BD67C6E}"
49+
EndProject
4050
Global
41-
GlobalSection(SharedMSBuildProjectFiles) = preSolution
42-
src\ILLink.Shared\ILLink.Shared.projitems*{92f5e753-2179-46dc-bdce-736858c18dc7}*SharedItemsImports = 13
43-
src\ILLink.Shared\ILLink.Shared.projitems*{dd28e2b1-057b-4b4d-a04d-b2ebd9e76e46}*SharedItemsImports = 5
44-
src\ILLink.Shared\ILLink.Shared.projitems*{f1a44a78-34ee-408b-8285-9a26f0e7d4f2}*SharedItemsImports = 5
45-
EndGlobalSection
4651
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4752
Debug|Any CPU = Debug|Any CPU
4853
Debug|x64 = Debug|x64
@@ -208,6 +213,30 @@ Global
208213
{3DDE7064-4B68-4979-8843-FDF4CE5A5140}.Release|x64.Build.0 = Release|Any CPU
209214
{3DDE7064-4B68-4979-8843-FDF4CE5A5140}.Release|x86.ActiveCfg = Release|Any CPU
210215
{3DDE7064-4B68-4979-8843-FDF4CE5A5140}.Release|x86.Build.0 = Release|Any CPU
216+
{7C068318-84AF-4861-9E5F-6F8A3BF38C9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
217+
{7C068318-84AF-4861-9E5F-6F8A3BF38C9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
218+
{7C068318-84AF-4861-9E5F-6F8A3BF38C9D}.Debug|x64.ActiveCfg = Debug|Any CPU
219+
{7C068318-84AF-4861-9E5F-6F8A3BF38C9D}.Debug|x64.Build.0 = Debug|Any CPU
220+
{7C068318-84AF-4861-9E5F-6F8A3BF38C9D}.Debug|x86.ActiveCfg = Debug|Any CPU
221+
{7C068318-84AF-4861-9E5F-6F8A3BF38C9D}.Debug|x86.Build.0 = Debug|Any CPU
222+
{7C068318-84AF-4861-9E5F-6F8A3BF38C9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
223+
{7C068318-84AF-4861-9E5F-6F8A3BF38C9D}.Release|Any CPU.Build.0 = Release|Any CPU
224+
{7C068318-84AF-4861-9E5F-6F8A3BF38C9D}.Release|x64.ActiveCfg = Release|Any CPU
225+
{7C068318-84AF-4861-9E5F-6F8A3BF38C9D}.Release|x64.Build.0 = Release|Any CPU
226+
{7C068318-84AF-4861-9E5F-6F8A3BF38C9D}.Release|x86.ActiveCfg = Release|Any CPU
227+
{7C068318-84AF-4861-9E5F-6F8A3BF38C9D}.Release|x86.Build.0 = Release|Any CPU
228+
{AF7722A0-D1A7-4294-A181-B88B6BD67C6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
229+
{AF7722A0-D1A7-4294-A181-B88B6BD67C6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
230+
{AF7722A0-D1A7-4294-A181-B88B6BD67C6E}.Debug|x64.ActiveCfg = Debug|Any CPU
231+
{AF7722A0-D1A7-4294-A181-B88B6BD67C6E}.Debug|x64.Build.0 = Debug|Any CPU
232+
{AF7722A0-D1A7-4294-A181-B88B6BD67C6E}.Debug|x86.ActiveCfg = Debug|Any CPU
233+
{AF7722A0-D1A7-4294-A181-B88B6BD67C6E}.Debug|x86.Build.0 = Debug|Any CPU
234+
{AF7722A0-D1A7-4294-A181-B88B6BD67C6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
235+
{AF7722A0-D1A7-4294-A181-B88B6BD67C6E}.Release|Any CPU.Build.0 = Release|Any CPU
236+
{AF7722A0-D1A7-4294-A181-B88B6BD67C6E}.Release|x64.ActiveCfg = Release|Any CPU
237+
{AF7722A0-D1A7-4294-A181-B88B6BD67C6E}.Release|x64.Build.0 = Release|Any CPU
238+
{AF7722A0-D1A7-4294-A181-B88B6BD67C6E}.Release|x86.ActiveCfg = Release|Any CPU
239+
{AF7722A0-D1A7-4294-A181-B88B6BD67C6E}.Release|x86.Build.0 = Release|Any CPU
211240
EndGlobalSection
212241
GlobalSection(SolutionProperties) = preSolution
213242
HideSolutionNode = FALSE
@@ -223,8 +252,17 @@ Global
223252
{8DA71B3B-5809-44E5-A018-5DE5C6FF6C2A} = {03EB085F-3E2E-4A68-A7DF-951ADF59A0CC}
224253
{6D20F334-B7E4-4585-854B-8A0E2B29B4AA} = {AA0569FB-73E9-4B42-9A19-714BB1229DAE}
225254
{3DDE7064-4B68-4979-8843-FDF4CE5A5140} = {C2969923-7BAA-4FE4-853C-F670B0D3C6C8}
255+
{7C068318-84AF-4861-9E5F-6F8A3BF38C9D} = {8FD57ADB-B449-4960-A141-845C1E2E26EC}
256+
{223B8007-F26C-4E28-B28D-E43C97F7EE23} = {8FD57ADB-B449-4960-A141-845C1E2E26EC}
257+
{19C783E3-B710-4F25-A977-0ADDA4D2CFEE} = {223B8007-F26C-4E28-B28D-E43C97F7EE23}
258+
{AF7722A0-D1A7-4294-A181-B88B6BD67C6E} = {19C783E3-B710-4F25-A977-0ADDA4D2CFEE}
226259
EndGlobalSection
227260
GlobalSection(ExtensibilityGlobals) = postSolution
228261
SolutionGuid = {E43A3901-42B0-48CA-BB36-5CD40A99A6EE}
229262
EndGlobalSection
263+
GlobalSection(SharedMSBuildProjectFiles) = preSolution
264+
src\ILLink.Shared\ILLink.Shared.projitems*{dd28e2b1-057b-4b4d-a04d-b2ebd9e76e46}*SharedItemsImports = 5
265+
src\ILLink.Shared\ILLink.Shared.projitems*{f1a44a78-34ee-408b-8285-9a26f0e7d4f2}*SharedItemsImports = 5
266+
src\ILLink.Shared\ILLink.Shared.projitems*{ff598e93-8e9e-4091-9f50-61a7572663ae}*SharedItemsImports = 13
267+
EndGlobalSection
230268
EndGlobal

src/tools/illink/src/ILLink.RoslynAnalyzer/TrimAnalysis/ParameterProxy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ partial struct ParameterProxy
1111
{
1212
public ParameterProxy (IParameterSymbol parameter)
1313
{
14-
Method = (new ((IMethodSymbol) parameter.ContainingSymbol));
14+
Method = new ((IMethodSymbol) parameter.ContainingSymbol);
1515
Index = (ParameterIndex) parameter.Ordinal + (Method.HasImplicitThis () ? 1 : 0);
1616
}
1717

src/tools/illink/src/ILLink.Shared/DataFlow/DefaultValueDictionary.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,8 @@ public DefaultValueDictionary<TKey, TValue> Clone ()
108108
// Prevent warning CS0659 https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs0659.
109109
// This type should never be used as a dictionary key.
110110
public override int GetHashCode () => throw new NotImplementedException ();
111+
112+
public static bool operator == (DefaultValueDictionary<TKey, TValue> left, DefaultValueDictionary<TKey, TValue> right) => left.Equals (right);
113+
public static bool operator != (DefaultValueDictionary<TKey, TValue> left, DefaultValueDictionary<TKey, TValue> right) => !(left == right);
111114
}
112115
}

src/tools/illink/src/ILLink.Shared/DataFlow/MaybeLattice.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public Maybe<T> Clone ()
2626
return new (copyValue.DeepCopy ());
2727
return new (value);
2828
}
29+
30+
public static bool operator == (Maybe<T> left, Maybe<T> right) => left.Equals (right);
31+
public static bool operator != (Maybe<T> left, Maybe<T> right) => !(left == right);
2932
}
3033

3134
public struct MaybeLattice<T, TValueLattice> : ILattice<Maybe<T>>

src/tools/illink/src/ILLink.Shared/DataFlow/ValueSet.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ public bool Equals (ValueSet<TValue> other)
120120
}
121121
}
122122

123+
public static bool operator == (ValueSet<TValue> left, ValueSet<TValue> right) => left.Equals (right);
124+
public static bool operator != (ValueSet<TValue> left, ValueSet<TValue> right) => !(left == right);
125+
123126
public override int GetHashCode ()
124127
{
125128
if (_values == null)

src/tools/illink/src/ILLink.Shared/TypeSystemProxy/WellKnownType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public static (string Namespace, string Name) GetNamespaceAndName (this WellKnow
3838
WellKnownType.System_NotSupportedException => ("System", "NotSupportedException"),
3939
WellKnownType.System_Runtime_CompilerServices_DisablePrivateReflectionAttribute => ("System.Runtime.CompilerServices", "DisablePrivateReflectionAttribute"),
4040
WellKnownType.System_Void => ("System", "Void"),
41+
_ => throw new System.ArgumentException (type.ToString ())
4142
};
4243
}
4344
public static string GetNamespace (this WellKnownType type) => GetNamespaceAndName (type).Namespace;

src/tools/illink/src/linker/Linker.Dataflow/HoistedLocalKey.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@ public HoistedLocalKey (FieldDefinition field)
2626
public override bool Equals (object? obj) => obj is HoistedLocalKey other && Equals (other);
2727

2828
public override int GetHashCode () => Field.GetHashCode ();
29+
30+
public static bool operator == (HoistedLocalKey left, HoistedLocalKey right) => left.Equals (right);
31+
public static bool operator != (HoistedLocalKey left, HoistedLocalKey right) => !(left == right);
2932
}
3033
}

src/tools/illink/src/linker/Linker.Dataflow/ValueNode.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,8 @@ public ValueBasicBlockPair (MultiValue value, int basicBlockIndex)
6464
public override bool Equals (object? obj) => obj is ValueBasicBlockPair other && Equals (other);
6565

6666
public override int GetHashCode () => HashUtils.Combine (Value.GetHashCode (), BasicBlockIndex);
67+
68+
public static bool operator == (ValueBasicBlockPair left, ValueBasicBlockPair right) => left.Equals (right);
69+
public static bool operator != (ValueBasicBlockPair left, ValueBasicBlockPair right) => !(left == right);
6770
}
6871
}

src/tools/illink/src/linker/Linker.Steps/MarkStep.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1610,7 +1610,7 @@ protected void MarkField (FieldReference reference, DependencyInfo reason, in Me
16101610
Debug.Assert (reason.Kind == DependencyKind.FieldAccess || reason.Kind == DependencyKind.Ldtoken);
16111611
// Blame the field reference (without actually marking) on the original reason.
16121612
Tracer.AddDirectDependency (reference, reason, marked: false);
1613-
MarkType (reference.DeclaringType, new DependencyInfo (DependencyKind.DeclaringType, reference), new MessageOrigin (Context.TryResolve (reference)));
1613+
MarkType (reference.DeclaringType, new DependencyInfo (DependencyKind.DeclaringType, reference));
16141614

16151615
// Blame the field definition that we will resolve on the field reference.
16161616
reason = new DependencyInfo (DependencyKind.FieldOnGenericInstance, reference);

src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/Verifiers/CSharpAnalyzerVerifier`1.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,7 @@ static bool IsMessageMatch (Diagnostic actual, ImmutableArray<string> actualArgu
585585

586586
public MatchQuality (int value)
587587
{
588-
if (value < 0) {
589-
throw new ArgumentOutOfRangeException (nameof (value));
590-
}
588+
ArgumentOutOfRangeException.ThrowIfNegative (value);
591589

592590
_value = value;
593591
}

src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedInstructionSequenceAttribute.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ public class ExpectedInstructionSequenceAttribute : BaseInAssemblyAttribute
1010
{
1111
public ExpectedInstructionSequenceAttribute (string[] opCodes)
1212
{
13-
if (opCodes == null)
14-
throw new ArgumentNullException (nameof (opCodes));
13+
ArgumentNullException.ThrowIfNull (opCodes);
1514
}
1615
}
1716
}

src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedInstructionSequenceOnMemberInAssemblyAttribute.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ public ExpectedInstructionSequenceOnMemberInAssemblyAttribute (string assemblyFi
1212
{
1313
if (string.IsNullOrEmpty (assemblyFileName))
1414
throw new ArgumentNullException (nameof (assemblyFileName));
15-
if (type == null)
16-
throw new ArgumentNullException (nameof (type));
15+
ArgumentNullException.ThrowIfNull (type);
1716
if (string.IsNullOrEmpty (memberName))
1817
throw new ArgumentNullException (nameof (memberName));
19-
if (opCodes == null)
20-
throw new ArgumentNullException (nameof (opCodes));
18+
ArgumentNullException.ThrowIfNull (opCodes);
2119
}
2220

2321
public ExpectedInstructionSequenceOnMemberInAssemblyAttribute (string assemblyFileName, string typeName, string memberName, string[] opCodes)
@@ -28,8 +26,7 @@ public ExpectedInstructionSequenceOnMemberInAssemblyAttribute (string assemblyFi
2826
throw new ArgumentNullException (nameof (typeName));
2927
if (string.IsNullOrEmpty (memberName))
3028
throw new ArgumentNullException (nameof (memberName));
31-
if (opCodes == null)
32-
throw new ArgumentNullException (nameof (opCodes));
29+
ArgumentNullException.ThrowIfNull (opCodes);
3330
}
3431
}
3532
}

src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedLocalsSequenceAttribute.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@ public class ExpectedLocalsSequenceAttribute : BaseInAssemblyAttribute
1010
{
1111
public ExpectedLocalsSequenceAttribute (string[] types)
1212
{
13-
if (types == null)
14-
throw new ArgumentNullException (nameof (types));
13+
ArgumentNullException.ThrowIfNull (types);
1514
}
1615

1716
public ExpectedLocalsSequenceAttribute (Type[] types)
1817
{
19-
if (types == null)
20-
throw new ArgumentNullException (nameof (types));
18+
ArgumentNullException.ThrowIfNull (types);
2119
}
2220
}
2321
}

src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/IgnoreTestCaseAttribute.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ public class IgnoreTestCaseAttribute : Attribute
1111

1212
public IgnoreTestCaseAttribute (string reason)
1313
{
14-
if (reason == null)
15-
throw new ArgumentNullException (nameof (reason));
14+
ArgumentNullException.ThrowIfNull (reason);
1615
}
1716
}
1817
}

src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttributeAttribute.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ public KeptAttributeAttribute (string attributeName)
1717

1818
public KeptAttributeAttribute (Type type)
1919
{
20-
if (type == null)
21-
throw new ArgumentNullException (nameof (type));
20+
ArgumentNullException.ThrowIfNull (type);
2221
}
2322
}
2423
}

src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptAttributeOnFixedBufferTypeAttribute.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ public KeptAttributeOnFixedBufferTypeAttribute (string attributeName)
1616

1717
public KeptAttributeOnFixedBufferTypeAttribute (Type type)
1818
{
19-
if (type == null)
20-
throw new ArgumentNullException (nameof (type));
19+
ArgumentNullException.ThrowIfNull (type);
2120
}
2221
}
2322
}

src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptBaseOnTypeInAssemblyAttribute.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ public class KeptBaseOnTypeInAssemblyAttribute : BaseInAssemblyAttribute
1010
{
1111
public KeptBaseOnTypeInAssemblyAttribute (string assemblyFileName, Type type, string baseAssemblyFileName, Type baseType)
1212
{
13-
if (type == null)
14-
throw new ArgumentNullException (nameof (type));
13+
ArgumentNullException.ThrowIfNull (type);
1514
if (string.IsNullOrEmpty (assemblyFileName))
1615
throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName));
1716

src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptBaseTypeAttribute.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@ public sealed class KeptBaseTypeAttribute : KeptAttribute
1010
{
1111
public KeptBaseTypeAttribute (Type baseType)
1212
{
13-
if (baseType == null)
14-
throw new ArgumentNullException (nameof (baseType));
13+
ArgumentNullException.ThrowIfNull (baseType);
1514
}
1615

1716
public KeptBaseTypeAttribute (Type baseType, params object[] typeArguments)
1817
{
19-
if (baseType == null)
20-
throw new ArgumentNullException (nameof (baseType));
21-
if (typeArguments == null)
22-
throw new ArgumentNullException (nameof (typeArguments));
18+
ArgumentNullException.ThrowIfNull (baseType);
19+
ArgumentNullException.ThrowIfNull (typeArguments);
2320
}
2421
}
2522
}

src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptExportedTypeAttribute.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ public class KeptExportedTypeAttribute : KeptAttribute
1313
{
1414
public KeptExportedTypeAttribute (Type type)
1515
{
16-
if (type is null)
17-
throw new ArgumentNullException (nameof (type));
16+
ArgumentNullException.ThrowIfNull (type);
1817
}
1918
}
2019
}

src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInitializerData.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ public KeptInitializerData ()
1515

1616
public KeptInitializerData (int occurrenceIndexInBody)
1717
{
18-
if (occurrenceIndexInBody < 0)
19-
throw new ArgumentOutOfRangeException (nameof (occurrenceIndexInBody));
18+
ArgumentOutOfRangeException.ThrowIfNegative (occurrenceIndexInBody);
2019
}
2120
}
2221
}

src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceAttribute.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,13 @@ public class KeptInterfaceAttribute : KeptAttribute
1111

1212
public KeptInterfaceAttribute (Type interfaceType)
1313
{
14-
if (interfaceType == null)
15-
throw new ArgumentNullException (nameof (interfaceType));
14+
ArgumentNullException.ThrowIfNull (interfaceType);
1615
}
1716

1817
public KeptInterfaceAttribute (Type interfaceType, params object[] typeArguments)
1918
{
20-
if (interfaceType == null)
21-
throw new ArgumentNullException (nameof (interfaceType));
22-
if (typeArguments == null)
23-
throw new ArgumentNullException (nameof (typeArguments));
19+
ArgumentNullException.ThrowIfNull (interfaceType);
20+
ArgumentNullException.ThrowIfNull (typeArguments);
2421
}
2522
}
2623
}

src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptInterfaceOnTypeInAssemblyAttribute.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ public class KeptInterfaceOnTypeInAssemblyAttribute : BaseInAssemblyAttribute
1010
{
1111
public KeptInterfaceOnTypeInAssemblyAttribute (string assemblyFileName, Type type, string interfaceAssemblyFileName, Type interfaceType)
1212
{
13-
if (type == null)
14-
throw new ArgumentNullException (nameof (type));
13+
ArgumentNullException.ThrowIfNull (type);
1514
if (string.IsNullOrEmpty (assemblyFileName))
1615
throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName));
1716

src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptMemberInAssemblyAttribute.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,16 @@ public KeptMemberInAssemblyAttribute (string assemblyFileName, Type type, params
1313
{
1414
if (string.IsNullOrEmpty (assemblyFileName))
1515
throw new ArgumentNullException (nameof (assemblyFileName));
16-
if (type == null)
17-
throw new ArgumentNullException (nameof (type));
18-
if (memberNames == null)
19-
throw new ArgumentNullException (nameof (memberNames));
16+
ArgumentNullException.ThrowIfNull (type);
17+
ArgumentNullException.ThrowIfNull (memberNames);
2018
}
2119

2220
public KeptMemberInAssemblyAttribute (string assemblyFileName, string typeName, params string[] memberNames)
2321
{
2422
if (string.IsNullOrEmpty (assemblyFileName))
2523
throw new ArgumentNullException (nameof (assemblyFileName));
26-
if (typeName == null)
27-
throw new ArgumentNullException (nameof (typeName));
28-
if (memberNames == null)
29-
throw new ArgumentNullException (nameof (memberNames));
24+
ArgumentNullException.ThrowIfNull (typeName);
25+
ArgumentNullException.ThrowIfNull (memberNames);
3026
}
3127

3228
public string ExpectationAssemblyName { get; set; }

src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptOverrideAttribute.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ public class KeptOverrideAttribute : KeptAttribute
1919

2020
public KeptOverrideAttribute (Type typeWithOverriddenMethod)
2121
{
22-
if (typeWithOverriddenMethod == null)
23-
throw new ArgumentNullException (nameof (typeWithOverriddenMethod));
22+
ArgumentNullException.ThrowIfNull (typeWithOverriddenMethod);
2423
TypeWithOverriddenMethodDeclaration = typeWithOverriddenMethod;
2524
}
2625
}

src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptReferencesInAssemblyAttribute.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ public KeptReferencesInAssemblyAttribute (string assemblyFileName, string[] expe
1313
if (string.IsNullOrEmpty (assemblyFileName))
1414
throw new ArgumentNullException (nameof (assemblyFileName));
1515

16-
if (expectedReferenceAssemblyNames == null)
17-
throw new ArgumentNullException (nameof (expectedReferenceAssemblyNames));
16+
ArgumentNullException.ThrowIfNull (expectedReferenceAssemblyNames);
1817
}
1918
}
2019
}

src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/KeptSecurityAttribute.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ public KeptSecurityAttribute (string attributeName)
1616

1717
public KeptSecurityAttribute (Type type)
1818
{
19-
if (type == null)
20-
throw new ArgumentNullException (nameof (type));
19+
ArgumentNullException.ThrowIfNull (type);
2120
}
2221
}
2322
}

0 commit comments

Comments
 (0)