Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTlakaelel Axayakatl Ceja <tlakaelel.ceja@microsoft.com>2022-09-08 21:52:33 +0300
committerGitHub <noreply@github.com>2022-09-08 21:52:33 +0300
commita9060d14067758ca17f8da072f4d2aa238b90045 (patch)
tree0d9e4e85d6fff442d544aa934c2b19e3a8239ee5 /src
parentfdcff4c6e14b48f40011d5c8538053f84ab1d0e0 (diff)
Fix lint command (#3027)
Use new version of MicrosoftCodeAnalysisVersion in linker (Copy from runtime) to fix the dotnet format command Run the dotnet format command Reenable Lint check in ci pipelines
Diffstat (limited to 'src')
-rw-r--r--src/ILLink.CodeFix/RequiresAssemblyFilesCodeFixProvider.cs5
-rw-r--r--src/ILLink.CodeFix/RequiresDynamicCodeCodeFixProvider.cs1
-rw-r--r--src/ILLink.CodeFix/RequiresHelpers.cs4
-rw-r--r--src/ILLink.CodeFix/RequiresUnreferencedCodeCodeFixProvider.cs1
-rw-r--r--src/ILLink.RoslynAnalyzer/CompilationExtensions.cs6
-rw-r--r--src/ILLink.Tasks/CreateRuntimeRootDescriptorFile.cs8
-rw-r--r--src/analyzer/LinkerAnalyzerCore/DependencyGraph.cs3
-rw-r--r--src/linker/Linker.Dataflow/AttributeDataFlow.cs2
-rw-r--r--src/linker/Linker.Dataflow/FlowAnnotations.cs10
-rw-r--r--src/linker/Linker.Dataflow/MethodBodyScanner.cs8
-rw-r--r--src/linker/Linker.Steps/DiscoverCustomOperatorsHandler.cs6
-rw-r--r--src/linker/Linker.Steps/UnreachableBlocksOptimizer.cs30
-rw-r--r--src/linker/Linker/AssemblyResolver.cs9
-rw-r--r--src/linker/Linker/DgmlDependencyRecorder.cs3
-rw-r--r--src/linker/Linker/LinkerAttributesInformation.cs3
-rw-r--r--src/linker/Linker/ParameterHelpers.cs2
-rw-r--r--src/linker/Linker/SerializationMarker.cs6
-rw-r--r--src/linker/Linker/Tracer.cs4
-rw-r--r--src/linker/Linker/XmlDependencyRecorder.cs3
19 files changed, 39 insertions, 75 deletions
diff --git a/src/ILLink.CodeFix/RequiresAssemblyFilesCodeFixProvider.cs b/src/ILLink.CodeFix/RequiresAssemblyFilesCodeFixProvider.cs
index 7ed5a8414..f55258251 100644
--- a/src/ILLink.CodeFix/RequiresAssemblyFilesCodeFixProvider.cs
+++ b/src/ILLink.CodeFix/RequiresAssemblyFilesCodeFixProvider.cs
@@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-using System;
using System.Collections.Immutable;
using System.Composition;
using System.Linq;
@@ -33,7 +32,7 @@ namespace ILLink.CodeFix
public sealed override Task RegisterCodeFixesAsync (CodeFixContext context) => BaseRegisterCodeFixesAsync (context);
- protected override SyntaxNode[] GetAttributeArguments (ISymbol? attributableSymbol, ISymbol targetSymbol, SyntaxGenerator syntaxGenerator, Diagnostic diagnostic) =>
- RequiresHelpers.GetAttributeArgumentsForRequires (targetSymbol, syntaxGenerator, HasPublicAccessibility(attributableSymbol));
+ protected override SyntaxNode[] GetAttributeArguments (ISymbol? attributableSymbol, ISymbol targetSymbol, SyntaxGenerator syntaxGenerator, Diagnostic diagnostic) =>
+ RequiresHelpers.GetAttributeArgumentsForRequires (targetSymbol, syntaxGenerator, HasPublicAccessibility (attributableSymbol));
}
}
diff --git a/src/ILLink.CodeFix/RequiresDynamicCodeCodeFixProvider.cs b/src/ILLink.CodeFix/RequiresDynamicCodeCodeFixProvider.cs
index 807d14b7d..62c484d41 100644
--- a/src/ILLink.CodeFix/RequiresDynamicCodeCodeFixProvider.cs
+++ b/src/ILLink.CodeFix/RequiresDynamicCodeCodeFixProvider.cs
@@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-using System;
using System.Collections.Immutable;
using System.Composition;
using System.Linq;
diff --git a/src/ILLink.CodeFix/RequiresHelpers.cs b/src/ILLink.CodeFix/RequiresHelpers.cs
index 91bb99591..b38f11ca4 100644
--- a/src/ILLink.CodeFix/RequiresHelpers.cs
+++ b/src/ILLink.CodeFix/RequiresHelpers.cs
@@ -2,9 +2,9 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
-using Microsoft.CodeAnalysis.Editing;
-using Microsoft.CodeAnalysis;
using ILLink.RoslynAnalyzer;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Editing;
namespace ILLink.CodeFixProvider
{
diff --git a/src/ILLink.CodeFix/RequiresUnreferencedCodeCodeFixProvider.cs b/src/ILLink.CodeFix/RequiresUnreferencedCodeCodeFixProvider.cs
index 5535e1764..4fe909683 100644
--- a/src/ILLink.CodeFix/RequiresUnreferencedCodeCodeFixProvider.cs
+++ b/src/ILLink.CodeFix/RequiresUnreferencedCodeCodeFixProvider.cs
@@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-using System;
using System.Collections.Immutable;
using System.Composition;
using System.Linq;
diff --git a/src/ILLink.RoslynAnalyzer/CompilationExtensions.cs b/src/ILLink.RoslynAnalyzer/CompilationExtensions.cs
index 0f3d7f8e0..a2c4840fe 100644
--- a/src/ILLink.RoslynAnalyzer/CompilationExtensions.cs
+++ b/src/ILLink.RoslynAnalyzer/CompilationExtensions.cs
@@ -1,10 +1,10 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using System;
+using System.Collections.Immutable;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
-using System.Collections.Immutable;
-using System;
namespace ILLink.RoslynAnalyzer
{
@@ -73,7 +73,7 @@ namespace ILLink.RoslynAnalyzer
return type;
}
-
+
// copied from https://github.com/dotnet/roslyn/blob/main/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/ISymbolExtensions.cs
private static SymbolVisibility GetResultantVisibility (this ISymbol symbol)
{
diff --git a/src/ILLink.Tasks/CreateRuntimeRootDescriptorFile.cs b/src/ILLink.Tasks/CreateRuntimeRootDescriptorFile.cs
index e95d2e505..5685f3cfd 100644
--- a/src/ILLink.Tasks/CreateRuntimeRootDescriptorFile.cs
+++ b/src/ILLink.Tasks/CreateRuntimeRootDescriptorFile.cs
@@ -423,9 +423,7 @@ namespace ILLink.Tasks
members = featureSwitchMembers[featureSwitch.Value][className];
}
- if (members.fields == null) {
- members.fields = new HashSet<string> ();
- }
+ members.fields ??= new HashSet<string> ();
members.fields.Add (fieldName);
}
@@ -446,9 +444,7 @@ namespace ILLink.Tasks
members = featureSwitchMembers[featureSwitch.Value][fullClassName];
}
- if (members.methods == null) {
- members.methods = new HashSet<string> ();
- }
+ members.methods ??= new HashSet<string> ();
members.methods.Add (methodName);
}
diff --git a/src/analyzer/LinkerAnalyzerCore/DependencyGraph.cs b/src/analyzer/LinkerAnalyzerCore/DependencyGraph.cs
index 275756b01..2b6c49063 100644
--- a/src/analyzer/LinkerAnalyzerCore/DependencyGraph.cs
+++ b/src/analyzer/LinkerAnalyzerCore/DependencyGraph.cs
@@ -70,8 +70,7 @@ namespace LinkerAnalyzer.Core
VertexData begin = Vertex (b, true);
VertexData end = Vertex (e, true);
- if (end.parentIndexes == null)
- end.parentIndexes = new List<int> ();
+ end.parentIndexes ??= new List<int> ();
if (!end.parentIndexes.Contains (begin.index)) {
end.parentIndexes.Add (begin.index);
//Console.WriteLine (" end parent index: {0}", end.parentIndexes);
diff --git a/src/linker/Linker.Dataflow/AttributeDataFlow.cs b/src/linker/Linker.Dataflow/AttributeDataFlow.cs
index 5dccfe2b1..03a32483c 100644
--- a/src/linker/Linker.Dataflow/AttributeDataFlow.cs
+++ b/src/linker/Linker.Dataflow/AttributeDataFlow.cs
@@ -28,7 +28,7 @@ namespace Mono.Linker.Dataflow
public void ProcessAttributeDataflow (MethodDefinition method, IList<CustomAttributeArgument> arguments)
{
for (int i = 0; i < method.Parameters.Count; i++) {
- var parameterValue = _context.Annotations.FlowAnnotations.GetMethodParameterValue (method, (SourceParameterIndex)i);
+ var parameterValue = _context.Annotations.FlowAnnotations.GetMethodParameterValue (method, (SourceParameterIndex) i);
if (parameterValue.DynamicallyAccessedMemberTypes != DynamicallyAccessedMemberTypes.None) {
MultiValue value = GetValueForCustomAttributeArgument (arguments[i]);
var diagnosticContext = new DiagnosticContext (_origin, diagnosticsEnabled: true, _context);
diff --git a/src/linker/Linker.Dataflow/FlowAnnotations.cs b/src/linker/Linker.Dataflow/FlowAnnotations.cs
index e7ed760df..f0c8cce9a 100644
--- a/src/linker/Linker.Dataflow/FlowAnnotations.cs
+++ b/src/linker/Linker.Dataflow/FlowAnnotations.cs
@@ -276,9 +276,7 @@ namespace ILLink.Shared.TrimAnalysis
continue;
}
- if (paramAnnotations == null) {
- paramAnnotations = new DynamicallyAccessedMemberTypes[method.Parameters.Count + offset];
- }
+ paramAnnotations ??= new DynamicallyAccessedMemberTypes[method.Parameters.Count + offset];
paramAnnotations[i + offset] = pa;
}
@@ -293,8 +291,7 @@ namespace ILLink.Shared.TrimAnalysis
var genericParameter = method.GenericParameters[genericParameterIndex];
var annotation = GetMemberTypesForDynamicallyAccessedMembersAttribute (method, providerIfNotMember: genericParameter);
if (annotation != DynamicallyAccessedMemberTypes.None) {
- if (genericParameterAnnotations == null)
- genericParameterAnnotations = new DynamicallyAccessedMemberTypes[method.GenericParameters.Count];
+ genericParameterAnnotations ??= new DynamicallyAccessedMemberTypes[method.GenericParameters.Count];
genericParameterAnnotations[genericParameterIndex] = annotation;
}
}
@@ -406,8 +403,7 @@ namespace ILLink.Shared.TrimAnalysis
var provider = attrs?[genericParameterIndex] ?? type.GenericParameters[genericParameterIndex];
var annotation = GetMemberTypesForDynamicallyAccessedMembersAttribute (type, providerIfNotMember: provider);
if (annotation != DynamicallyAccessedMemberTypes.None) {
- if (typeGenericParameterAnnotations == null)
- typeGenericParameterAnnotations = new DynamicallyAccessedMemberTypes[type.GenericParameters.Count];
+ typeGenericParameterAnnotations ??= new DynamicallyAccessedMemberTypes[type.GenericParameters.Count];
typeGenericParameterAnnotations[genericParameterIndex] = annotation;
}
}
diff --git a/src/linker/Linker.Dataflow/MethodBodyScanner.cs b/src/linker/Linker.Dataflow/MethodBodyScanner.cs
index 179ac10bb..0216252cc 100644
--- a/src/linker/Linker.Dataflow/MethodBodyScanner.cs
+++ b/src/linker/Linker.Dataflow/MethodBodyScanner.cs
@@ -12,11 +12,11 @@ using ILLink.Shared.TypeSystemProxy;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Collections.Generic;
+using static Mono.Linker.ParameterHelpers;
using LocalVariableStore = System.Collections.Generic.Dictionary<
Mono.Cecil.Cil.VariableDefinition,
Mono.Linker.Dataflow.ValueBasicBlockPair>;
using MultiValue = ILLink.Shared.DataFlow.ValueSet<ILLink.Shared.DataFlow.SingleValue>;
-using static Mono.Linker.ParameterHelpers;
namespace Mono.Linker.Dataflow
{
@@ -301,9 +301,7 @@ namespace Mono.Linker.Dataflow
}
}
- if (currentStack == null) {
- currentStack = new Stack<StackSlot> (methodBody.MaxStackSize);
- }
+ currentStack ??= new Stack<StackSlot> (methodBody.MaxStackSize);
switch (operation.OpCode.Code) {
case Code.Add:
@@ -1097,7 +1095,7 @@ namespace Mono.Linker.Dataflow
if (calledMethod.ParameterReferenceKind ((int) ilArgumentIndex) is not (ReferenceKind.Ref or ReferenceKind.Out))
continue;
- SingleValue newByRefValue = methodIsResolved && (int)parameterIndex < calledMethodDefinition!.Parameters.Count
+ SingleValue newByRefValue = methodIsResolved && (int) parameterIndex < calledMethodDefinition!.Parameters.Count
? _context.Annotations.FlowAnnotations.GetMethodParameterValue (calledMethodDefinition!, parameterIndex)
: UnknownValue.Instance;
StoreInReference (methodArguments[(int) ilArgumentIndex], newByRefValue, callingMethodBody.Method, operation, locals, curBasicBlock, ref ipState);
diff --git a/src/linker/Linker.Steps/DiscoverCustomOperatorsHandler.cs b/src/linker/Linker.Steps/DiscoverCustomOperatorsHandler.cs
index 24e324590..5811555c6 100644
--- a/src/linker/Linker.Steps/DiscoverCustomOperatorsHandler.cs
+++ b/src/linker/Linker.Steps/DiscoverCustomOperatorsHandler.cs
@@ -24,8 +24,7 @@ namespace Mono.Linker.Steps
Dictionary<TypeDefinition, List<MethodDefinition>> PendingOperatorsForType {
get {
- if (_pendingOperatorsForType == null)
- _pendingOperatorsForType = new Dictionary<TypeDefinition, List<MethodDefinition>> ();
+ _pendingOperatorsForType ??= new Dictionary<TypeDefinition, List<MethodDefinition>> ();
return _pendingOperatorsForType;
}
}
@@ -119,8 +118,7 @@ namespace Mono.Linker.Steps
TypeDefinition? _nullableOfT;
TypeDefinition? NullableOfT {
get {
- if (_nullableOfT == null)
- _nullableOfT = BCL.FindPredefinedType (WellKnownType.System_Nullable_T, Context);
+ _nullableOfT ??= BCL.FindPredefinedType (WellKnownType.System_Nullable_T, Context);
return _nullableOfT;
}
}
diff --git a/src/linker/Linker.Steps/UnreachableBlocksOptimizer.cs b/src/linker/Linker.Steps/UnreachableBlocksOptimizer.cs
index d91fb09dd..d6bc01798 100644
--- a/src/linker/Linker.Steps/UnreachableBlocksOptimizer.cs
+++ b/src/linker/Linker.Steps/UnreachableBlocksOptimizer.cs
@@ -319,8 +319,7 @@ namespace Mono.Linker.Steps
if (!IsConstantValue (instr))
return null;
- if (result == null)
- result = new Instruction[method.Parameters.Count];
+ result ??= new Instruction[method.Parameters.Count];
result[pos] = instr;
}
@@ -578,8 +577,7 @@ namespace Mono.Linker.Steps
void RewriteConditionToNop (int index)
{
- if (conditionInstrsToRemove == null)
- conditionInstrsToRemove = new List<int> ();
+ conditionInstrsToRemove ??= new List<int> ();
conditionInstrsToRemove.Add (index);
RewriteToNop (index);
@@ -755,8 +753,7 @@ namespace Mono.Linker.Steps
Instruction[]? args = GetArgumentsOnStack (md, FoldedInstructions ?? instructions, i);
targetResult = args?.Length > 0 && md.IsStatic ? EvaluateIntrinsicCall (md, args) : null;
- if (targetResult == null)
- targetResult = optimizer.TryGetMethodCallResult (new CalleePayload (md, args))?.Instruction;
+ targetResult ??= optimizer.TryGetMethodCallResult (new CalleePayload (md, args))?.Instruction;
if (targetResult == null)
break;
@@ -1007,8 +1004,7 @@ namespace Mono.Linker.Steps
continue;
case FlowControl.Cond_Branch:
- if (condBranches == null)
- condBranches = new Stack<int> ();
+ condBranches ??= new Stack<int> ();
switch (instr.Operand) {
case Instruction starget:
@@ -1052,15 +1048,13 @@ namespace Mono.Linker.Steps
int end = instrs.IndexOf (handler.TryEnd) - 1;
if (!HasAnyBitSet (reachable, start, end)) {
- if (unreachableHandlers == null)
- unreachableHandlers = new List<ExceptionHandler> ();
+ unreachableHandlers ??= new List<ExceptionHandler> ();
unreachableHandlers.Add (handler);
continue;
}
- if (condBranches == null)
- condBranches = new Stack<int> ();
+ condBranches ??= new Stack<int> ();
condBranches.Push (GetInstructionIndex (handler.HandlerStart));
if (handler.FilterStart != null)
@@ -1240,8 +1234,7 @@ namespace Mono.Linker.Steps
VariableDefinition? variable = GetVariableReference (instr);
if (variable != null) {
- if (removedVariablesReferences == null)
- removedVariablesReferences = new List<VariableDefinition> ();
+ removedVariablesReferences ??= new List<VariableDefinition> ();
if (!removedVariablesReferences.Contains (variable))
removedVariablesReferences.Add (variable);
}
@@ -1273,8 +1266,7 @@ namespace Mono.Linker.Steps
if (index > 0 && IsSideEffectFreeLoad (instrs[index - 1])) {
var nop = Instruction.Create (OpCodes.Nop);
- if (sentinelNops == null)
- sentinelNops = new List<Instruction> ();
+ sentinelNops ??= new List<Instruction> ();
sentinelNops.Add (nop);
ILProcessor.Replace (index - 1, Instruction.Create (OpCodes.Pop));
@@ -1902,16 +1894,14 @@ namespace Mono.Linker.Steps
void PushOnStack (Instruction instruction)
{
- if (stack_instr == null)
- stack_instr = new Stack<Instruction> ();
+ stack_instr ??= new Stack<Instruction> ();
stack_instr.Push (instruction);
}
void StoreToLocals (int index)
{
- if (locals == null)
- locals = new Dictionary<int, Instruction> ();
+ locals ??= new Dictionary<int, Instruction> ();
if (stack_instr == null)
Debug.Fail ("Invalid IL?");
diff --git a/src/linker/Linker/AssemblyResolver.cs b/src/linker/Linker/AssemblyResolver.cs
index 87b8b74d6..b833a504c 100644
--- a/src/linker/Linker/AssemblyResolver.cs
+++ b/src/linker/Linker/AssemblyResolver.cs
@@ -100,12 +100,10 @@ namespace Mono.Linker
// Any full path explicit reference takes precedence over other look up logic
asm = ResolveFromReferences (name);
- if (asm == null)
- asm = SearchDirectory (name);
+ asm ??= SearchDirectory (name);
if (asm == null) {
- if (_unresolvedAssemblies == null)
- _unresolvedAssemblies = new HashSet<string> ();
+ _unresolvedAssemblies ??= new HashSet<string> ();
if (!probing)
ReportUnresolvedAssembly (name);
@@ -120,8 +118,7 @@ namespace Mono.Linker
void ReportUnresolvedAssembly (AssemblyNameReference reference)
{
- if (_reportedUnresolvedAssemblies == null)
- _reportedUnresolvedAssemblies = new HashSet<string> ();
+ _reportedUnresolvedAssemblies ??= new HashSet<string> ();
if (!_reportedUnresolvedAssemblies.Add (reference.Name))
return;
diff --git a/src/linker/Linker/DgmlDependencyRecorder.cs b/src/linker/Linker/DgmlDependencyRecorder.cs
index 5cf4dc832..0bccf909b 100644
--- a/src/linker/Linker/DgmlDependencyRecorder.cs
+++ b/src/linker/Linker/DgmlDependencyRecorder.cs
@@ -31,8 +31,7 @@ namespace Mono.Linker
IndentChars = " "
};
- if (fileName == null)
- fileName = DefaultDependenciesFileName;
+ fileName ??= DefaultDependenciesFileName;
if (string.IsNullOrEmpty (Path.GetDirectoryName (fileName)) && !string.IsNullOrEmpty (context.OutputDirectory)) {
fileName = Path.Combine (context.OutputDirectory, fileName);
diff --git a/src/linker/Linker/LinkerAttributesInformation.cs b/src/linker/Linker/LinkerAttributesInformation.cs
index 27fbcdac1..9fef9b59c 100644
--- a/src/linker/Linker/LinkerAttributesInformation.cs
+++ b/src/linker/Linker/LinkerAttributesInformation.cs
@@ -69,8 +69,7 @@ namespace Mono.Linker
if (attributeValue == null)
continue;
- if (cache == null)
- cache = new List<(Type Type, List<Attribute> Attributes)> ();
+ cache ??= new List<(Type Type, List<Attribute> Attributes)> ();
Type attributeValueType = attributeValue.GetType ();
diff --git a/src/linker/Linker/ParameterHelpers.cs b/src/linker/Linker/ParameterHelpers.cs
index 2ea4786b1..eeca9c28c 100644
--- a/src/linker/Linker/ParameterHelpers.cs
+++ b/src/linker/Linker/ParameterHelpers.cs
@@ -2,9 +2,9 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
+using ILLink.Shared;
using Mono.Cecil;
using Mono.Cecil.Cil;
-using ILLink.Shared;
namespace Mono.Linker
{
diff --git a/src/linker/Linker/SerializationMarker.cs b/src/linker/Linker/SerializationMarker.cs
index feb0cb919..0f13544ea 100644
--- a/src/linker/Linker/SerializationMarker.cs
+++ b/src/linker/Linker/SerializationMarker.cs
@@ -58,8 +58,7 @@ namespace Mono.Linker
Dictionary<SerializerKind, HashSet<ICustomAttributeProvider>>? _trackedRoots;
Dictionary<SerializerKind, HashSet<ICustomAttributeProvider>> TrackedRoots {
get {
- if (_trackedRoots == null)
- _trackedRoots = new Dictionary<SerializerKind, HashSet<ICustomAttributeProvider>> ();
+ _trackedRoots ??= new Dictionary<SerializerKind, HashSet<ICustomAttributeProvider>> ();
return _trackedRoots;
}
@@ -68,8 +67,7 @@ namespace Mono.Linker
HashSet<TypeDefinition>? _recursiveTypes;
HashSet<TypeDefinition> RecursiveTypes {
get {
- if (_recursiveTypes == null)
- _recursiveTypes = new HashSet<TypeDefinition> ();
+ _recursiveTypes ??= new HashSet<TypeDefinition> ();
return _recursiveTypes;
}
diff --git a/src/linker/Linker/Tracer.cs b/src/linker/Linker/Tracer.cs
index 3da9dd51e..15bd8a4b3 100644
--- a/src/linker/Linker/Tracer.cs
+++ b/src/linker/Linker/Tracer.cs
@@ -61,9 +61,7 @@ namespace Mono.Linker
public void AddRecorder (IDependencyRecorder recorder)
{
- if (recorders == null) {
- recorders = new List<IDependencyRecorder> ();
- }
+ recorders ??= new List<IDependencyRecorder> ();
recorders.Add (recorder);
}
diff --git a/src/linker/Linker/XmlDependencyRecorder.cs b/src/linker/Linker/XmlDependencyRecorder.cs
index c66383b14..6c386ac36 100644
--- a/src/linker/Linker/XmlDependencyRecorder.cs
+++ b/src/linker/Linker/XmlDependencyRecorder.cs
@@ -54,8 +54,7 @@ namespace Mono.Linker
IndentChars = "\t"
};
- if (fileName == null)
- fileName = DefaultDependenciesFileName;
+ fileName ??= DefaultDependenciesFileName;
if (string.IsNullOrEmpty (Path.GetDirectoryName (fileName)) && !string.IsNullOrEmpty (context.OutputDirectory)) {
fileName = Path.Combine (context.OutputDirectory, fileName);