diff --git a/.editorconfig b/.editorconfig
index 7f28f9908..767ae4a99 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -153,6 +153,7 @@ dotnet_diagnostic.IDE2003.severity = silent
#cleared null error types
dotnet_diagnostic.CS8612.severity = error
+dotnet_diagnostic.CS8622.severity = error
dotnet_diagnostic.CS8714.severity = error
dotnet_diagnostic.CS8762.severity = error
dotnet_diagnostic.CS8765.severity = error
diff --git a/ICSharpCode.Decompiler/CSharp/CallBuilder.cs b/ICSharpCode.Decompiler/CSharp/CallBuilder.cs
index 5e2d7c6ee..4b86a1334 100644
--- a/ICSharpCode.Decompiler/CSharp/CallBuilder.cs
+++ b/ICSharpCode.Decompiler/CSharp/CallBuilder.cs
@@ -777,7 +777,7 @@ namespace ICSharpCode.Decompiler.CSharp
ArgumentWithAlignmentAndFormat,
}
- private IEnumerable<(TokenKind, string)> TokenizeFormatString(string value)
+ private IEnumerable<(TokenKind, string?)> TokenizeFormatString(string value)
{
int pos = -1;
@@ -1395,7 +1395,7 @@ namespace ICSharpCode.Decompiler.CSharp
}
OverloadResolutionErrors IsUnambiguousCall(ExpectedTargetDetails expectedTargetDetails, IMethod method,
- ResolveResult target, IType[] typeArguments, ResolveResult[] arguments,
+ ResolveResult? target, IType[] typeArguments, ResolveResult[] arguments,
string[]? argumentNames, int firstOptionalArgumentIndex,
out IParameterizedMember? foundMember, out bool bestCandidateIsExpandedForm)
{
@@ -1676,7 +1676,7 @@ namespace ICSharpCode.Decompiler.CSharp
return false;
}
- ExpressionWithResolveResult HandleConstructorCall(ExpectedTargetDetails expectedTargetDetails, ResolveResult target, IMethod method, ArgumentList argumentList)
+ ExpressionWithResolveResult HandleConstructorCall(ExpectedTargetDetails expectedTargetDetails, ResolveResult? target, IMethod method, ArgumentList argumentList)
{
if (settings.AnonymousTypes && method.DeclaringType.IsAnonymousType())
{
@@ -1823,7 +1823,7 @@ namespace ICSharpCode.Decompiler.CSharp
return expr.Expression.WithRR(new MemberResolveResult(null, method));
}
- ExpressionWithResolveResult BuildDelegateReference(IMethod method, IMethod? invokeMethod, ExpectedTargetDetails expectedTargetDetails, ILInstruction thisArg)
+ ExpressionWithResolveResult BuildDelegateReference(IMethod method, IMethod? invokeMethod, ExpectedTargetDetails expectedTargetDetails, ILInstruction? thisArg)
{
ExpressionBuilder expressionBuilder = this.expressionBuilder;
ExpressionWithResolveResult targetExpression;
@@ -1850,11 +1850,11 @@ namespace ICSharpCode.Decompiler.CSharp
}
- (TranslatedExpression target, bool addTypeArguments, string methodName, ResolveResult result) DisambiguateDelegateReference(IMethod method, IMethod invokeMethod, ExpectedTargetDetails expectedTargetDetails, ILInstruction thisArg)
+ (TranslatedExpression target, bool addTypeArguments, string? methodName, ResolveResult result) DisambiguateDelegateReference(IMethod method, IMethod invokeMethod, ExpectedTargetDetails expectedTargetDetails, ILInstruction? thisArg)
{
if (method.IsLocalFunction)
{
- ILFunction localFunction = expressionBuilder.ResolveLocalFunction(method);
+ ILFunction? localFunction = expressionBuilder.ResolveLocalFunction(method);
Debug.Assert(localFunction != null);
return (default, addTypeArguments: true, localFunction.Name, ToMethodGroup(method, localFunction));
}
diff --git a/ICSharpCode.Decompiler/CSharp/RecordDecompiler.cs b/ICSharpCode.Decompiler/CSharp/RecordDecompiler.cs
index f1788bb7c..91d77e1b6 100644
--- a/ICSharpCode.Decompiler/CSharp/RecordDecompiler.cs
+++ b/ICSharpCode.Decompiler/CSharp/RecordDecompiler.cs
@@ -267,7 +267,7 @@ namespace ICSharpCode.Decompiler.CSharp
///
/// Gets the detected primary constructor. Returns null, if there was no primary constructor detected.
///
- public IMethod PrimaryConstructor => primaryCtor;
+ public IMethod? PrimaryConstructor => primaryCtor;
public bool IsInheritedRecord => isInheritedRecord;
diff --git a/ICSharpCode.Decompiler/CSharp/Resolver/MethodGroupResolveResult.cs b/ICSharpCode.Decompiler/CSharp/Resolver/MethodGroupResolveResult.cs
index 3dbb5bf7a..6c5542c94 100644
--- a/ICSharpCode.Decompiler/CSharp/Resolver/MethodGroupResolveResult.cs
+++ b/ICSharpCode.Decompiler/CSharp/Resolver/MethodGroupResolveResult.cs
@@ -79,10 +79,10 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
{
readonly IReadOnlyList methodLists;
readonly IReadOnlyList typeArguments;
- readonly ResolveResult targetResult;
+ readonly ResolveResult? targetResult;
readonly string methodName;
- public MethodGroupResolveResult(ResolveResult targetResult, string methodName,
+ public MethodGroupResolveResult(ResolveResult? targetResult, string methodName,
IReadOnlyList methods, IReadOnlyList typeArguments)
: base(SpecialType.NoType)
{
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InterpolatedStringExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InterpolatedStringExpression.cs
index 332dc6f3f..2573c9a5d 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InterpolatedStringExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/InterpolatedStringExpression.cs
@@ -106,7 +106,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public int Alignment { get; }
- public string Suffix { get; }
+ public string? Suffix { get; }
public CSharpTokenNode RBraceToken {
get { return GetChildByRole(RBrace); }
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Statements/Statement.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Statements/Statement.cs
index 75ecaad58..92198d5a0 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Statements/Statement.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Statements/Statement.cs
@@ -86,12 +86,12 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
visitor.VisitPatternPlaceholder(this, child);
}
- public override T? AcceptVisitor(IAstVisitor visitor)
+ public override T AcceptVisitor(IAstVisitor visitor)
{
return visitor.VisitPatternPlaceholder(this, child);
}
- public override S? AcceptVisitor(IAstVisitor visitor, T data)
+ public override S AcceptVisitor(IAstVisitor visitor, T data)
{
return visitor.VisitPatternPlaceholder(this, child, data);
}
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/Accessor.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/Accessor.cs
index 890666c8e..acd671315 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/Accessor.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/Accessor.cs
@@ -89,7 +89,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
}
}
- public BlockStatement Body {
+ public BlockStatement? Body {
get { return GetChildByRole(Roles.Body); }
set { SetChildByRole(Roles.Body, value); }
}
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/EnumMemberDeclaration.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/EnumMemberDeclaration.cs
index b4f58e628..cc42720a4 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/EnumMemberDeclaration.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/EnumMemberDeclaration.cs
@@ -40,7 +40,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(Roles.Assign); }
}
- public Expression Initializer {
+ public Expression? Initializer {
get { return GetChildByRole(InitializerRole); }
set { SetChildByRole(InitializerRole, value); }
}
diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/DeclareVariables.cs b/ICSharpCode.Decompiler/CSharp/Transforms/DeclareVariables.cs
index d73ed5ef0..b36e180a5 100644
--- a/ICSharpCode.Decompiler/CSharp/Transforms/DeclareVariables.cs
+++ b/ICSharpCode.Decompiler/CSharp/Transforms/DeclareVariables.cs
@@ -766,7 +766,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
{
foreach (var node in rootNode.Descendants)
{
- ILVariable ilVar;
+ ILVariable? ilVar;
switch (node)
{
case IdentifierExpression id:
diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/FixNameCollisions.cs b/ICSharpCode.Decompiler/CSharp/Transforms/FixNameCollisions.cs
index b5edb964d..db9031008 100644
--- a/ICSharpCode.Decompiler/CSharp/Transforms/FixNameCollisions.cs
+++ b/ICSharpCode.Decompiler/CSharp/Transforms/FixNameCollisions.cs
@@ -50,7 +50,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
if (fieldDecl.Variables.Count != 1)
continue;
string oldName = fieldDecl.Variables.Single().Name;
- ISymbol symbol = fieldDecl.GetSymbol();
+ ISymbol? symbol = fieldDecl.GetSymbol();
if (memberNames.Contains(oldName) && ((IField)symbol).Accessibility == Accessibility.Private)
{
string newName = PickNewName(memberNames, oldName);
diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceQueryExpressions.cs b/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceQueryExpressions.cs
index 457b5331a..ab6f1c7f0 100644
--- a/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceQueryExpressions.cs
+++ b/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceQueryExpressions.cs
@@ -80,7 +80,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
void DecompileQueries(AstNode node)
{
- Expression query = DecompileQuery(node as InvocationExpression);
+ Expression? query = DecompileQuery(node as InvocationExpression);
if (query != null)
{
if (node.Parent is ExpressionStatement && CanUseDiscardAssignment())
@@ -351,13 +351,13 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
///
/// Ensure that all ThenBy's are correct, and that the list of ThenBy's is terminated by an 'OrderBy' invocation.
///
- bool ValidateThenByChain(InvocationExpression invocation, string expectedParameterName)
+ bool ValidateThenByChain(InvocationExpression? invocation, string expectedParameterName)
{
if (invocation == null || invocation.Arguments.Count != 1)
return false;
if (!(invocation.Target is MemberReferenceExpression mre))
return false;
- if (!MatchSimpleLambda(invocation.Arguments.Single(), out ParameterDeclaration parameter, out _))
+ if (!MatchSimpleLambda(invocation.Arguments.Single(), out ParameterDeclaration? parameter, out _))
return false;
if (parameter.Name != expectedParameterName)
return false;
diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs b/ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs
index 5ac5dba86..96bafdb26 100644
--- a/ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs
+++ b/ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs
@@ -184,7 +184,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
if (instanceCtorsNotChainingWithThis.Length > 0)
{
var ctorMethodDef = instanceCtorsNotChainingWithThis[0].GetSymbol() as IMethod;
- ITypeDefinition declaringTypeDefinition = ctorMethodDef?.DeclaringTypeDefinition;
+ ITypeDefinition? declaringTypeDefinition = ctorMethodDef?.DeclaringTypeDefinition;
if (ctorMethodDef != null && declaringTypeDefinition?.IsReferenceType == false && !declaringTypeDefinition.IsRecord)
return;
diff --git a/ICSharpCode.Decompiler/DecompilerException.cs b/ICSharpCode.Decompiler/DecompilerException.cs
index 412a1d395..63f06f720 100644
--- a/ICSharpCode.Decompiler/DecompilerException.cs
+++ b/ICSharpCode.Decompiler/DecompilerException.cs
@@ -36,15 +36,15 @@ namespace ICSharpCode.Decompiler
///
public class DecompilerException : Exception, ISerializable
{
- public string AssemblyName => File.Name;
+ public string? AssemblyName => File?.Name;
- public string FileName => File.FileName;
+ public string? FileName => File?.FileName;
- public IEntity DecompiledEntity { get; }
- public IModule Module { get; }
- public MetadataFile File { get; }
+ public IEntity? DecompiledEntity { get; }
+ public IModule? Module { get; }
+ public MetadataFile? File { get; }
- public DecompilerException(MetadataModule module, IEntity decompiledEntity,
+ public DecompilerException(MetadataModule module, IEntity? decompiledEntity,
Exception innerException, string? message = null)
: base(message ?? GetDefaultMessage(decompiledEntity), innerException)
{
@@ -115,7 +115,7 @@ namespace ICSharpCode.Decompiler
for (int i = 0; i < stackTrace.FrameCount; i++)
{
StackFrame? frame = stackTrace.GetFrame(i);
- MethodBase? method = frame.GetMethod();
+ MethodBase? method = frame?.GetMethod();
if (method == null)
continue;
@@ -126,7 +126,7 @@ namespace ICSharpCode.Decompiler
Type? declaringType = method.DeclaringType;
if (declaringType != null)
{
- b.Append(declaringType.FullName.Replace('+', '.'));
+ b.Append(declaringType.FullName?.Replace('+', '.'));
b.Append('.');
}
b.Append(method.Name);
@@ -168,7 +168,7 @@ namespace ICSharpCode.Decompiler
b.Append(')');
// source location
- if (frame.GetILOffset() >= 0)
+ if (frame?.GetILOffset() >= 0)
{
string? filename = null;
try
diff --git a/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs b/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs
index 9e130ead2..75a3c2877 100644
--- a/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs
+++ b/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs
@@ -1188,7 +1188,7 @@ namespace ICSharpCode.Decompiler.Disassembler
break;
default:
var blob = metadata.GetBlobReader(constant.Value);
- object value;
+ object? value;
try
{
value = blob.ReadConstant(constant.TypeCode);
diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs b/ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs
index 68459498d..d8789bd13 100644
--- a/ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs
+++ b/ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs
@@ -74,29 +74,29 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
ILTransformContext context;
// These fields are set by MatchTaskCreationPattern() or MatchEnumeratorCreationNewObj()
- IType taskType; // return type of the async method; or IAsyncEnumerable{T}/IAsyncEnumerator{T}
- IType underlyingReturnType; // return type of the method (only the "T" for Task{T}), for async enumerators this is the type being yielded
+ IType? taskType; // return type of the async method; or IAsyncEnumerable{T}/IAsyncEnumerator{T}
+ IType? underlyingReturnType; // return type of the method (only the "T" for Task{T}), for async enumerators this is the type being yielded
AsyncMethodType methodType;
- ITypeDefinition stateMachineType;
- IType builderType;
- IField builderField;
- IField stateField;
+ ITypeDefinition? stateMachineType;
+ IType? builderType;
+ IField? builderField;
+ IField? stateField;
int initialState;
Dictionary fieldToParameterMap = new Dictionary();
Dictionary cachedFieldToParameterMap = new Dictionary();
- IField disposeModeField; // 'disposeMode' field (IAsyncEnumerable/IAsyncEnumerator only)
+ IField? disposeModeField; // 'disposeMode' field (IAsyncEnumerable/IAsyncEnumerator only)
// These fields are set by AnalyzeMoveNext():
- ILFunction moveNextFunction;
- ILVariable cachedStateVar; // variable in MoveNext that caches the stateField.
- TryCatch mainTryCatch;
- Block setResultReturnBlock; // block that is jumped to for return statements
- // Note: for async enumerators, a jump to setResultReturnBlock is a 'yield break;'
+ ILFunction? moveNextFunction;
+ ILVariable? cachedStateVar; // variable in MoveNext that caches the stateField.
+ TryCatch? mainTryCatch;
+ Block? setResultReturnBlock; // block that is jumped to for return statements
+ // Note: for async enumerators, a jump to setResultReturnBlock is a 'yield break;'
int finalState; // final state after the setResultAndExitBlock
bool finalStateKnown;
- ILVariable resultVar; // the variable that gets returned by the setResultAndExitBlock
- Block setResultYieldBlock; // block that is jumped to for 'yield return' statements
- ILVariable doFinallyBodies;
+ ILVariable? resultVar; // the variable that gets returned by the setResultAndExitBlock
+ Block? setResultYieldBlock; // block that is jumped to for 'yield return' statements
+ ILVariable? doFinallyBodies;
// These fields are set by AnalyzeStateMachine():
int smallestAwaiterVarIndex;
@@ -295,15 +295,15 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
}
if (startCall.Arguments.Count != 2)
return false;
- ILInstruction loadBuilderExpr = startCall.Arguments[0];
- if (!startCall.Arguments[1].MatchLdLoca(out ILVariable stateMachineVar))
+ ILInstruction? loadBuilderExpr = startCall.Arguments[0];
+ if (!startCall.Arguments[1].MatchLdLoca(out ILVariable? stateMachineVar))
return false;
stateMachineType = stateMachineVar.Type.GetDefinition();
if (stateMachineType == null)
return false;
pos--;
- if (loadBuilderExpr.MatchLdLocRef(out ILVariable builderVar))
+ if (loadBuilderExpr.MatchLdLocRef(out ILVariable? builderVar))
{
// Check third-to-last instruction (copy of builder)
// stloc builder(ldfld StateMachine::<>t__builder(ldloc stateMachine))
@@ -340,8 +340,8 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
return false;
if (!MatchCall(returnValue, "get_Task", out var getTaskArgs) || getTaskArgs.Count != 1)
return false;
- ILInstruction target;
- IField builderField2;
+ ILInstruction? target;
+ IField? builderField2;
if (builderType.IsReferenceType == true)
{
if (!getTaskArgs[0].MatchLdFld(out target, out builderField2))
@@ -804,7 +804,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
return block.Instructions[1].MatchLeave(blockContainer);
}
- private Block CheckSetResultReturnBlock(BlockContainer blockContainer, int setResultReturnBlockIndex, bool[] blocksAnalyzed)
+ private Block? CheckSetResultReturnBlock(BlockContainer blockContainer, int setResultReturnBlockIndex, bool[] blocksAnalyzed)
{
if (setResultReturnBlockIndex >= blockContainer.Blocks.Count)
{
@@ -1931,7 +1931,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
context.StepEndGroup(keepIfEmpty: true);
}
- internal static Block GetBodyEntryPoint(BlockContainer body)
+ internal static Block? GetBodyEntryPoint(BlockContainer? body)
{
if (body == null)
return null;
diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/DetectPinnedRegions.cs b/ICSharpCode.Decompiler/IL/ControlFlow/DetectPinnedRegions.cs
index 53e5f2c1c..a20a515fa 100644
--- a/ICSharpCode.Decompiler/IL/ControlFlow/DetectPinnedRegions.cs
+++ b/ICSharpCode.Decompiler/IL/ControlFlow/DetectPinnedRegions.cs
@@ -163,7 +163,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
for (int i = 0; i < container.Blocks.Count; i++)
{
var block = container.Blocks[i];
- if (IsNullSafeArrayToPointerPattern(block, out ILVariable v, out ILVariable p, out Block targetBlock))
+ if (IsNullSafeArrayToPointerPattern(block, out ILVariable? v, out ILVariable? p, out Block? targetBlock))
{
context.Step("NullSafeArrayToPointerPattern", block);
ILInstruction arrayToPointer = new GetPinnableReference(new LdLoc(v), null);
@@ -176,7 +176,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
((Branch)block.Instructions.Last()).TargetBlock = targetBlock;
modified = true;
}
- else if (IsCustomRefPinPattern(block, out ILInstruction ldlocMem, out var callGPR, out v, out var stlocPtr,
+ else if (IsCustomRefPinPattern(block, out ILInstruction? ldlocMem, out var callGPR, out v, out var stlocPtr,
out targetBlock, out var nullBlock, out var notNullBlock))
{
context.Step("CustomRefPinPattern", block);
@@ -432,7 +432,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
}
}
condition = condition.UnwrapConv(ConversionKind.Truncate);
- if (condition.MatchLdLen(StackType.I, out ILInstruction array))
+ if (condition.MatchLdLen(StackType.I, out ILInstruction? array))
{
// OK
}
@@ -451,7 +451,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
}
if (!array.MatchLdLoc(v))
return false;
- if (!trueInst.MatchBranch(out Block notNullAndNotEmptyBlock))
+ if (!trueInst.MatchBranch(out Block? notNullAndNotEmptyBlock))
return false;
if (notNullAndNotEmptyBlock.Parent != block.Parent)
return false;
@@ -468,7 +468,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
// }
if (block.Instructions.Count != 2)
return false;
- if (!block.Instructions[0].MatchStLoc(out var p2, out ILInstruction value))
+ if (!block.Instructions[0].MatchStLoc(out var p2, out ILInstruction? value))
return false;
if (p != p2)
{
@@ -950,8 +950,8 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
}
pinnedRegion.Init = new GetPinnableReference(pinnedRegion.Init, null);
- ILVariable otherVar;
- ILInstruction otherVarInit;
+ ILVariable? otherVar;
+ ILInstruction? otherVarInit;
// In optimized builds, the 'nativeVar' may end up being a stack slot,
// and only gets assigned to a real variable after the offset adjustment.
if (nativeVar.Kind == VariableKind.StackSlot && nativeVar.LoadCount == 1
diff --git a/ICSharpCode.Decompiler/IL/Transforms/EarlyExpressionTransforms.cs b/ICSharpCode.Decompiler/IL/Transforms/EarlyExpressionTransforms.cs
index f7a9226ca..54458029a 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/EarlyExpressionTransforms.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/EarlyExpressionTransforms.cs
@@ -132,7 +132,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
internal static bool LdObjToLdLoc(LdObj inst, ILTransformContext context)
{
- if (inst.Target.MatchLdLoca(out ILVariable v)
+ if (inst.Target.MatchLdLoca(out ILVariable? v)
&& TypeUtils.IsCompatibleTypeForMemoryAccess(v.Type, inst.Type)
&& inst.UnalignedPrefix == 0
&& !inst.IsVolatile)
diff --git a/ICSharpCode.Decompiler/IL/Transforms/IndexRangeTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/IndexRangeTransform.cs
index 5ee75f167..dd8136a8a 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/IndexRangeTransform.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/IndexRangeTransform.cs
@@ -275,8 +275,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
void TransformSlicing(bool sliceLengthWasMisdetectedAsStartOffset = false)
{
- ILVariable sliceLengthVar;
- ILInstruction sliceLengthVarInit;
+ ILVariable? sliceLengthVar;
+ ILInstruction? sliceLengthVarInit;
if (sliceLengthWasMisdetectedAsStartOffset)
{
// Special case: when slicing without a start point, the slice length calculation is mis-detected as the start offset,
@@ -303,7 +303,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
if (!(sliceLengthVar.IsSingleDefinition && sliceLengthVar.LoadCount == 1))
return;
- if (!MatchSliceLength(sliceLengthVarInit, out IndexKind endIndexKind, out ILInstruction endIndexLoad, containerLengthVar, ref containerVar, startOffsetVar))
+ if (!MatchSliceLength(sliceLengthVarInit, out IndexKind endIndexKind, out ILInstruction? endIndexLoad, containerLengthVar, ref containerVar, startOffsetVar))
return;
if (!CheckContainerLengthVariableUseCount(containerLengthVar, startIndexKind, endIndexKind))
{
diff --git a/ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs b/ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs
index d35b10b82..d98f2fee3 100644
--- a/ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs
+++ b/ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs
@@ -262,7 +262,7 @@ namespace ICSharpCode.Decompiler.Metadata
return version.ToString();
}
- internal static (Version version, DirectoryInfo directory) ConvertToVersion(DirectoryInfo directory)
+ internal static (Version? version, DirectoryInfo? directory) ConvertToVersion(DirectoryInfo directory)
{
string RemoveTrailingVersionInfo()
{
@@ -289,7 +289,7 @@ namespace ICSharpCode.Decompiler.Metadata
public static string? FindDotNetExeDirectory()
{
string dotnetExeName = (Environment.OSVersion.Platform == PlatformID.Unix) ? "dotnet" : "dotnet.exe";
- foreach (var item in Environment.GetEnvironmentVariable("PATH").Split(Path.PathSeparator))
+ foreach (var item in Environment.GetEnvironmentVariable("PATH")!.Split(Path.PathSeparator))
{
try
{
diff --git a/ICSharpCode.Decompiler/TypeSystem/ApplyAttributeTypeVisitor.cs b/ICSharpCode.Decompiler/TypeSystem/ApplyAttributeTypeVisitor.cs
index 0ebba87ef..53dd7dea9 100644
--- a/ICSharpCode.Decompiler/TypeSystem/ApplyAttributeTypeVisitor.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/ApplyAttributeTypeVisitor.cs
@@ -48,7 +48,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
bool[]? dynamicAttributeData = null;
bool hasNativeIntegersAttribute = (options & TypeSystemOptions.NativeIntegersWithoutAttribute) != 0;
bool[]? nativeIntegersAttributeData = null;
- string[]? tupleElementNames = null;
+ string?[]? tupleElementNames = null;
Nullability nullability;
Nullability[]? nullableAttributeData = null;
if ((options & TypeSystemOptions.NullabilityAnnotations) != 0)
diff --git a/ICSharpCode.Decompiler/TypeSystem/DecompilerTypeSystem.cs b/ICSharpCode.Decompiler/TypeSystem/DecompilerTypeSystem.cs
index 896f9e802..1c688a03f 100644
--- a/ICSharpCode.Decompiler/TypeSystem/DecompilerTypeSystem.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/DecompilerTypeSystem.cs
@@ -245,7 +245,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
// Load referenced assemblies and type-forwarder references.
// This is necessary to make .NET Core/PCL binaries work better.
var referencedAssemblies = new List();
- var assemblyReferenceQueue = new Queue<(bool IsAssembly, MetadataFile MainModule, object Reference, Task ResolveTask)>();
+ var assemblyReferenceQueue = new Queue<(bool IsAssembly, MetadataFile MainModule, object Reference, Task ResolveTask)>();
var comparer = KeyComparer.Create(((bool IsAssembly, MetadataFile MainModule, object Reference) reference) =>
reference.IsAssembly ? "A:" + ((IAssemblyReference)reference.Reference).FullName :
"M:" + reference.Reference);
@@ -348,7 +348,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
{
// Immediately start loading the referenced module as we add the entry to the queue.
// This allows loading multiple modules in parallel.
- Task asm;
+ Task asm;
if (isAssembly)
{
asm = assemblyResolver.ResolveAsync((IAssemblyReference)reference);
diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataEvent.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataEvent.cs
index d7f1be94b..4fe48c5c2 100644
--- a/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataEvent.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataEvent.cs
@@ -99,7 +99,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
{
if (method == null)
return EmptyList.Instance;
- return method.ExplicitlyImplementedInterfaceMembers.Select(m => ((IMethod)m).AccessorOwner).Where(m => m != null);
+ return method.ExplicitlyImplementedInterfaceMembers.Select(m => ((IMethod)m).AccessorOwner).OfType();
}
public ITypeDefinition DeclaringTypeDefinition => AnyAccessor?.DeclaringTypeDefinition;
diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataProperty.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataProperty.cs
index 70e24e735..f9d6d779b 100644
--- a/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataProperty.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataProperty.cs
@@ -188,7 +188,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
{
if (method == null)
return EmptyList.Instance;
- return method.ExplicitlyImplementedInterfaceMembers.Select(m => ((IMethod)m).AccessorOwner).Where(m => m != null);
+ return method.ExplicitlyImplementedInterfaceMembers.Select(m => ((IMethod)m).AccessorOwner).OfType();
}
public ITypeDefinition DeclaringTypeDefinition => AnyAccessor?.DeclaringTypeDefinition;
diff --git a/ICSharpCode.Decompiler/TypeSystem/TypeProvider.cs b/ICSharpCode.Decompiler/TypeSystem/TypeProvider.cs
index d73b54b29..39c2bcad3 100644
--- a/ICSharpCode.Decompiler/TypeSystem/TypeProvider.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/TypeProvider.cs
@@ -160,7 +160,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return type ?? new UnknownType(fullTypeName, IsReferenceType(reader, handle, rawTypeKind));
}
- public IType? GetTypeFromSerializedName(string name)
+ public IType GetTypeFromSerializedName(string name)
{
if (name == null)
{
diff --git a/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs b/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs
index c52d62c14..7e5554e06 100644
--- a/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs
@@ -83,7 +83,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
if (type == null)
throw new ArgumentNullException(nameof(type));
- return type.GetAllBaseTypes().Select(t => t.GetDefinition()).Where(d => d != null).Distinct();
+ return type.GetAllBaseTypes().Select(t => t.GetDefinition()).OfType().Distinct();
}
///
diff --git a/ICSharpCode.ILSpyX/Abstractions/ILanguage.cs b/ICSharpCode.ILSpyX/Abstractions/ILanguage.cs
index f05c6ded3..bfc6504e3 100644
--- a/ICSharpCode.ILSpyX/Abstractions/ILanguage.cs
+++ b/ICSharpCode.ILSpyX/Abstractions/ILanguage.cs
@@ -27,7 +27,7 @@ namespace ICSharpCode.ILSpyX.Abstractions
{
bool ShowMember(IEntity member);
CodeMappingInfo GetCodeMappingInfo(MetadataFile module, EntityHandle member);
- string GetEntityName(MetadataFile module, System.Reflection.Metadata.EntityHandle handle, bool fullName, bool omitGenerics);
+ string? GetEntityName(MetadataFile module, System.Reflection.Metadata.EntityHandle handle, bool fullName, bool omitGenerics);
string GetTooltip(IEntity entity);
string TypeToString(IType type, bool includeNamespace);
diff --git a/ILSpy.ReadyToRun/ReadyToRunLanguage.cs b/ILSpy.ReadyToRun/ReadyToRunLanguage.cs
index b201a6608..b086bd54c 100644
--- a/ILSpy.ReadyToRun/ReadyToRunLanguage.cs
+++ b/ILSpy.ReadyToRun/ReadyToRunLanguage.cs
@@ -216,7 +216,7 @@ namespace ICSharpCode.ILSpy.ReadyToRun
}
}
- public override RichText GetRichTextTooltip(IEntity entity)
+ public override RichText? GetRichTextTooltip(IEntity entity)
{
return Languages.ILLanguage.GetRichTextTooltip(entity);
}
diff --git a/ILSpy/Analyzers/AnalyzerEntityTreeNode.cs b/ILSpy/Analyzers/AnalyzerEntityTreeNode.cs
index 213624ee1..d0917a982 100644
--- a/ILSpy/Analyzers/AnalyzerEntityTreeNode.cs
+++ b/ILSpy/Analyzers/AnalyzerEntityTreeNode.cs
@@ -22,8 +22,8 @@ using System.Windows;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.TreeNodes;
using ICSharpCode.ILSpyX;
-using ICSharpCode.ILSpyX.TreeView.PlatformAbstractions;
using ICSharpCode.ILSpyX.TreeView;
+using ICSharpCode.ILSpyX.TreeView.PlatformAbstractions;
namespace ICSharpCode.ILSpy.Analyzers
{
@@ -32,7 +32,7 @@ namespace ICSharpCode.ILSpy.Analyzers
///
public abstract class AnalyzerEntityTreeNode : AnalyzerTreeNode, IMemberTreeNode
{
- public abstract IEntity Member { get; }
+ public abstract IEntity? Member { get; }
public override void ActivateItem(IPlatformRoutedEventArgs e)
{
diff --git a/ILSpy/Analyzers/TreeNodes/AnalyzedEventTreeNode.cs b/ILSpy/Analyzers/TreeNodes/AnalyzedEventTreeNode.cs
index e5f88adcb..463c74c99 100644
--- a/ILSpy/Analyzers/TreeNodes/AnalyzedEventTreeNode.cs
+++ b/ILSpy/Analyzers/TreeNodes/AnalyzedEventTreeNode.cs
@@ -40,7 +40,7 @@ namespace ICSharpCode.ILSpy.Analyzers.TreeNodes
this.LazyLoading = true;
}
- public override IEntity Member => analyzedEvent;
+ public override IEntity? Member => analyzedEvent;
public override object Icon => EventTreeNode.GetIcon(analyzedEvent);
diff --git a/ILSpy/Analyzers/TreeNodes/AnalyzedFieldTreeNode.cs b/ILSpy/Analyzers/TreeNodes/AnalyzedFieldTreeNode.cs
index 1f2b9b9a3..b75a8b384 100644
--- a/ILSpy/Analyzers/TreeNodes/AnalyzedFieldTreeNode.cs
+++ b/ILSpy/Analyzers/TreeNodes/AnalyzedFieldTreeNode.cs
@@ -52,6 +52,6 @@ namespace ICSharpCode.ILSpy.Analyzers.TreeNodes
}
}
- public override IEntity Member => analyzedField;
+ public override IEntity? Member => analyzedField;
}
}
diff --git a/ILSpy/Analyzers/TreeNodes/AnalyzedMethodTreeNode.cs b/ILSpy/Analyzers/TreeNodes/AnalyzedMethodTreeNode.cs
index b7cee8ede..b4fc0d044 100644
--- a/ILSpy/Analyzers/TreeNodes/AnalyzedMethodTreeNode.cs
+++ b/ILSpy/Analyzers/TreeNodes/AnalyzedMethodTreeNode.cs
@@ -54,6 +54,6 @@ namespace ICSharpCode.ILSpy.Analyzers.TreeNodes
}
}
- public override IEntity Member => analyzedMethod;
+ public override IEntity? Member => analyzedMethod;
}
}
diff --git a/ILSpy/Analyzers/TreeNodes/AnalyzedPropertyTreeNode.cs b/ILSpy/Analyzers/TreeNodes/AnalyzedPropertyTreeNode.cs
index d19bc3e73..383f41f26 100644
--- a/ILSpy/Analyzers/TreeNodes/AnalyzedPropertyTreeNode.cs
+++ b/ILSpy/Analyzers/TreeNodes/AnalyzedPropertyTreeNode.cs
@@ -62,6 +62,6 @@ namespace ICSharpCode.ILSpy.Analyzers.TreeNodes
}
}
- public override IEntity Member => analyzedProperty;
+ public override IEntity? Member => analyzedProperty;
}
}
diff --git a/ILSpy/Analyzers/TreeNodes/AnalyzedTypeTreeNode.cs b/ILSpy/Analyzers/TreeNodes/AnalyzedTypeTreeNode.cs
index 6836944eb..09ad9f950 100644
--- a/ILSpy/Analyzers/TreeNodes/AnalyzedTypeTreeNode.cs
+++ b/ILSpy/Analyzers/TreeNodes/AnalyzedTypeTreeNode.cs
@@ -52,6 +52,6 @@ namespace ICSharpCode.ILSpy.Analyzers.TreeNodes
}
}
- public override IEntity Member => analyzedType;
+ public override IEntity? Member => analyzedType;
}
}
diff --git a/ILSpy/App.xaml.cs b/ILSpy/App.xaml.cs
index 92c46a1f5..b1d6e3254 100644
--- a/ILSpy/App.xaml.cs
+++ b/ILSpy/App.xaml.cs
@@ -18,6 +18,7 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel.Composition.Hosting;
using System.Diagnostics;
using System.IO;
using System.Linq;
@@ -34,17 +35,15 @@ using ICSharpCode.ILSpy.AppEnv;
using ICSharpCode.ILSpy.Options;
using ICSharpCode.ILSpyX.Analyzers;
using ICSharpCode.ILSpyX.Settings;
+using ICSharpCode.ILSpyX.TreeView;
using Medo.Application;
using Microsoft.VisualStudio.Composition;
-using TomsToolbox.Wpf.Styles;
-using ICSharpCode.ILSpyX.TreeView;
-
using TomsToolbox.Composition;
using TomsToolbox.Wpf.Composition;
-using System.ComponentModel.Composition.Hosting;
+using TomsToolbox.Wpf.Styles;
namespace ICSharpCode.ILSpy
{
@@ -115,7 +114,7 @@ namespace ICSharpCode.ILSpy
}
}
- private static void SingleInstance_NewInstanceDetected(object sender, NewInstanceEventArgs e)
+ private static void SingleInstance_NewInstanceDetected(object? sender, NewInstanceEventArgs e)
{
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
ICSharpCode.ILSpy.MainWindow.Instance.HandleSingleInstanceCommandLineArguments(e.Args);
@@ -210,7 +209,7 @@ namespace ICSharpCode.ILSpy
base.OnStartup(e);
}
- void DotNet40_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
+ void DotNet40_UnobservedTaskException(object? sender, UnobservedTaskExceptionEventArgs e)
{
// On .NET 4.0, an unobserved exception in a task terminates the process unless we mark it as observed
e.SetObserved();
diff --git a/ILSpy/AvalonEdit/TextMarkerService.cs b/ILSpy/AvalonEdit/TextMarkerService.cs
index 9a1d1598c..5abf534f5 100644
--- a/ILSpy/AvalonEdit/TextMarkerService.cs
+++ b/ILSpy/AvalonEdit/TextMarkerService.cs
@@ -34,7 +34,7 @@ namespace ICSharpCode.ILSpy.AvalonEdit
///
sealed class TextMarkerService : DocumentColorizingTransformer, IBackgroundRenderer, ITextMarkerService
{
- TextSegmentCollection markers;
+ TextSegmentCollection? markers;
TextView textView;
public TextMarkerService(TextView textView)
@@ -46,7 +46,7 @@ namespace ICSharpCode.ILSpy.AvalonEdit
OnDocumentChanged(null, null);
}
- void OnDocumentChanged(object sender, EventArgs e)
+ void OnDocumentChanged(object? sender, EventArgs? e)
{
if (textView.Document != null)
markers = new TextSegmentCollection(textView.Document);
diff --git a/ILSpy/Commands/CommandWrapper.cs b/ILSpy/Commands/CommandWrapper.cs
index 2cf061b70..15e2d0592 100644
--- a/ILSpy/Commands/CommandWrapper.cs
+++ b/ILSpy/Commands/CommandWrapper.cs
@@ -39,7 +39,7 @@ namespace ICSharpCode.ILSpy
return command;
}
- public event EventHandler CanExecuteChanged {
+ public event EventHandler? CanExecuteChanged {
add { wrappedCommand.CanExecuteChanged += value; }
remove { wrappedCommand.CanExecuteChanged -= value; }
}
diff --git a/ILSpy/Commands/DelegateCommand.cs b/ILSpy/Commands/DelegateCommand.cs
index 41996e327..80345c32d 100644
--- a/ILSpy/Commands/DelegateCommand.cs
+++ b/ILSpy/Commands/DelegateCommand.cs
@@ -12,7 +12,7 @@ namespace ICSharpCode.ILSpy.Commands
private readonly Action action;
private readonly Func canExecute;
- public event EventHandler CanExecuteChanged {
+ public event EventHandler? CanExecuteChanged {
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
@@ -44,7 +44,7 @@ namespace ICSharpCode.ILSpy.Commands
private readonly Action action;
private readonly Func canExecute;
- public event EventHandler CanExecuteChanged {
+ public event EventHandler? CanExecuteChanged {
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
diff --git a/ILSpy/Commands/IProtocolHandler.cs b/ILSpy/Commands/IProtocolHandler.cs
index 53f6e7ef3..dbd6552c4 100644
--- a/ILSpy/Commands/IProtocolHandler.cs
+++ b/ILSpy/Commands/IProtocolHandler.cs
@@ -25,6 +25,6 @@ namespace ICSharpCode.ILSpy
{
public interface IProtocolHandler
{
- ILSpyTreeNode Resolve(string protocol, MetadataFile module, Handle handle, out bool newTabPage);
+ ILSpyTreeNode? Resolve(string protocol, MetadataFile module, Handle handle, out bool newTabPage);
}
}
diff --git a/ILSpy/Commands/SimpleCommand.cs b/ILSpy/Commands/SimpleCommand.cs
index 502d7ea9f..956ad70ce 100644
--- a/ILSpy/Commands/SimpleCommand.cs
+++ b/ILSpy/Commands/SimpleCommand.cs
@@ -24,7 +24,7 @@ namespace ICSharpCode.ILSpy
{
public abstract class SimpleCommand : ICommand
{
- public event EventHandler CanExecuteChanged {
+ public event EventHandler? CanExecuteChanged {
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
@@ -41,12 +41,12 @@ namespace ICSharpCode.ILSpy
{
private bool isChecked;
- public event EventHandler CanExecuteChanged {
+ public event EventHandler? CanExecuteChanged {
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
- public event PropertyChangedEventHandler PropertyChanged;
+ public event PropertyChangedEventHandler? PropertyChanged;
void ICommand.Execute(object? parameter)
{
diff --git a/ILSpy/Controls/SearchBox.cs b/ILSpy/Controls/SearchBox.cs
index 4795bbe11..e7ec45df3 100644
--- a/ILSpy/Controls/SearchBox.cs
+++ b/ILSpy/Controls/SearchBox.cs
@@ -110,7 +110,7 @@ namespace ICSharpCode.ILSpy.Controls
wl.Visibility = HasText ? Visibility.Hidden : Visibility.Visible;
}
- void timer_Tick(object sender, EventArgs e)
+ void timer_Tick(object? sender, EventArgs e)
{
timer.Stop();
timer = null;
diff --git a/ILSpy/Controls/TreeView/SharpTreeNodeView.cs b/ILSpy/Controls/TreeView/SharpTreeNodeView.cs
index 002cc9ba1..cecb3cfea 100644
--- a/ILSpy/Controls/TreeView/SharpTreeNodeView.cs
+++ b/ILSpy/Controls/TreeView/SharpTreeNodeView.cs
@@ -103,7 +103,7 @@ namespace ICSharpCode.ILSpy.Controls.TreeView
}
}
- void Node_PropertyChanged(object sender, PropertyChangedEventArgs e)
+ void Node_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "IsEditing")
{
diff --git a/ILSpy/Controls/TreeView/SharpTreeView.cs b/ILSpy/Controls/TreeView/SharpTreeView.cs
index 13b841740..845ba297c 100644
--- a/ILSpy/Controls/TreeView/SharpTreeView.cs
+++ b/ILSpy/Controls/TreeView/SharpTreeView.cs
@@ -171,7 +171,7 @@ namespace ICSharpCode.ILSpy.Controls.TreeView
}
}
- void flattener_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
+ void flattener_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
// Deselect nodes that are being hidden, if any remain in the tree
if (e.Action == NotifyCollectionChangedAction.Remove && Items.Count > 0)
diff --git a/ILSpy/Controls/TreeView/SharpTreeViewItemAutomationPeer.cs b/ILSpy/Controls/TreeView/SharpTreeViewItemAutomationPeer.cs
index ca38c4ea4..98bef52e5 100644
--- a/ILSpy/Controls/TreeView/SharpTreeViewItemAutomationPeer.cs
+++ b/ILSpy/Controls/TreeView/SharpTreeViewItemAutomationPeer.cs
@@ -32,7 +32,7 @@ namespace ICSharpCode.ILSpy.Controls.TreeView
: base(owner)
{
SharpTreeViewItem.DataContextChanged += OnDataContextChanged;
- SharpTreeNode node = SharpTreeViewItem.DataContext as SharpTreeNode;
+ SharpTreeNode? node = SharpTreeViewItem.DataContext as SharpTreeNode;
if (node == null)
return;
@@ -61,18 +61,18 @@ namespace ICSharpCode.ILSpy.Controls.TreeView
public ExpandCollapseState ExpandCollapseState {
get {
- SharpTreeNode node = SharpTreeViewItem.DataContext as SharpTreeNode;
+ SharpTreeNode? node = SharpTreeViewItem.DataContext as SharpTreeNode;
if (node == null || !node.ShowExpander)
return ExpandCollapseState.LeafNode;
return node.IsExpanded ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed;
}
}
- private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
+ private void OnPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName != "IsExpanded")
return;
- SharpTreeNode node = sender as SharpTreeNode;
+ SharpTreeNode? node = sender as SharpTreeNode;
if (node == null || node.Children.Count == 0)
return;
bool newValue = node.IsExpanded;
@@ -83,12 +83,12 @@ namespace ICSharpCode.ILSpy.Controls.TreeView
newValue ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed);
}
- private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
+ private void OnDataContextChanged(object? sender, DependencyPropertyChangedEventArgs e)
{
- SharpTreeNode oldNode = e.OldValue as SharpTreeNode;
+ SharpTreeNode? oldNode = e.OldValue as SharpTreeNode;
if (oldNode != null)
oldNode.PropertyChanged -= OnPropertyChanged;
- SharpTreeNode newNode = e.NewValue as SharpTreeNode;
+ SharpTreeNode? newNode = e.NewValue as SharpTreeNode;
if (newNode != null)
newNode.PropertyChanged += OnPropertyChanged;
}
diff --git a/ILSpy/Docking/DockWorkspace.cs b/ILSpy/Docking/DockWorkspace.cs
index a7b4c7102..59100a4d3 100644
--- a/ILSpy/Docking/DockWorkspace.cs
+++ b/ILSpy/Docking/DockWorkspace.cs
@@ -52,7 +52,7 @@ namespace ICSharpCode.ILSpy.Docking
MessageBus.Subscribers += (sender, e) => CurrentAssemblyList_Changed(sender, e);
}
- private void CurrentAssemblyList_Changed(object sender, NotifyCollectionChangedEventArgs e)
+ private void CurrentAssemblyList_Changed(object? sender, NotifyCollectionChangedEventArgs e)
{
if (e.OldItems == null)
{
@@ -163,7 +163,7 @@ namespace ICSharpCode.ILSpy.Docking
}
}
- void LayoutSerializationCallback(object sender, LayoutSerializationCallbackEventArgs e)
+ void LayoutSerializationCallback(object? sender, LayoutSerializationCallbackEventArgs e)
{
switch (e.Model)
{
diff --git a/ILSpy/Docking/PaneCollection.cs b/ILSpy/Docking/PaneCollection.cs
index 72b1b851b..a1715d9a4 100644
--- a/ILSpy/Docking/PaneCollection.cs
+++ b/ILSpy/Docking/PaneCollection.cs
@@ -30,7 +30,7 @@ namespace ICSharpCode.ILSpy.Docking
{
private ObservableCollection observableCollection = new ObservableCollection();
- public event NotifyCollectionChangedEventHandler CollectionChanged;
+ public event NotifyCollectionChangedEventHandler? CollectionChanged;
public PaneCollection()
{
diff --git a/ILSpy/LanguageSettings.cs b/ILSpy/LanguageSettings.cs
index ef7613ccf..6328a6924 100644
--- a/ILSpy/LanguageSettings.cs
+++ b/ILSpy/LanguageSettings.cs
@@ -173,9 +173,9 @@ namespace ICSharpCode.ILSpy
}
}
- public event PropertyChangedEventHandler PropertyChanged;
+ public event PropertyChangedEventHandler? PropertyChanged;
- protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
if (PropertyChanged != null)
{
diff --git a/ILSpy/Languages/Language.cs b/ILSpy/Languages/Language.cs
index 5374a8eec..b556c04ff 100644
--- a/ILSpy/Languages/Language.cs
+++ b/ILSpy/Languages/Language.cs
@@ -364,7 +364,7 @@ namespace ICSharpCode.ILSpy
/// Converts a member signature to a string.
/// This is used for displaying the tooltip on a member reference.
///
- public virtual RichText GetRichTextTooltip(IEntity entity)
+ public virtual RichText? GetRichTextTooltip(IEntity entity)
{
return GetTooltip(entity);
}
diff --git a/ILSpy/MainWindow.xaml.cs b/ILSpy/MainWindow.xaml.cs
index 87c9ce121..b17691b11 100644
--- a/ILSpy/MainWindow.xaml.cs
+++ b/ILSpy/MainWindow.xaml.cs
@@ -132,7 +132,7 @@ namespace ICSharpCode.ILSpy
this.Loaded += MainWindow_Loaded;
}
- private void DockWorkspace_ActiveTabPageChanged(object sender, EventArgs e)
+ private void DockWorkspace_ActiveTabPageChanged(object? sender, EventArgs e)
{
DockWorkspace dock = DockWorkspace.Instance;
@@ -350,7 +350,7 @@ namespace ICSharpCode.ILSpy
ToolsChanged(dock.ToolPanes, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
TabsChanged(dock.TabPages, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
- void ToolsChanged(object sender, NotifyCollectionChangedEventArgs e)
+ void ToolsChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
int endIndex = windowMenuItem.Items.IndexOf(separatorBeforeDocuments);
int startIndex = windowMenuItem.Items.IndexOf(separatorBeforeTools) + 1;
@@ -429,7 +429,7 @@ namespace ICSharpCode.ILSpy
}
}
- void TabsChanged(object sender, NotifyCollectionChangedEventArgs e)
+ void TabsChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
int endIndex = windowMenuItem.Items.Count;
int startIndex = windowMenuItem.Items.IndexOf(separatorBeforeDocuments) + 1;
@@ -498,7 +498,7 @@ namespace ICSharpCode.ILSpy
}
}
- static void TabPageChanged(object sender, PropertyChangedEventArgs e)
+ static void TabPageChanged(object? sender, PropertyChangedEventArgs e)
{
var windowMenuItem = Instance.mainMenu.Items.OfType