diff --git a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
index d2be2971e..7fd38be1a 100644
--- a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
+++ b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
@@ -541,7 +541,7 @@ namespace ICSharpCode.Decompiler.CSharp
return typeSystemAstBuilder;
}
- IDocumentationProvider CreateDefaultDocumentationProvider()
+ IDocumentationProvider? CreateDefaultDocumentationProvider()
{
try
{
@@ -1096,7 +1096,7 @@ namespace ICSharpCode.Decompiler.CSharp
return syntaxTree;
}
- ITypeDefinition FindCommonDeclaringTypeDefinition(ITypeDefinition a, ITypeDefinition b)
+ ITypeDefinition? FindCommonDeclaringTypeDefinition(ITypeDefinition a, ITypeDefinition b)
{
if (a == null || b == null)
return null;
diff --git a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
index b85f053d8..f187b3c43 100644
--- a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
+++ b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
@@ -265,7 +265,7 @@ namespace ICSharpCode.Decompiler.CSharp
}
}
- internal ILFunction ResolveLocalFunction(IMethod method)
+ internal ILFunction? ResolveLocalFunction(IMethod method)
{
Debug.Assert(method.IsLocalFunction);
method = (IMethod)((IMethod)method.MemberDefinition).ReducedFrom.MemberDefinition;
diff --git a/ICSharpCode.Decompiler/CSharp/OutputVisitor/TextWriterTokenWriter.cs b/ICSharpCode.Decompiler/CSharp/OutputVisitor/TextWriterTokenWriter.cs
index e305cb98e..477ba3a6f 100644
--- a/ICSharpCode.Decompiler/CSharp/OutputVisitor/TextWriterTokenWriter.cs
+++ b/ICSharpCode.Decompiler/CSharp/OutputVisitor/TextWriterTokenWriter.cs
@@ -437,7 +437,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
/// Gets the escape sequence for the specified character.
///
/// This method does not convert ' or ".
- static string ConvertChar(char ch)
+ static string? ConvertChar(char ch)
{
switch (ch)
{
diff --git a/ICSharpCode.Decompiler/CSharp/ProjectDecompiler/TargetFramework.cs b/ICSharpCode.Decompiler/CSharp/ProjectDecompiler/TargetFramework.cs
index 793b70e7a..ff8a2ecef 100644
--- a/ICSharpCode.Decompiler/CSharp/ProjectDecompiler/TargetFramework.cs
+++ b/ICSharpCode.Decompiler/CSharp/ProjectDecompiler/TargetFramework.cs
@@ -79,7 +79,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler
///
public bool IsPortableClassLibrary { get; }
- static string GetTargetFrameworkMoniker(string frameworkIdentifier, int version)
+ static string? GetTargetFrameworkMoniker(string frameworkIdentifier, int version)
{
// Reference: https://docs.microsoft.com/en-us/dotnet/standard/frameworks
switch (frameworkIdentifier)
diff --git a/ICSharpCode.Decompiler/CSharp/ProjectDecompiler/WholeProjectDecompiler.cs b/ICSharpCode.Decompiler/CSharp/ProjectDecompiler/WholeProjectDecompiler.cs
index a55980cf5..b9e619830 100644
--- a/ICSharpCode.Decompiler/CSharp/ProjectDecompiler/WholeProjectDecompiler.cs
+++ b/ICSharpCode.Decompiler/CSharp/ProjectDecompiler/WholeProjectDecompiler.cs
@@ -488,7 +488,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler
const int RT_ICON = 3;
const int RT_GROUP_ICON = 14;
- unsafe static byte[] CreateApplicationIcon(Win32ResourceDirectory resources)
+ unsafe static byte[]? CreateApplicationIcon(Win32ResourceDirectory resources)
{
var iconGroup = resources.Find(new Win32ResourceName(RT_GROUP_ICON))?.FirstDirectory()?.FirstData()?.Data;
if (iconGroup == null)
diff --git a/ICSharpCode.Decompiler/CSharp/Resolver/CSharpConversions.cs b/ICSharpCode.Decompiler/CSharp/Resolver/CSharpConversions.cs
index f3a37e841..9cfe6918d 100644
--- a/ICSharpCode.Decompiler/CSharp/Resolver/CSharpConversions.cs
+++ b/ICSharpCode.Decompiler/CSharp/Resolver/CSharpConversions.cs
@@ -554,7 +554,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
/// For IList{T}, ICollection{T}, IEnumerable{T} and IReadOnlyList{T}, returns T.
/// Otherwise, returns null.
///
- IType UnpackGenericArrayInterface(IType interfaceType)
+ IType? UnpackGenericArrayInterface(IType interfaceType)
{
ParameterizedType? pt = interfaceType as ParameterizedType;
if (pt != null)
@@ -938,7 +938,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
&& (StandardImplicitConversion(a, b).IsValid || StandardImplicitConversion(b, a).IsValid);
}
- IType FindMostEncompassedType(IEnumerable candidates)
+ IType? FindMostEncompassedType(IEnumerable candidates)
{
IType? best = null;
foreach (var current in candidates)
@@ -951,7 +951,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
return best;
}
- IType FindMostEncompassingType(IEnumerable candidates)
+ IType? FindMostEncompassingType(IEnumerable candidates)
{
IType? best = null;
foreach (var current in candidates)
@@ -1482,7 +1482,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
///
/// Unpacks the generic Task[T]. Returns null if the input is not Task[T].
///
- static IType UnpackTask(IType type)
+ static IType? UnpackTask(IType type)
{
ParameterizedType? pt = type as ParameterizedType;
if (pt != null && pt.TypeParameterCount == 1 && pt.Name == "Task" && pt.Namespace == "System.Threading.Tasks")
diff --git a/ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs b/ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs
index b4ed267ba..431cbdae0 100644
--- a/ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs
+++ b/ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs
@@ -565,7 +565,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
#endregion
#region GetOverloadableOperatorName
- static string GetOverloadableOperatorName(UnaryOperatorType op)
+ static string? GetOverloadableOperatorName(UnaryOperatorType op)
{
switch (op)
{
@@ -980,7 +980,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
#endregion
#region Enum helper methods
- IType GetEnumUnderlyingType(IType enumType)
+ IType? GetEnumUnderlyingType(IType enumType)
{
ITypeDefinition? def = enumType.GetDefinition();
return def != null ? def.EnumUnderlyingType : SpecialType.UnknownType;
@@ -1203,7 +1203,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
#endregion
#region GetOverloadableOperatorName
- static string GetOverloadableOperatorName(BinaryOperatorType op)
+ static string? GetOverloadableOperatorName(BinaryOperatorType op)
{
switch (op)
{
diff --git a/ICSharpCode.Decompiler/CSharp/Resolver/OverloadResolution.cs b/ICSharpCode.Decompiler/CSharp/Resolver/OverloadResolution.cs
index 690033469..311b66b67 100644
--- a/ICSharpCode.Decompiler/CSharp/Resolver/OverloadResolution.cs
+++ b/ICSharpCode.Decompiler/CSharp/Resolver/OverloadResolution.cs
@@ -891,7 +891,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
#endregion
#region Output Properties
- public IParameterizedMember BestCandidate {
+ public IParameterizedMember? BestCandidate {
get { return bestCandidate != null ? bestCandidate.Member : null; }
}
@@ -919,7 +919,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
get { return bestCandidate != null && IsApplicable(bestCandidate.Errors); }
}
- public IParameterizedMember BestCandidateAmbiguousWith {
+ public IParameterizedMember? BestCandidateAmbiguousWith {
get { return bestCandidateAmbiguousWith != null ? bestCandidateAmbiguousWith.Member : null; }
}
@@ -958,7 +958,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
///
/// parameterIndex = GetArgumentToParameterMap()[argumentIndex]
///
- public IReadOnlyList GetArgumentToParameterMap()
+ public IReadOnlyList? GetArgumentToParameterMap()
{
if (bestCandidate != null)
return bestCandidate.ArgumentToParameterMap;
@@ -1037,7 +1037,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
return args;
}
- public IParameterizedMember GetBestCandidateWithSubstitutedTypeArguments()
+ public IParameterizedMember? GetBestCandidateWithSubstitutedTypeArguments()
{
if (bestCandidate == null)
return null;
diff --git a/ICSharpCode.Decompiler/CSharp/Resolver/TypeInference.cs b/ICSharpCode.Decompiler/CSharp/Resolver/TypeInference.cs
index 280c968f6..3942c2d1e 100644
--- a/ICSharpCode.Decompiler/CSharp/Resolver/TypeInference.cs
+++ b/ICSharpCode.Decompiler/CSharp/Resolver/TypeInference.cs
@@ -698,7 +698,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
}
}
- TP GetTPForType(IType v)
+ TP? GetTPForType(IType v)
{
if (v is NullabilityAnnotatedTypeParameter natp)
{
diff --git a/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs b/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs
index 37db21cda..e335af219 100644
--- a/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs
+++ b/ICSharpCode.Decompiler/CSharp/StatementBuilder.cs
@@ -624,7 +624,7 @@ namespace ICSharpCode.Decompiler.CSharp
}
}
- Statement TransformToForeach(UsingInstruction inst, Expression resource)
+ Statement? TransformToForeach(UsingInstruction inst, Expression resource)
{
if (!settings.ForEachStatement)
{
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/DepthFirstAstVisitor.cs b/ICSharpCode.Decompiler/CSharp/Syntax/DepthFirstAstVisitor.cs
index 7dc80d576..2a4317d4d 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/DepthFirstAstVisitor.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/DepthFirstAstVisitor.cs
@@ -713,7 +713,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
///
public abstract class DepthFirstAstVisitor : IAstVisitor
{
- protected virtual T VisitChildren(AstNode node)
+ protected virtual T? VisitChildren(AstNode node)
{
AstNode? next;
for (var child = node.FirstChild; child != null; child = next)
@@ -726,7 +726,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return default(T);
}
- public virtual T VisitNullNode(AstNode nullNode)
+ public virtual T? VisitNullNode(AstNode nullNode)
{
// Should we call VisitChildren here?
// We usually want to ignore null nodes.
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/UnaryOperatorExpression.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/UnaryOperatorExpression.cs
index 3052e1bf7..596b13b77 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/UnaryOperatorExpression.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/Expressions/UnaryOperatorExpression.cs
@@ -94,7 +94,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
&& this.Expression.DoMatch(o.Expression, match);
}
- public static TokenRole GetOperatorRole(UnaryOperatorType op)
+ public static TokenRole? GetOperatorRole(UnaryOperatorType op)
{
switch (op)
{
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/OperatorDeclaration.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/OperatorDeclaration.cs
index 70343f3ac..e004eabc2 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/OperatorDeclaration.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/OperatorDeclaration.cs
@@ -293,7 +293,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
///
/// Gets the method name for the operator type. ("op_Addition", "op_Implicit", etc.)
///
- public static string GetName(OperatorType? type)
+ public static string? GetName(OperatorType? type)
{
if (type == null)
return null;
diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs b/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs
index cc70cac43..3b5320f86 100644
--- a/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs
+++ b/ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs
@@ -1443,7 +1443,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
const float MathF_PI = 3.14159274f;
const float MathF_E = 2.71828175f;
- Expression TryExtractExpression(IType mathType, IType type, object literalValue, string memberName, bool isDouble)
+ Expression? TryExtractExpression(IType mathType, IType type, object literalValue, string memberName, bool isDouble)
{
Expression MakeFieldReference()
{
@@ -1464,7 +1464,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return new CastExpression(ConvertType(type), fieldRef);
}
- Expression ExtractExpression(long n, long d)
+ Expression? ExtractExpression(long n, long d)
{
Expression fieldReference = MakeFieldReference();
@@ -2400,7 +2400,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return decl;
}
- internal Constraint ConvertTypeParameterConstraint(ITypeParameter tp)
+ internal Constraint? ConvertTypeParameterConstraint(ITypeParameter tp)
{
if (!tp.HasDefaultConstructorConstraint && !tp.HasReferenceTypeConstraint && !tp.HasValueTypeConstraint && tp.NullabilityConstraint != Nullability.NotNullable && tp.DirectBaseTypes.All(IsObjectOrValueType))
{
diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUnsafeModifier.cs b/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUnsafeModifier.cs
index 0688e9c49..7a7e3ab25 100644
--- a/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUnsafeModifier.cs
+++ b/ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUnsafeModifier.cs
@@ -40,8 +40,8 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
protected override bool VisitChildren(AstNode node)
{
bool result = false;
- AstNode next;
- for (AstNode child = node.FirstChild; child != null; child = next)
+ AstNode? next;
+ for (AstNode? child = node.FirstChild; child != null; child = next)
{
// Store next to allow the loop to continue
// if the visitor removes/replaces child.
diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/PatternStatementTransform.cs b/ICSharpCode.Decompiler/CSharp/Transforms/PatternStatementTransform.cs
index 114e60daf..5424ececc 100644
--- a/ICSharpCode.Decompiler/CSharp/Transforms/PatternStatementTransform.cs
+++ b/ICSharpCode.Decompiler/CSharp/Transforms/PatternStatementTransform.cs
@@ -77,7 +77,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
public override AstNode VisitExpressionStatement(ExpressionStatement expressionStatement)
{
- AstNode result = TransformForeachOnMultiDimArray(expressionStatement);
+ AstNode? result = TransformForeachOnMultiDimArray(expressionStatement);
if (result != null)
return result;
result = TransformFor(expressionStatement);
@@ -182,7 +182,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
if (!m1.Success)
return null;
var variable = m1.Get("variable").Single().GetILVariable();
- AstNode next = node.NextSibling;
+ AstNode? next = node.NextSibling;
if (next is ForStatement forStatement && ForStatementUsesVariable(forStatement, variable))
{
node.Remove();
@@ -477,7 +477,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
return true;
}
- Statement TransformForeachOnMultiDimArray(ExpressionStatement expressionStatement)
+ Statement? TransformForeachOnMultiDimArray(ExpressionStatement expressionStatement)
{
if (!context.Settings.ForEachStatement)
return null;
@@ -609,7 +609,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
return true;
}
- PropertyDeclaration TransformAutomaticProperty(PropertyDeclaration propertyDeclaration)
+ PropertyDeclaration? TransformAutomaticProperty(PropertyDeclaration propertyDeclaration)
{
IProperty? property = propertyDeclaration.GetSymbol() as IProperty;
if (!CanTransformToAutomaticProperty(property, !property.DeclaringTypeDefinition.Fields.Any(f => f.Name == "_" + property.Name && f.IsCompilerGenerated())))
@@ -736,7 +736,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
return true;
}
- Identifier ReplaceBackingFieldUsage(Identifier identifier)
+ Identifier? ReplaceBackingFieldUsage(Identifier identifier)
{
if (NameCouldBeBackingFieldOfAutomaticProperty(identifier.Name, out _))
{
@@ -757,7 +757,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
return null;
}
- Identifier ReplaceEventFieldAnnotation(Identifier identifier)
+ Identifier? ReplaceEventFieldAnnotation(Identifier identifier)
{
var parent = identifier.Parent;
var mrr = parent.Annotation();
@@ -995,7 +995,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
return true;
}
- EventDeclaration TransformAutomaticEvents(CustomEventDeclaration ev)
+ EventDeclaration? TransformAutomaticEvents(CustomEventDeclaration ev)
{
if (!ev.PrivateImplementationType.IsNull)
return null;
@@ -1055,7 +1055,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
Body = destructorBodyPattern
};
- DestructorDeclaration TransformDestructor(MethodDeclaration methodDef)
+ DestructorDeclaration? TransformDestructor(MethodDeclaration methodDef)
{
Match m = destructorPattern.Match(methodDef);
if (m.Success)
@@ -1072,7 +1072,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
return null;
}
- DestructorDeclaration TransformDestructorBody(DestructorDeclaration dtorDef)
+ DestructorDeclaration? TransformDestructorBody(DestructorDeclaration dtorDef)
{
Match m = destructorBodyPattern.Match(dtorDef.Body);
if (m.Success)
@@ -1099,7 +1099,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
/// Simplify nested 'try { try {} catch {} } finally {}'.
/// This transformation must run after the using/lock tranformations.
///
- TryCatchStatement TransformTryCatchFinally(TryCatchStatement tryFinally)
+ TryCatchStatement? TransformTryCatchFinally(TryCatchStatement tryFinally)
{
if (tryCatchFinallyPattern.IsMatch(tryFinally))
{
@@ -1130,7 +1130,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
}
};
- AstNode SimplifyCascadingIfElseStatements(IfElseStatement node)
+ AstNode? SimplifyCascadingIfElseStatements(IfElseStatement node)
{
Match m = cascadingIfElsePattern.Match(node);
if (m.Success)
diff --git a/ICSharpCode.Decompiler/CSharp/TypeSystem/ResolvedUsingScope.cs b/ICSharpCode.Decompiler/CSharp/TypeSystem/ResolvedUsingScope.cs
index 87441be6e..0d42b9786 100644
--- a/ICSharpCode.Decompiler/CSharp/TypeSystem/ResolvedUsingScope.cs
+++ b/ICSharpCode.Decompiler/CSharp/TypeSystem/ResolvedUsingScope.cs
@@ -213,12 +213,12 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
get { return parentNamespace.Compilation; }
}
- INamespace INamespace.GetChildNamespace(string name)
+ INamespace? INamespace.GetChildNamespace(string name)
{
return null;
}
- ITypeDefinition INamespace.GetTypeDefinition(string name, int typeParameterCount)
+ ITypeDefinition? INamespace.GetTypeDefinition(string name, int typeParameterCount)
{
return null;
}
diff --git a/ICSharpCode.Decompiler/CSharp/TypeSystem/TypeOrNamespaceReference.cs b/ICSharpCode.Decompiler/CSharp/TypeSystem/TypeOrNamespaceReference.cs
index aa69222f3..749aeee14 100644
--- a/ICSharpCode.Decompiler/CSharp/TypeSystem/TypeOrNamespaceReference.cs
+++ b/ICSharpCode.Decompiler/CSharp/TypeSystem/TypeOrNamespaceReference.cs
@@ -43,7 +43,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
///
/// Returns the namespace that is referenced; or null if no such namespace is found.
///
- public INamespace ResolveNamespace(CSharpResolver resolver)
+ public INamespace? ResolveNamespace(CSharpResolver resolver)
{
NamespaceResolveResult? nrr = Resolve(resolver) as NamespaceResolveResult;
return nrr != null ? nrr.Namespace : null;
diff --git a/ICSharpCode.Decompiler/Disassembler/DisassemblerHelpers.cs b/ICSharpCode.Decompiler/Disassembler/DisassemblerHelpers.cs
index 3f3aea4e5..78d1f8259 100644
--- a/ICSharpCode.Decompiler/Disassembler/DisassemblerHelpers.cs
+++ b/ICSharpCode.Decompiler/Disassembler/DisassemblerHelpers.cs
@@ -150,7 +150,7 @@ namespace ICSharpCode.Decompiler.Disassembler
writer.WriteLocalReference(name, "param_" + index);
}
- string GetParameterName(int parameterNumber)
+ string? GetParameterName(int parameterNumber)
{
var methodDefinition = metadata.GetMethodDefinition(handle);
if ((methodDefinition.Attributes & System.Reflection.MethodAttributes.Static) != 0)
@@ -339,7 +339,7 @@ namespace ICSharpCode.Decompiler.Disassembler
}
return sb.ToString();
}
- public static string PrimitiveTypeName(string fullName)
+ public static string? PrimitiveTypeName(string fullName)
{
switch (fullName)
{
diff --git a/ICSharpCode.Decompiler/Documentation/IdStringMemberReference.cs b/ICSharpCode.Decompiler/Documentation/IdStringMemberReference.cs
index 3b0ad8bdc..a9226da95 100644
--- a/ICSharpCode.Decompiler/Documentation/IdStringMemberReference.cs
+++ b/ICSharpCode.Decompiler/Documentation/IdStringMemberReference.cs
@@ -61,7 +61,7 @@ namespace ICSharpCode.Decompiler.Documentation
get { return declaringTypeReference; }
}
- public IMember Resolve(ITypeResolveContext context)
+ public IMember? Resolve(ITypeResolveContext context)
{
IType declaringType = declaringTypeReference.Resolve(context);
foreach (var member in declaringType.GetMembers(CanMatch, GetMemberOptions.IgnoreInheritedMembers))
diff --git a/ICSharpCode.Decompiler/Documentation/XmlDocLoader.cs b/ICSharpCode.Decompiler/Documentation/XmlDocLoader.cs
index de2b116f0..1a7d16695 100644
--- a/ICSharpCode.Decompiler/Documentation/XmlDocLoader.cs
+++ b/ICSharpCode.Decompiler/Documentation/XmlDocLoader.cs
@@ -34,7 +34,7 @@ namespace ICSharpCode.Decompiler.Documentation
static readonly Lazy mscorlibDocumentation = new Lazy(LoadMscorlibDocumentation);
static readonly ConditionalWeakTable cache = new();
- static XmlDocumentationProvider LoadMscorlibDocumentation()
+ static XmlDocumentationProvider? LoadMscorlibDocumentation()
{
string xmlDocFile = FindXmlDocumentation("mscorlib.dll", TargetRuntime.Net_4_0)
?? FindXmlDocumentation("mscorlib.dll", TargetRuntime.Net_2_0);
@@ -120,7 +120,7 @@ namespace ICSharpCode.Decompiler.Documentation
/// Given the assembly file name, looks up the XML documentation file name.
/// Returns null if no XML documentation file is found.
///
- internal static string LookupLocalizedXmlDoc(string fileName)
+ internal static string? LookupLocalizedXmlDoc(string fileName)
{
if (string.IsNullOrEmpty(fileName))
return null;
diff --git a/ICSharpCode.Decompiler/Documentation/XmlDocumentationProvider.cs b/ICSharpCode.Decompiler/Documentation/XmlDocumentationProvider.cs
index af9bf21f7..40f39261e 100644
--- a/ICSharpCode.Decompiler/Documentation/XmlDocumentationProvider.cs
+++ b/ICSharpCode.Decompiler/Documentation/XmlDocumentationProvider.cs
@@ -81,7 +81,7 @@ namespace ICSharpCode.Decompiler.Documentation
return false;
}
- internal void Add(string key, string value)
+ internal void Add(string key, string? value)
{
entries[pos++] = new KeyValuePair(key, value);
if (pos == entries.Length)
@@ -279,7 +279,7 @@ namespace ICSharpCode.Decompiler.Documentation
if (reader.LocalName == "member")
{
int pos = linePosMapper.GetPositionForLine(reader.LineNumber) + Math.Max(reader.LinePosition - 2, 0);
- string memberAttr = reader.GetAttribute("name");
+ string? memberAttr = reader.GetAttribute("name");
if (memberAttr != null)
indexList.Add(new IndexEntry(GetHashCode(memberAttr), pos));
reader.Skip();
@@ -330,7 +330,7 @@ namespace ICSharpCode.Decompiler.Documentation
return GetDocumentation(entity.GetIdString());
}
- string GetDocumentation(string key, bool allowReload)
+ string? GetDocumentation(string key, bool allowReload)
{
int hashcode = GetHashCode(key);
var index = this.index; // read volatile field
@@ -347,7 +347,7 @@ namespace ICSharpCode.Decompiler.Documentation
XmlDocumentationCache cache = this.cache;
lock (cache)
{
- if (!cache.TryGet(key, out string val))
+ if (!cache.TryGet(key, out string? val))
{
try
{
@@ -376,7 +376,7 @@ namespace ICSharpCode.Decompiler.Documentation
}
}
- string ReloadAndGetDocumentation(string key)
+ string? ReloadAndGetDocumentation(string key)
{
try
{
@@ -407,7 +407,7 @@ namespace ICSharpCode.Decompiler.Documentation
#endregion
#region Load / Read XML
- string LoadDocumentation(string key, int positionInFile)
+ string? LoadDocumentation(string key, int positionInFile)
{
using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete))
{
@@ -420,7 +420,7 @@ namespace ICSharpCode.Decompiler.Documentation
{
if (r.NodeType == XmlNodeType.Element)
{
- string memberAttr = r.GetAttribute("name");
+ string? memberAttr = r.GetAttribute("name");
if (memberAttr == key)
{
return r.ReadInnerXml();
diff --git a/ICSharpCode.Decompiler/FlowAnalysis/DataFlowVisitor.cs b/ICSharpCode.Decompiler/FlowAnalysis/DataFlowVisitor.cs
index 06d4a24d3..fd050c349 100644
--- a/ICSharpCode.Decompiler/FlowAnalysis/DataFlowVisitor.cs
+++ b/ICSharpCode.Decompiler/FlowAnalysis/DataFlowVisitor.cs
@@ -237,7 +237,7 @@ namespace ICSharpCode.Decompiler.FlowAnalysis
#if DEBUG
Debug.Assert(initialized, "Initialize() was not called");
- if (debugDict.TryGetValue(inst, out State previousState))
+ if (debugDict.TryGetValue(inst, out State? previousState))
{
Debug.Assert(previousState.LessThanOrEqual(state));
previousState.JoinWith(state);
@@ -350,7 +350,7 @@ namespace ICSharpCode.Decompiler.FlowAnalysis
///
State GetBlockInputState(Block block)
{
- if (stateOnBranch.TryGetValue(block, out State s))
+ if (stateOnBranch.TryGetValue(block, out State? s))
{
return s;
}
@@ -398,7 +398,7 @@ namespace ICSharpCode.Decompiler.FlowAnalysis
state.ReplaceWith(stateOnBranch[block]);
block.AcceptVisitor(this);
}
- if (stateOnLeave.TryGetValue(container, out State stateOnExit))
+ if (stateOnLeave.TryGetValue(container, out State? stateOnExit))
{
state.ReplaceWith(stateOnExit);
}
@@ -463,7 +463,7 @@ namespace ICSharpCode.Decompiler.FlowAnalysis
void MergeBranchStateIntoStateOnLeave(Leave inst, State branchState)
{
- if (stateOnLeave.TryGetValue(inst.TargetContainer, out State targetState))
+ if (stateOnLeave.TryGetValue(inst.TargetContainer, out State? targetState))
{
targetState.JoinWith(branchState);
}
@@ -505,7 +505,7 @@ namespace ICSharpCode.Decompiler.FlowAnalysis
protected State HandleTryBlock(TryInstruction inst)
{
State oldStateOnException = currentStateOnException;
- if (stateOnException.TryGetValue(inst, out State newStateOnException))
+ if (stateOnException.TryGetValue(inst, out State? newStateOnException))
{
newStateOnException.JoinWith(state);
}
diff --git a/ICSharpCode.Decompiler/Humanizer/Vocabulary.cs b/ICSharpCode.Decompiler/Humanizer/Vocabulary.cs
index f90125416..620107f2b 100644
--- a/ICSharpCode.Decompiler/Humanizer/Vocabulary.cs
+++ b/ICSharpCode.Decompiler/Humanizer/Vocabulary.cs
@@ -119,7 +119,7 @@ namespace Humanizer.Inflections
return result ?? word;
}
- private string ApplyRules(IList rules, string word, bool skipFirstRule)
+ private string? ApplyRules(IList rules, string word, bool skipFirstRule)
{
if (word == null)
{
@@ -164,7 +164,7 @@ namespace Humanizer.Inflections
_replacement = replacement;
}
- public string Apply(string word)
+ public string? Apply(string word)
{
if (!_regex.IsMatch(word))
{
diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/LoopDetection.cs b/ICSharpCode.Decompiler/IL/ControlFlow/LoopDetection.cs
index 1c8256801..099d5325c 100644
--- a/ICSharpCode.Decompiler/IL/ControlFlow/LoopDetection.cs
+++ b/ICSharpCode.Decompiler/IL/ControlFlow/LoopDetection.cs
@@ -311,7 +311,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
/// 3) otherwise (exit point unknown, heuristically extend loop): null
///
/// This method must not write to the Visited flags on the CFG.
- internal ControlFlowNode FindExitPoint(ControlFlowNode loopHead, IReadOnlyList naturalLoop)
+ internal ControlFlowNode? FindExitPoint(ControlFlowNode loopHead, IReadOnlyList naturalLoop)
{
bool hasReachableExit = HasReachableExit(loopHead);
if (!hasReachableExit)
diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/SwitchAnalysis.cs b/ICSharpCode.Decompiler/IL/ControlFlow/SwitchAnalysis.cs
index 8114f1e21..42c0f668d 100644
--- a/ICSharpCode.Decompiler/IL/ControlFlow/SwitchAnalysis.cs
+++ b/ICSharpCode.Decompiler/IL/ControlFlow/SwitchAnalysis.cs
@@ -126,7 +126,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
trueValues = trueValues.IntersectWith(inputValues);
if (trueValues.SetEquals(inputValues) || trueValues.IsEmpty)
return false;
- Block trueBlock;
+ Block? trueBlock;
if (trueInst.MatchBranch(out trueBlock) && AnalyzeBlock(trueBlock, trueValues))
{
// OK, true block was further analyzed.
@@ -159,7 +159,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
var remainingValues = inputValues.ExceptWith(trueValues);
ILInstruction falseInst = block.Instructions.Last();
- Block falseBlock;
+ Block? falseBlock;
if (falseInst.MatchBranch(out falseBlock) && AnalyzeBlock(falseBlock, remainingValues))
{
// OK, false block was further analyzed.
@@ -237,7 +237,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
{
return;
}
- if (inst.MatchBranch(out Block targetBlock))
+ if (inst.MatchBranch(out Block? targetBlock))
{
if (targetBlockToSectionIndex.TryGetValue(targetBlock, out int index))
{
@@ -252,7 +252,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
Sections.Add(new KeyValuePair(values, inst));
}
}
- else if (inst.MatchLeave(out BlockContainer targetContainer))
+ else if (inst.MatchLeave(out BlockContainer? targetContainer))
{
if (targetContainerToSectionIndex.TryGetValue(targetContainer, out int index))
{
diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/SwitchDetection.cs b/ICSharpCode.Decompiler/IL/ControlFlow/SwitchDetection.cs
index 88f316daf..2f0010516 100644
--- a/ICSharpCode.Decompiler/IL/ControlFlow/SwitchDetection.cs
+++ b/ICSharpCode.Decompiler/IL/ControlFlow/SwitchDetection.cs
@@ -233,9 +233,9 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
var dict = new Dictionary(); // branch target -> switch section
sw.Sections.RemoveAll(
section => {
- if (section.Body.MatchBranch(out Block target))
+ if (section.Body.MatchBranch(out Block? target))
{
- if (dict.TryGetValue(target, out SwitchSection primarySection))
+ if (dict.TryGetValue(target, out SwitchSection? primarySection))
{
primarySection.Labels = primarySection.Labels.UnionWith(section.Labels);
primarySection.HasNullLabel |= section.HasNullLabel;
@@ -438,13 +438,13 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
// if (comp(logic.not(call get_HasValue(ldloca nullableVar))) br NullCase
// br RootBlock
- var nullableBlock = (Block)controlFlowGraph.GetNode(analysis.RootBlock).Predecessors.SingleOrDefault()?.UserData;
+ var nullableBlock = (Block?)controlFlowGraph.GetNode(analysis.RootBlock).Predecessors.SingleOrDefault()?.UserData;
if (nullableBlock == null ||
nullableBlock.Instructions.Count < 2 ||
!nullableBlock.Instructions.Last().MatchBranch(analysis.RootBlock) ||
!nullableBlock.Instructions.SecondToLastOrDefault().MatchIfInstruction(out var cond, out var trueInst) ||
!cond.MatchLogicNot(out var getHasValue) ||
- !NullableLiftingTransform.MatchHasValueCall(getHasValue, out ILInstruction nullableInst))
+ !NullableLiftingTransform.MatchHasValueCall(getHasValue, out ILInstruction? nullableInst))
return;
// could check that nullableInst is ldloc or ldloca and that the switch variable matches a GetValueOrDefault
diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs b/ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs
index 4856bdbb3..a018bfe28 100644
--- a/ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs
+++ b/ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs
@@ -269,7 +269,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
return false;
}
- ILInstruction newObj;
+ ILInstruction? newObj;
if (body.Instructions.Count == 1)
{
// No parameters passed to enumerator (not even 'this'):
@@ -943,7 +943,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
void ConvertBranchAfterYieldReturn(Block newBlock, Block oldBlock, int pos)
{
- Block targetBlock;
+ Block? targetBlock;
if (isCompiledWithMono && disposingField != null)
{
// Mono skips over the state assignment if 'this.disposing' is set:
@@ -1233,7 +1233,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
{
context.CancellationToken.ThrowIfCancellationRequested();
int oldState = blockState[block.ChildIndex];
- BlockContainer container; // new container for the block
+ BlockContainer? container; // new container for the block
if (GetNewState(block) is int newState)
{
// OK, state change
@@ -1436,7 +1436,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
return false;
if (!call.Method.Name.StartsWith("<>__Finally"))
return false;
- ITypeDefinition declaringTypeDefinition = call.Method.DeclaringTypeDefinition;
+ ITypeDefinition? declaringTypeDefinition = call.Method.DeclaringTypeDefinition;
if (declaringTypeDefinition.MetadataToken != this.enumeratorType)
return false;
if (declaringTypeDefinition.ParentModule.MetadataFile.Metadata != metadata)
diff --git a/ICSharpCode.Decompiler/IL/PointerArithmeticOffset.cs b/ICSharpCode.Decompiler/IL/PointerArithmeticOffset.cs
index b4c4008b3..344ab6db8 100644
--- a/ICSharpCode.Decompiler/IL/PointerArithmeticOffset.cs
+++ b/ICSharpCode.Decompiler/IL/PointerArithmeticOffset.cs
@@ -35,7 +35,7 @@ namespace ICSharpCode.Decompiler.IL
/// The target type of the pointer type.
/// Whether the pointer arithmetic operation checks for overflow.
/// Whether to allow zero extensions in the mul argument.
- public static ILInstruction Detect(ILInstruction byteOffsetInst, IType pointerElementType,
+ public static ILInstruction? Detect(ILInstruction byteOffsetInst, IType pointerElementType,
bool checkForOverflow,
bool unwrapZeroExtension = false)
{
diff --git a/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs b/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs
index b54ecfc8f..ecc219400 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs
@@ -227,7 +227,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{
var v = i.Variable;
// if there is already a valid name for the variable slot, just use it
- if (variableMapping.TryGetValue(v, out string name))
+ if (variableMapping.TryGetValue(v, out string? name))
{
v.Name = name;
continue;
@@ -463,7 +463,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return SplitName(proposedName, out _);
}
- static string GetNameFromInstruction(ILInstruction inst)
+ static string? GetNameFromInstruction(ILInstruction inst)
{
switch (inst)
{
@@ -506,7 +506,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return null;
}
- static string GetNameForArgument(ILInstruction parent, int i)
+ static string? GetNameForArgument(ILInstruction parent, int i)
{
switch (parent)
{
@@ -566,7 +566,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
type = NullableType.GetUnderlyingType(((TypeWithElementType)type).ElementType);
}
- string name = type.Kind switch {
+ string? name = type.Kind switch {
TypeKind.Array => "array",
TypeKind.Pointer => "ptr",
TypeKind.TypeParameter => "val",
@@ -637,7 +637,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return name;
}
- static string CleanUpVariableName(string name)
+ static string? CleanUpVariableName(string name)
{
// remove the backtick (generics)
int pos = name.IndexOf('`');
diff --git a/ICSharpCode.Decompiler/IL/Transforms/CombineExitsTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/CombineExitsTransform.cs
index 03e6ffbf1..fa067c882 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/CombineExitsTransform.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/CombineExitsTransform.cs
@@ -30,7 +30,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
ExpressionTransforms.RunOnSingleStatement(combinedExit, context);
}
- static Leave CombineExits(Block block)
+ static Leave? CombineExits(Block block)
{
if (!(block.Instructions.SecondToLastOrDefault() is IfInstruction ifInst && block.Instructions.LastOrDefault() is Leave leaveElse))
return null;
diff --git a/ICSharpCode.Decompiler/IL/Transforms/DeconstructionTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/DeconstructionTransform.cs
index 30fa9dc15..78181b4a7 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/DeconstructionTransform.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/DeconstructionTransform.cs
@@ -191,8 +191,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{
int startPos = pos;
Action? delayedActions = null;
- if (MatchDeconstruction(block.Instructions[pos], out IMethod deconstructMethod,
- out ILInstruction rootTestedOperand))
+ if (MatchDeconstruction(block.Instructions[pos], out IMethod? deconstructMethod,
+ out ILInstruction? rootTestedOperand))
{
pos++;
}
diff --git a/ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs b/ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs
index a3b8caa15..6d0909158 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs
@@ -80,7 +80,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
- internal static bool MatchDelegateConstruction(ILInstruction inst, out IMethod? targetMethod,
+ internal static bool MatchDelegateConstruction(ILInstruction? inst, out IMethod? targetMethod,
[NotNullWhen(true)] out ILInstruction? target, [NotNullWhen(true)] out IType? delegateType, bool allowTransformed = false)
{
targetMethod = null;
@@ -165,7 +165,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return new GenericContext(classTypeParameters, methodTypeParameters);
}
- ILFunction TransformDelegateConstruction(
+ ILFunction? TransformDelegateConstruction(
ILInstruction value, IMethod targetMethod,
ILInstruction target, IType delegateType)
{
diff --git a/ICSharpCode.Decompiler/IL/Transforms/DynamicCallSiteTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/DynamicCallSiteTransform.cs
index 2bd7b5ea0..54b8cd5cf 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/DynamicCallSiteTransform.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/DynamicCallSiteTransform.cs
@@ -147,7 +147,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
container.SortBlocks(deleteUnreachableBlocks: true);
}
- ILInstruction MakeDynamicInstruction(CallSiteInfo callsite, CallVirt targetInvokeCall, List deadArguments)
+ ILInstruction? MakeDynamicInstruction(CallSiteInfo callsite, CallVirt targetInvokeCall, List deadArguments)
{
switch (callsite.Kind)
{
diff --git a/ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs b/ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs
index e65bac4fe..5a28917a6 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs
@@ -141,7 +141,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
else if (rightWithoutConv.MatchLdcI4(0) && inst.Kind.IsEqualityOrInequality())
{
- if (inst.Left.MatchLdLen(StackType.I, out ILInstruction array))
+ if (inst.Left.MatchLdLen(StackType.I, out ILInstruction? array))
{
// comp.unsigned(ldlen array == conv i4->i(ldc.i4 0))
// => comp(ldlen.i4 array == ldc.i4 0)
@@ -167,7 +167,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
protected internal override void VisitConv(Conv inst)
{
inst.Argument.AcceptVisitor(this);
- if (inst.Argument.MatchLdLen(StackType.I, out ILInstruction array) && inst.TargetType.IsIntegerType()
+ if (inst.Argument.MatchLdLen(StackType.I, out ILInstruction? array) && inst.TargetType.IsIntegerType()
&& (!inst.CheckForOverflow || context.Settings.AssumeArrayLengthFitsIntoInt32))
{
context.Step("conv.i4(ldlen array) => ldlen.i4(array)", inst);
@@ -303,7 +303,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
protected internal override void VisitNewObj(NewObj inst)
{
Block? block;
- if (TransformSpanTCtorContainingStackAlloc(inst, out ILInstruction locallocSpan))
+ if (TransformSpanTCtorContainingStackAlloc(inst, out ILInstruction? locallocSpan))
{
context.Step("new Span(stackalloc) -> stackalloc Span", inst);
inst.ReplaceWith(locallocSpan);
@@ -329,7 +329,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
inst.ReplaceWith(replacement);
return;
}
- if (TransformDelegateCtorLdVirtFtnToLdVirtDelegate(inst, out LdVirtDelegate ldVirtDelegate))
+ if (TransformDelegateCtorLdVirtFtnToLdVirtDelegate(inst, out LdVirtDelegate? ldVirtDelegate))
{
context.Step("new Delegate(target, ldvirtftn Method) -> ldvirtdelegate Delegate Method(target)", inst);
inst.ReplaceWith(ldVirtDelegate);
@@ -462,7 +462,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
EarlyExpressionTransforms.AddressOfLdLocToLdLoca(inst, context);
if (EarlyExpressionTransforms.LdObjToLdLoc(inst, context))
return;
- if (TransformDecimalFieldToConstant(inst, out LdcDecimal decimalConstant))
+ if (TransformDecimalFieldToConstant(inst, out LdcDecimal? decimalConstant))
{
context.Step("TransformDecimalFieldToConstant", inst);
inst.ReplaceWith(decimalConstant);
@@ -549,8 +549,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
Block? falseInst = inst.FalseInst as Block;
if (falseInst == null || falseInst.Instructions.Count != 1)
return inst;
- ILVariable v;
- ILInstruction value1, value2;
+ ILVariable? v;
+ ILInstruction? value1, value2;
if (trueInst.Instructions[0].MatchStLoc(out v, out value1) && falseInst.Instructions[0].MatchStLoc(v, out value2))
{
context.Step("conditional operator", inst);
@@ -629,7 +629,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{
// validate that each integer is used for exactly one value
var integersUsed = new HashSet();
- foreach ((string key, int val) in str2int.Map)
+ foreach ((string? key, int val) in str2int.Map)
{
if (!integersUsed.Add(val))
return;
diff --git a/ICSharpCode.Decompiler/IL/Transforms/HighLevelLoopTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/HighLevelLoopTransform.cs
index c637979aa..7ed3818d2 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/HighLevelLoopTransform.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/HighLevelLoopTransform.cs
@@ -156,21 +156,21 @@ namespace ICSharpCode.Decompiler.IL.Transforms
///
bool MatchDoWhileLoop(BlockContainer loop)
{
- (List? conditions, ILInstruction exit, bool swap, bool split, bool unwrap) = AnalyzeDoWhileConditions(loop);
+ (List? conditions, ILInstruction? exit, bool swap, bool split, bool unwrap) = AnalyzeDoWhileConditions(loop);
// not a do-while loop, exit.
if (conditions == null || conditions.Count == 0)
return false;
context.Step("Transform to do-while loop: " + loop.EntryPoint.Label, loop);
Block conditionBlock;
// first we remove all extracted instructions from the original block.
- var originalBlock = (Block)exit.Parent;
+ var originalBlock = exit.Parent as Block;
if (unwrap)
{
// we found a condition block nested in a condition that is followed by a return statement:
// we flip the condition and swap the blocks
Debug.Assert(originalBlock.Parent is IfInstruction);
var returnCondition = (IfInstruction)originalBlock.Parent;
- var topLevelBlock = (Block)returnCondition.Parent;
+ var topLevelBlock = returnCondition.Parent as Block;
Debug.Assert(topLevelBlock.Parent == loop);
var leaveFunction = topLevelBlock.Instructions[returnCondition.ChildIndex + 1];
Debug.Assert(leaveFunction.MatchReturn(out _));
diff --git a/ICSharpCode.Decompiler/IL/Transforms/ILExtraction.cs b/ICSharpCode.Decompiler/IL/Transforms/ILExtraction.cs
index a3627a221..12432ff90 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/ILExtraction.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/ILExtraction.cs
@@ -97,7 +97,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
///
/// May return null if extraction is not possible.
///
- public static ILVariable Extract(ILInstruction instToExtract, ILTransformContext context)
+ public static ILVariable? Extract(ILInstruction instToExtract, ILTransformContext context)
{
var function = instToExtract.Ancestors.OfType().First();
ExtractionContext ctx = new ExtractionContext(function, context);
diff --git a/ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs b/ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs
index b94826d99..bc4ccdf3b 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs
@@ -577,7 +577,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{
if (findResult.Type == FindResultType.NamedArgument)
{
- var originalStore = (StLoc)inlinedExpression.Parent;
+ var originalStore = inlinedExpression.Parent as StLoc;
return !originalStore.ILStackWasEmpty;
}
Debug.Assert(findResult.Type == FindResultType.Found);
@@ -784,7 +784,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
if (expr.MatchLdLoc(v) || expr.MatchLdLoca(v))
{
// Match found, we can inline
- if (expr.SlotInfo == StObj.TargetSlot && !((StObj)expr.Parent).CanInlineIntoTargetSlot(expressionBeingMoved))
+ if (expr.SlotInfo == StObj.TargetSlot && !(expr.Parent as StObj).CanInlineIntoTargetSlot(expressionBeingMoved))
{
if ((options & InliningOptions.AllowChangingOrderOfEvaluationForExceptions) != 0)
{
@@ -867,7 +867,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
///
/// Finds the first call instruction within the instructions that were inlined into inst.
///
- internal static CallInstruction FindFirstInlinedCall(ILInstruction inst)
+ internal static CallInstruction? FindFirstInlinedCall(ILInstruction inst)
{
foreach (var child in inst.Children)
{
diff --git a/ICSharpCode.Decompiler/IL/Transforms/InterpolatedStringTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/InterpolatedStringTransform.cs
index 03e1d62a8..640f9a872 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/InterpolatedStringTransform.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/InterpolatedStringTransform.cs
@@ -32,7 +32,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return;
int interpolationStart = pos;
int interpolationEnd;
- ILInstruction insertionPoint;
+ ILInstruction? insertionPoint;
// stloc v(newobj DefaultInterpolatedStringHandler..ctor(ldc.i4 literalLength, ldc.i4 formattedCount))
if (block.Instructions[pos] is StLoc {
Variable: ILVariable { Kind: VariableKind.Local } v,
diff --git a/ICSharpCode.Decompiler/IL/Transforms/LocalFunctionDecompiler.cs b/ICSharpCode.Decompiler/IL/Transforms/LocalFunctionDecompiler.cs
index f74c0cf0b..a68dc8cc4 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/LocalFunctionDecompiler.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/LocalFunctionDecompiler.cs
@@ -308,7 +308,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
- private ILInstruction FindCompatibleArgument(LocalFunctionInfo info, IList arguments, bool ignoreStructure = false)
+ private ILInstruction? FindCompatibleArgument(LocalFunctionInfo info, IList arguments, bool ignoreStructure = false)
{
foreach (var arg in arguments)
{
@@ -321,7 +321,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return null;
}
- private ILVariable ResolveAncestorScopeReference(ILInstruction inst)
+ private ILVariable? ResolveAncestorScopeReference(ILInstruction inst)
{
if (!inst.MatchLdFld(out var target, out var field))
return null;
@@ -338,7 +338,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return null;
}
- private ILFunction GetDeclaringFunction(ILFunction localFunction)
+ private ILFunction? GetDeclaringFunction(ILFunction localFunction)
{
if (localFunction.DeclarationScope == null)
return null;
@@ -446,7 +446,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
- ILFunction ReadLocalFunctionDefinition(ILFunction rootFunction, IMethod targetMethod, int skipCount)
+ ILFunction? ReadLocalFunctionDefinition(ILFunction rootFunction, IMethod targetMethod, int skipCount)
{
var methodDefinition = context.PEFile.Metadata.GetMethodDefinition((MethodDefinitionHandle)targetMethod.MetadataToken);
var genericContext = GenericContextFromTypeArguments(targetMethod, skipCount);
@@ -723,7 +723,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
function.DeclarationScope = FindCommonAncestorInstruction(function.DeclarationScope, closureVar.CaptureScope);
return true;
- ILInstruction GetClosureInitializer(ILVariable variable)
+ ILInstruction? GetClosureInitializer(ILVariable variable)
{
var type = variable.Type.UnwrapByRef().GetDefinition();
if (type == null)
diff --git a/ICSharpCode.Decompiler/IL/Transforms/NullPropagationTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/NullPropagationTransform.cs
index cdf0a7de9..6e988f724 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/NullPropagationTransform.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/NullPropagationTransform.cs
@@ -71,7 +71,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// Check if "condition ? trueInst : falseInst" can be simplified using the null-conditional operator.
/// Returns the replacement instruction, or null if no replacement is possible.
///
- internal ILInstruction Run(ILInstruction condition, ILInstruction trueInst, ILInstruction falseInst)
+ internal ILInstruction? Run(ILInstruction condition, ILInstruction trueInst, ILInstruction falseInst)
{
Debug.Assert(context.Settings.NullPropagation);
Debug.Assert(!condition.MatchLogicNot(out _), "Caller should pass in positive condition");
@@ -107,7 +107,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
///
/// testedVar != null ? nonNullInst : nullInst
///
- ILInstruction TryNullPropagation(ILVariable testedVar, ILInstruction nonNullInst, ILInstruction nullInst,
+ ILInstruction? TryNullPropagation(ILVariable testedVar, ILInstruction nonNullInst, ILInstruction nullInst,
Mode mode)
{
bool removedRewrapOrNullableCtor = false;
diff --git a/ICSharpCode.Decompiler/IL/Transforms/NullableLiftingTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/NullableLiftingTransform.cs
index ed0118526..d721e08c9 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/NullableLiftingTransform.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/NullableLiftingTransform.cs
@@ -176,7 +176,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// Main entry point for lifting; called by both the expression-transform
/// and the block transform.
///
- ILInstruction Lift(ILInstruction ifInst, ILInstruction condition, ILInstruction trueInst, ILInstruction falseInst)
+ ILInstruction? Lift(ILInstruction ifInst, ILInstruction condition, ILInstruction trueInst, ILInstruction falseInst)
{
// ifInst is usually the IfInstruction to which condition belongs;
// but can also be a BinaryNumericInstruction.
@@ -479,7 +479,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
- internal ILInstruction MakeLifted(ComparisonKind newComparisonKind, ILInstruction left, ILInstruction right)
+ internal ILInstruction? MakeLifted(ComparisonKind newComparisonKind, ILInstruction left, ILInstruction right)
{
if (Instruction is Comp comp)
{
diff --git a/ICSharpCode.Decompiler/IL/Transforms/ReduceNestingTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/ReduceNestingTransform.cs
index 5a92f5cb2..d0a88b74c 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/ReduceNestingTransform.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/ReduceNestingTransform.cs
@@ -451,7 +451,7 @@ namespace ICSharpCode.Decompiler.IL
///
/// [else-]if (parent-cond) else { ifInst }
///
- private IfInstruction GetElseIfParent(IfInstruction ifInst)
+ private IfInstruction? GetElseIfParent(IfInstruction ifInst)
{
Debug.Assert(ifInst.Parent is Block);
if (Block.Unwrap(ifInst.Parent) == ifInst && // only instruction in block
diff --git a/ICSharpCode.Decompiler/IL/Transforms/SplitVariables.cs b/ICSharpCode.Decompiler/IL/Transforms/SplitVariables.cs
index 4f3bbd698..ce24e3a31 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/SplitVariables.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/SplitVariables.cs
@@ -175,7 +175,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// Given 'ldloc ref_local' and 'ldloca target; stloc ref_local', returns the ldloca.
/// This function must return a non-null LdLoca for every use of a SupportedRefLocal.
///
- static LdLoca GetAddressLoadForRefLocalUse(LdLoc ldloc)
+ static LdLoca? GetAddressLoadForRefLocalUse(LdLoc ldloc)
{
if (!ldloc.Variable.IsSingleDefinition)
return null; // only single-definition variables can be supported ref locals
diff --git a/ICSharpCode.Decompiler/IL/Transforms/TransformDisplayClassUsage.cs b/ICSharpCode.Decompiler/IL/Transforms/TransformDisplayClassUsage.cs
index 34b1294a1..74bdd9c52 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/TransformDisplayClassUsage.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/TransformDisplayClassUsage.cs
@@ -246,7 +246,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
- private DisplayClass AnalyzeVariable(ILVariable v)
+ private DisplayClass? AnalyzeVariable(ILVariable v)
{
switch (v.Kind)
{
@@ -265,7 +265,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
- DisplayClass DetectDisplayClass(ILVariable v)
+ DisplayClass? DetectDisplayClass(ILVariable v)
{
ITypeDefinition? definition;
if (v.Kind != VariableKind.StackSlot)
@@ -385,7 +385,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
- DisplayClass DetectDisplayClassInitializer(ILVariable v)
+ DisplayClass? DetectDisplayClassInitializer(ILVariable v)
{
if (v.StoreInstructions.Count != 1 || !(v.StoreInstructions[0] is StLoc store && store.Parent is Block initializerBlock && initializerBlock.Kind == BlockKind.ObjectInitializer))
return null;
@@ -520,7 +520,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// If a value does not match either LdLoc or a LdObj LdLdFlda* LdLoc chain, null is returned.
/// The if any of the variables/fields in the chain cannot be propagated, null is returned.
///
- ILVariable ResolveVariableToPropagate(ILInstruction value, IType? expectedType = null)
+ ILVariable? ResolveVariableToPropagate(ILInstruction value, IType? expectedType = null)
{
ILVariable v;
switch (value)
@@ -634,7 +634,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// mcs likes to optimize closures in yield state machines away by moving the captured variables' fields into the state machine type,
/// We construct a that spans the whole method body.
///
- DisplayClass HandleMonoStateMachine(ILFunction function, ILVariable thisVariable)
+ DisplayClass? HandleMonoStateMachine(ILFunction function, ILVariable thisVariable)
{
if (!(function.StateMachineCompiledWithMono && thisVariable.IsThis()))
return null;
diff --git a/ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs b/ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs
index e05439151..3261dbb8c 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs
@@ -459,7 +459,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
if (!MatchArgumentList(invocation.Arguments[1], out var arguments))
arguments = new[] { invocation.Arguments[1] };
- ILInstruction Convert()
+ ILInstruction? Convert()
{
Func[] toBeConverted = new Func[arguments.Count];
for (int i = 0; i < arguments.Count; i++)
@@ -683,7 +683,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return call.Arguments[0];
}
- Func[] ConvertCallArguments(IList arguments, IMethod method)
+ Func[]? ConvertCallArguments(IList arguments, IMethod method)
{
var converted = new Func[arguments.Count];
Debug.Assert(arguments.Count == method.Parameters.Count);
@@ -1359,7 +1359,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (null, SpecialType.UnknownType);
}
- ILInstruction ConvertValue(ILInstruction value, ILInstruction context)
+ ILInstruction? ConvertValue(ILInstruction value, ILInstruction context)
{
switch (value)
{
diff --git a/ICSharpCode.Decompiler/IL/Transforms/UserDefinedLogicTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/UserDefinedLogicTransform.cs
index 86ed3d301..559e107ff 100644
--- a/ICSharpCode.Decompiler/IL/Transforms/UserDefinedLogicTransform.cs
+++ b/ICSharpCode.Decompiler/IL/Transforms/UserDefinedLogicTransform.cs
@@ -147,7 +147,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// if (call op_True(ldloc lhsVar)) ldloc lhsVar else call op_BitwiseOr(ldloc lhsVar, rhsInst)
/// -> user.logic op_BitwiseOr(ldloc lhsVar, rhsInst)
///
- public static ILInstruction Transform(ILInstruction condition, ILInstruction trueInst, ILInstruction falseInst)
+ public static ILInstruction? Transform(ILInstruction condition, ILInstruction trueInst, ILInstruction falseInst)
{
if (!MatchCondition(condition, out var lhsVar, out var conditionMethodName))
return null;
@@ -164,7 +164,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return result;
}
- public static ILInstruction TransformDynamic(ILInstruction condition, ILInstruction trueInst, ILInstruction falseInst)
+ public static ILInstruction? TransformDynamic(ILInstruction condition, ILInstruction trueInst, ILInstruction falseInst)
{
// Check condition:
System.Linq.Expressions.ExpressionType unaryOp;
diff --git a/ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs b/ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs
index 9007bde8c..d35b10b82 100644
--- a/ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs
+++ b/ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs
@@ -211,7 +211,7 @@ namespace ICSharpCode.Decompiler.Metadata
}
}
- public string TryResolveDotNetCoreShared(IAssemblyReference name, out string? runtimePack)
+ public string? TryResolveDotNetCoreShared(IAssemblyReference name, out string? runtimePack)
{
if (dotnetBasePath == null)
{
@@ -286,7 +286,7 @@ namespace ICSharpCode.Decompiler.Metadata
}
}
- public static string FindDotNetExeDirectory()
+ public static string? FindDotNetExeDirectory()
{
string dotnetExeName = (Environment.OSVersion.Platform == PlatformID.Unix) ? "dotnet" : "dotnet.exe";
foreach (var item in Environment.GetEnvironmentVariable("PATH").Split(Path.PathSeparator))
@@ -312,7 +312,7 @@ namespace ICSharpCode.Decompiler.Metadata
return null;
}
- static unsafe string GetRealPath(string path, Encoding encoding)
+ static unsafe string? GetRealPath(string path, Encoding encoding)
{
var bytes = encoding.GetBytes(path);
fixed (byte* input = bytes)
diff --git a/ICSharpCode.Decompiler/Metadata/LightJson/JsonValue.cs b/ICSharpCode.Decompiler/Metadata/LightJson/JsonValue.cs
index 17f203f34..ba52d003e 100644
--- a/ICSharpCode.Decompiler/Metadata/LightJson/JsonValue.cs
+++ b/ICSharpCode.Decompiler/Metadata/LightJson/JsonValue.cs
@@ -329,7 +329,7 @@ namespace LightJson
/// Gets this value as a String type.
///
/// This value as a String type.
- public string AsString {
+ public string? AsString {
get {
switch (this.Type)
{
@@ -354,7 +354,7 @@ namespace LightJson
/// Gets this value as an JsonObject.
///
/// This value as an JsonObject.
- public JsonObject AsJsonObject {
+ public JsonObject? AsJsonObject {
get {
return this.IsJsonObject
? (JsonObject)this.reference
@@ -366,7 +366,7 @@ namespace LightJson
/// Gets this value as an JsonArray.
///
/// This value as an JsonArray.
- public JsonArray AsJsonArray {
+ public JsonArray? AsJsonArray {
get {
return this.IsJsonArray
? (JsonArray)this.reference
@@ -397,7 +397,7 @@ namespace LightJson
/// Gets this (inner) value as a System.object.
///
/// This (inner) value as a System.object.
- public object AsObject {
+ public object? AsObject {
get {
switch (this.Type)
{
@@ -808,7 +808,7 @@ namespace LightJson
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
- public JsonObject ObjectView {
+ public JsonObject? ObjectView {
get {
if (this.jsonValue.IsJsonObject)
{
@@ -822,7 +822,7 @@ namespace LightJson
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
- public JsonArray ArrayView {
+ public JsonArray? ArrayView {
get {
if (this.jsonValue.IsJsonArray)
{
diff --git a/ICSharpCode.Decompiler/NRExtensions.cs b/ICSharpCode.Decompiler/NRExtensions.cs
index 58850d2b8..638c3d63f 100644
--- a/ICSharpCode.Decompiler/NRExtensions.cs
+++ b/ICSharpCode.Decompiler/NRExtensions.cs
@@ -92,7 +92,7 @@ namespace ICSharpCode.Decompiler
}
}
- internal static string GetDocumentation(this IEntity entity)
+ internal static string? GetDocumentation(this IEntity entity)
{
var docProvider = XmlDocLoader.LoadDocumentation(entity.ParentModule.MetadataFile);
if (docProvider == null)
diff --git a/ICSharpCode.Decompiler/Output/TextTokenWriter.cs b/ICSharpCode.Decompiler/Output/TextTokenWriter.cs
index d225feeaa..eb0a446af 100644
--- a/ICSharpCode.Decompiler/Output/TextTokenWriter.cs
+++ b/ICSharpCode.Decompiler/Output/TextTokenWriter.cs
@@ -108,7 +108,7 @@ namespace ICSharpCode.Decompiler
output.Write(name);
}
- ISymbol GetCurrentMemberReference()
+ ISymbol? GetCurrentMemberReference()
{
AstNode node = nodeStack.Peek();
var symbol = node.GetSymbol();
@@ -130,7 +130,7 @@ namespace ICSharpCode.Decompiler
return FilterMember(symbol);
}
- ISymbol FilterMember(ISymbol symbol)
+ ISymbol? FilterMember(ISymbol symbol)
{
if (symbol == null)
return null;
@@ -141,7 +141,7 @@ namespace ICSharpCode.Decompiler
return symbol;
}
- object GetCurrentLocalReference()
+ object? GetCurrentLocalReference()
{
AstNode node = nodeStack.Peek();
ILVariable variable = node.Annotation()?.Variable;
@@ -169,7 +169,7 @@ namespace ICSharpCode.Decompiler
return null;
}
- object GetCurrentLocalDefinition(Identifier id)
+ object? GetCurrentLocalDefinition(Identifier id)
{
AstNode node = nodeStack.Peek();
if (node is Identifier && node.Parent != null)
@@ -213,7 +213,7 @@ namespace ICSharpCode.Decompiler
return null;
}
- ISymbol GetCurrentDefinition()
+ ISymbol? GetCurrentDefinition()
{
if (nodeStack == null || nodeStack.Count == 0)
return null;
diff --git a/ICSharpCode.Decompiler/Semantics/LocalResolveResult.cs b/ICSharpCode.Decompiler/Semantics/LocalResolveResult.cs
index 4c7922b1f..4eb744def 100644
--- a/ICSharpCode.Decompiler/Semantics/LocalResolveResult.cs
+++ b/ICSharpCode.Decompiler/Semantics/LocalResolveResult.cs
@@ -62,7 +62,7 @@ namespace ICSharpCode.Decompiler.Semantics
get { return variable.IsConst; }
}
- public override object ConstantValue {
+ public override object? ConstantValue {
get { return IsParameter ? null : variable.GetConstantValue(); }
}
diff --git a/ICSharpCode.Decompiler/TypeSystem/FunctionPointerType.cs b/ICSharpCode.Decompiler/TypeSystem/FunctionPointerType.cs
index babf67d83..b5c27eaa4 100644
--- a/ICSharpCode.Decompiler/TypeSystem/FunctionPointerType.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/FunctionPointerType.cs
@@ -123,7 +123,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public override TypeKind Kind => ((module.TypeSystemOptions & TypeSystemOptions.FunctionPointers) != 0) ? TypeKind.FunctionPointer : TypeKind.Struct;
- public override ITypeDefinition GetDefinition()
+ public override ITypeDefinition? GetDefinition()
{
if ((module.TypeSystemOptions & TypeSystemOptions.FunctionPointers) != 0)
{
diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/AttributeListBuilder.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/AttributeListBuilder.cs
index 66d77a735..66eedf359 100644
--- a/ICSharpCode.Decompiler/TypeSystem/Implementation/AttributeListBuilder.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/AttributeListBuilder.cs
@@ -283,7 +283,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return false;
}
- internal IAttribute GetAttribute(MetadataReader metadata, CustomAttributeHandleCollection customAttributes, KnownAttribute attribute, SymbolKind symbolKind)
+ internal IAttribute? GetAttribute(MetadataReader metadata, CustomAttributeHandleCollection customAttributes, KnownAttribute attribute, SymbolKind symbolKind)
{
Debug.Assert(attribute.IsCustomAttribute());
foreach (var h in customAttributes)
diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/CustomAttribute.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/CustomAttribute.cs
index 9ef688330..f760cc27c 100644
--- a/ICSharpCode.Decompiler/TypeSystem/Implementation/CustomAttribute.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/CustomAttribute.cs
@@ -109,7 +109,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
}
}
- internal static IMember MemberForNamedArgument(IType attributeType, CustomAttributeNamedArgument namedArgument)
+ internal static IMember? MemberForNamedArgument(IType attributeType, CustomAttributeNamedArgument namedArgument)
{
switch (namedArgument.Kind)
{
diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/DecimalConstantHelper.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/DecimalConstantHelper.cs
index effeb11a1..777d440a2 100644
--- a/ICSharpCode.Decompiler/TypeSystem/Implementation/DecimalConstantHelper.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/DecimalConstantHelper.cs
@@ -32,7 +32,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return attributeHandles.HasKnownAttribute(module.metadata, KnownAttribute.DecimalConstant);
}
- public static object GetDecimalConstantValue(MetadataModule module, CustomAttributeHandleCollection attributeHandles)
+ public static object? GetDecimalConstantValue(MetadataModule module, CustomAttributeHandleCollection attributeHandles)
{
var metadata = module.metadata;
foreach (var attributeHandle in attributeHandles)
diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultAssemblyReference.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultAssemblyReference.cs
index aa89607bf..726390342 100644
--- a/ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultAssemblyReference.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultAssemblyReference.cs
@@ -39,7 +39,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
shortName = assemblyName;
}
- public IModule Resolve(ITypeResolveContext context)
+ public IModule? Resolve(ITypeResolveContext context)
{
IModule current = context.CurrentModule;
if (current != null && string.Equals(shortName, current.AssemblyName, StringComparison.OrdinalIgnoreCase))
diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/DummyTypeParameter.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/DummyTypeParameter.cs
index 16f96c6e5..06b5519a6 100644
--- a/ICSharpCode.Decompiler/TypeSystem/Implementation/DummyTypeParameter.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/DummyTypeParameter.cs
@@ -163,7 +163,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
get { return VarianceModifier.Invariant; }
}
- IEntity ITypeParameter.Owner {
+ IEntity? ITypeParameter.Owner {
get { return null; }
}
diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/FakeMember.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/FakeMember.cs
index 13426414a..3bb07edfe 100644
--- a/ICSharpCode.Decompiler/TypeSystem/Implementation/FakeMember.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/FakeMember.cs
@@ -63,7 +63,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
IEnumerable IEntity.GetAttributes() => EmptyList.Instance;
bool IEntity.HasAttribute(KnownAttribute attribute) => false;
- IAttribute IEntity.GetAttribute(KnownAttribute attribute) => null;
+ IAttribute? IEntity.GetAttribute(KnownAttribute attribute) => null;
public Accessibility Accessibility { get; set; } = Accessibility.Public;
@@ -114,7 +114,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
bool IField.IsVolatile => false;
bool IVariable.IsConst => false;
- object IVariable.GetConstantValue(bool throwOnInvalidMetadata) => null;
+ object? IVariable.GetConstantValue(bool throwOnInvalidMetadata) => null;
IType IVariable.Type => ReturnType;
public override SymbolKind SymbolKind => SymbolKind.Field;
diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/GetClassTypeReference.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/GetClassTypeReference.cs
index ac27c97ec..56d132108 100644
--- a/ICSharpCode.Decompiler/TypeSystem/Implementation/GetClassTypeReference.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/GetClassTypeReference.cs
@@ -84,7 +84,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
///
public FullTypeName FullTypeName { get { return fullTypeName; } }
- internal static IType ResolveInAllAssemblies(ICompilation compilation, in FullTypeName fullTypeName)
+ internal static IType? ResolveInAllAssemblies(ICompilation compilation, in FullTypeName fullTypeName)
{
foreach (var asm in compilation.Modules)
{
diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/MergedNamespace.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/MergedNamespace.cs
index 5d2f71bd1..f05b248dc 100644
--- a/ICSharpCode.Decompiler/TypeSystem/Implementation/MergedNamespace.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/MergedNamespace.cs
@@ -108,7 +108,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
get { return GetChildNamespaces().Values; }
}
- public INamespace GetChildNamespace(string name)
+ public INamespace? GetChildNamespace(string name)
{
INamespace ns;
if (GetChildNamespaces().TryGetValue(name, out ns))
diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataNamespace.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataNamespace.cs
index 6a35f8568..729d1e5ba 100644
--- a/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataNamespace.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataNamespace.cs
@@ -86,7 +86,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
ICompilation ICompilationProvider.Compilation => module.Compilation;
- INamespace INamespace.GetChildNamespace(string name)
+ INamespace? INamespace.GetChildNamespace(string name)
{
foreach (var ns in ChildNamespaces)
{
diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataParameter.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataParameter.cs
index 14bee08dc..0222e19b9 100644
--- a/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataParameter.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataParameter.cs
@@ -156,7 +156,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
bool IVariable.IsConst => false;
- public object GetConstantValue(bool throwOnInvalidMetadata)
+ public object? GetConstantValue(bool throwOnInvalidMetadata)
{
try
{
diff --git a/ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializedMember.cs b/ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializedMember.cs
index 0f8f55734..63b267aa4 100644
--- a/ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializedMember.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializedMember.cs
@@ -59,7 +59,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
this.substitution = TypeParameterSubstitution.Compose(newSubstitution, this.substitution);
}
- internal IMethod WrapAccessor(ref IMethod cachingField, IMethod accessorDefinition)
+ internal IMethod? WrapAccessor(ref IMethod cachingField, IMethod accessorDefinition)
{
if (accessorDefinition == null)
return null;
diff --git a/ICSharpCode.Decompiler/TypeSystem/InheritanceHelper.cs b/ICSharpCode.Decompiler/TypeSystem/InheritanceHelper.cs
index 154f06375..b4b82f604 100644
--- a/ICSharpCode.Decompiler/TypeSystem/InheritanceHelper.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/InheritanceHelper.cs
@@ -109,7 +109,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
///
/// Finds the member declared in 'derivedType' that has the same signature (could override) 'baseMember'.
///
- public static IMember GetDerivedMember(IMember baseMember, ITypeDefinition derivedType)
+ public static IMember? GetDerivedMember(IMember baseMember, ITypeDefinition derivedType)
{
if (baseMember == null)
throw new ArgumentNullException(nameof(baseMember));
@@ -185,7 +185,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
}
}
- internal static IAttribute GetAttribute(ITypeDefinition typeDef, KnownAttribute attributeType)
+ internal static IAttribute? GetAttribute(ITypeDefinition typeDef, KnownAttribute attributeType)
{
foreach (var baseType in typeDef.GetNonInterfaceBaseTypes().Reverse())
{
@@ -217,7 +217,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
} while (member.IsOverride && (member = InheritanceHelper.GetBaseMember(member)) != null);
}
- internal static IAttribute GetAttribute(IMember member, KnownAttribute attributeType)
+ internal static IAttribute? GetAttribute(IMember member, KnownAttribute attributeType)
{
HashSet visitedMembers = new HashSet();
do
diff --git a/ICSharpCode.Decompiler/TypeSystem/MetadataModule.cs b/ICSharpCode.Decompiler/TypeSystem/MetadataModule.cs
index a7c2881fa..f8aac8452 100644
--- a/ICSharpCode.Decompiler/TypeSystem/MetadataModule.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/MetadataModule.cs
@@ -192,7 +192,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return LazyInit.GetOrSet(ref this.internalsVisibleTo, result);
}
- static string GetShortName(string fullAssemblyName)
+ static string? GetShortName(string fullAssemblyName)
{
if (fullAssemblyName == null)
return null;
@@ -217,7 +217,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
}
}
- public ITypeDefinition GetDefinition(TypeDefinitionHandle handle)
+ public ITypeDefinition? GetDefinition(TypeDefinitionHandle handle)
{
if (handle.IsNil)
return null;
@@ -233,7 +233,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return LazyInit.GetOrSet(ref typeDefs[row], typeDef);
}
- public IField GetDefinition(FieldDefinitionHandle handle)
+ public IField? GetDefinition(FieldDefinitionHandle handle)
{
if (handle.IsNil)
return null;
@@ -249,7 +249,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return LazyInit.GetOrSet(ref fieldDefs[row], field);
}
- public IMethod GetDefinition(MethodDefinitionHandle handle)
+ public IMethod? GetDefinition(MethodDefinitionHandle handle)
{
if (handle.IsNil)
return null;
@@ -266,7 +266,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return LazyInit.GetOrSet(ref methodDefs[row], method);
}
- public IProperty GetDefinition(PropertyDefinitionHandle handle)
+ public IProperty? GetDefinition(PropertyDefinitionHandle handle)
{
if (handle.IsNil)
return null;
@@ -283,7 +283,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return LazyInit.GetOrSet(ref propertyDefs[row], property);
}
- public IEvent GetDefinition(EventDefinitionHandle handle)
+ public IEvent? GetDefinition(EventDefinitionHandle handle)
{
if (handle.IsNil)
return null;
@@ -308,7 +308,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
#region Resolve Module
- public IModule ResolveModule(AssemblyReferenceHandle handle)
+ public IModule? ResolveModule(AssemblyReferenceHandle handle)
{
if (handle.IsNil)
return null;
@@ -332,7 +332,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return Compilation.FindModuleByReference(asmRef);
}
- public IModule ResolveModule(ModuleReferenceHandle handle)
+ public IModule? ResolveModule(ModuleReferenceHandle handle)
{
if (handle.IsNil)
return null;
@@ -348,7 +348,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return null;
}
- public IModule GetDeclaringModule(TypeReferenceHandle handle)
+ public IModule? GetDeclaringModule(TypeReferenceHandle handle)
{
if (handle.IsNil)
return null;
@@ -747,7 +747,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// * May return specialized members, where generics are involved.
/// * Other types of handles that don't correspond to TS entities, will return null.
///
- public IEntity ResolveEntity(EntityHandle entityHandle, GenericContext context = default)
+ public IEntity? ResolveEntity(EntityHandle entityHandle, GenericContext context = default)
{
switch (entityHandle.Kind)
{
@@ -904,7 +904,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
}
return new UnknownType(typeName);
- IModule ResolveModule(ExportedType type)
+ IModule? ResolveModule(ExportedType type)
{
switch (type.Implementation.Kind)
{
diff --git a/ICSharpCode.Decompiler/TypeSystem/ReflectionHelper.cs b/ICSharpCode.Decompiler/TypeSystem/ReflectionHelper.cs
index b7309ba73..9608b6c59 100644
--- a/ICSharpCode.Decompiler/TypeSystem/ReflectionHelper.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/ReflectionHelper.cs
@@ -442,7 +442,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return new GetClassTypeReference(assemblyReference, typeName.Substring(0, pos), typeName.Substring(pos + 1), tpc);
}
- static string SkipAheadAndReadAssemblyName(string reflectionTypeName, int pos)
+ static string? SkipAheadAndReadAssemblyName(string reflectionTypeName, int pos)
{
int nestingLevel = 0;
while (pos < reflectionTypeName.Length)
diff --git a/ICSharpCode.Decompiler/TypeSystem/TupleType.cs b/ICSharpCode.Decompiler/TypeSystem/TupleType.cs
index 4eab3d430..59f1d4b4b 100644
--- a/ICSharpCode.Decompiler/TypeSystem/TupleType.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/TupleType.cs
@@ -144,7 +144,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// Construct a tuple type (without element names) from the given underlying type.
/// Returns null if the input is not a valid underlying type.
///
- public static TupleType FromUnderlyingType(ICompilation compilation, IType type)
+ public static TupleType? FromUnderlyingType(ICompilation compilation, IType type)
{
var elementTypes = GetTupleElementTypes(type);
if (elementTypes.Length > 0)
diff --git a/ICSharpCode.Decompiler/TypeSystem/TypeProvider.cs b/ICSharpCode.Decompiler/TypeSystem/TypeProvider.cs
index 39c2bcad3..d73b54b29 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 ca75ab3a7..c52d62c14 100644
--- a/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs
+++ b/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs
@@ -354,7 +354,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
///
/// Returns null if the type is not a delegate type; or if the invoke method could not be found.
///
- public static IMethod GetDelegateInvokeMethod(this IType type)
+ public static IMethod? GetDelegateInvokeMethod(this IType type)
{
if (type == null)
throw new ArgumentNullException(nameof(type));
@@ -461,7 +461,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// Gets the type definition for the specified unresolved type.
/// Returns null if the unresolved type does not belong to this assembly.
///
- public static ITypeDefinition GetTypeDefinition(this IModule module, FullTypeName fullTypeName)
+ public static ITypeDefinition? GetTypeDefinition(this IModule module, FullTypeName fullTypeName)
{
if (module == null)
throw new ArgumentNullException("assembly");
@@ -481,7 +481,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return typeDef;
}
- static ITypeDefinition FindNestedType(ITypeDefinition typeDef, string name, int typeParameterCount)
+ static ITypeDefinition? FindNestedType(ITypeDefinition typeDef, string name, int typeParameterCount)
{
foreach (var nestedType in typeDef.NestedTypes)
{
@@ -626,7 +626,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
#endregion
#region ResolveResult
- public static ISymbol GetSymbol(this ResolveResult rr)
+ public static ISymbol? GetSymbol(this ResolveResult rr)
{
if (rr is LocalResolveResult)
{
@@ -713,7 +713,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return false;
}
- public static IModule FindModuleByReference(this ICompilation compilation, IAssemblyReference assemblyName)
+ public static IModule? FindModuleByReference(this ICompilation compilation, IAssemblyReference assemblyName)
{
foreach (var module in compilation.Modules)
{
@@ -749,7 +749,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
}
}
- public static INamespace GetNamespaceByFullName(this ICompilation compilation, string name)
+ public static INamespace? GetNamespaceByFullName(this ICompilation compilation, string name)
{
if (string.IsNullOrEmpty(name))
return compilation.RootNamespace;
diff --git a/ICSharpCode.Decompiler/Util/CSharpPrimitiveCast.cs b/ICSharpCode.Decompiler/Util/CSharpPrimitiveCast.cs
index b57516b45..ee940d9d8 100644
--- a/ICSharpCode.Decompiler/Util/CSharpPrimitiveCast.cs
+++ b/ICSharpCode.Decompiler/Util/CSharpPrimitiveCast.cs
@@ -34,7 +34,7 @@ namespace ICSharpCode.Decompiler.Util
///
/// Overflow checking is enabled and an overflow occurred.
/// The cast is invalid, e.g. casting a boolean to an integer.
- public static object Cast(TypeCode targetType, object input, bool checkForOverflow)
+ public static object? Cast(TypeCode targetType, object input, bool checkForOverflow)
{
if (input == null)
return null;
diff --git a/ILSpy/Analyzers/TreeNodes/AnalyzedModuleTreeNode.cs b/ILSpy/Analyzers/TreeNodes/AnalyzedModuleTreeNode.cs
index e7f83f638..b54f31f2e 100644
--- a/ILSpy/Analyzers/TreeNodes/AnalyzedModuleTreeNode.cs
+++ b/ILSpy/Analyzers/TreeNodes/AnalyzedModuleTreeNode.cs
@@ -64,6 +64,6 @@ namespace ICSharpCode.ILSpy.Analyzers.TreeNodes
MainWindow.Instance.JumpToReference(analyzedModule.MetadataFile);
}
- public override IEntity Member => null;
+ public override IEntity? Member => null;
}
}
diff --git a/ILSpy/App.xaml.cs b/ILSpy/App.xaml.cs
index c136891a1..92c46a1f5 100644
--- a/ILSpy/App.xaml.cs
+++ b/ILSpy/App.xaml.cs
@@ -122,7 +122,7 @@ namespace ICSharpCode.ILSpy
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
}
- static Assembly ResolvePluginDependencies(AssemblyLoadContext context, AssemblyName assemblyName)
+ static Assembly? ResolvePluginDependencies(AssemblyLoadContext context, AssemblyName assemblyName)
{
var rootPath = Path.GetDirectoryName(typeof(App).Assembly.Location);
var assemblyFileName = Path.Combine(rootPath, assemblyName.Name + ".dll");
diff --git a/ILSpy/AppEnv/CommandLineTools.cs b/ILSpy/AppEnv/CommandLineTools.cs
index 7379db12e..5f7c14dec 100644
--- a/ILSpy/AppEnv/CommandLineTools.cs
+++ b/ILSpy/AppEnv/CommandLineTools.cs
@@ -56,7 +56,7 @@ namespace ICSharpCode.ILSpy.AppEnv
/// - (2n) + 1 backslashes followed by a quotation mark again produce n backslashes followed by a quotation mark.
/// - n backslashes not followed by a quotation mark simply produce n backslashes.
///
- public static string ArgumentArrayToCommandLine(params string[] arguments)
+ public static string? ArgumentArrayToCommandLine(params string[] arguments)
{
if (arguments == null)
return null;
diff --git a/ILSpy/Commands/CopyFullyQualifiedNameContextMenuEntry.cs b/ILSpy/Commands/CopyFullyQualifiedNameContextMenuEntry.cs
index 47490e37b..446f434ed 100644
--- a/ILSpy/Commands/CopyFullyQualifiedNameContextMenuEntry.cs
+++ b/ILSpy/Commands/CopyFullyQualifiedNameContextMenuEntry.cs
@@ -42,7 +42,7 @@ namespace ICSharpCode.ILSpy
Clipboard.SetText(member.ReflectionName);
}
- private IMemberTreeNode GetMemberNodeFromContext(TextViewContext context)
+ private IMemberTreeNode? GetMemberNodeFromContext(TextViewContext context)
{
return context.SelectedTreeNodes?.Length == 1 ? context.SelectedTreeNodes[0] as IMemberTreeNode : null;
}
diff --git a/ILSpy/Commands/SaveCodeContextMenuEntry.cs b/ILSpy/Commands/SaveCodeContextMenuEntry.cs
index d7e38ada3..ada78fcba 100644
--- a/ILSpy/Commands/SaveCodeContextMenuEntry.cs
+++ b/ILSpy/Commands/SaveCodeContextMenuEntry.cs
@@ -101,7 +101,7 @@ namespace ICSharpCode.ILSpy.TextView
/// will be used.
///
/// The full path of the selected target file, or null if the user canceled.
- static string SelectSolutionFile()
+ static string? SelectSolutionFile()
{
SaveFileDialog dlg = new SaveFileDialog();
dlg.FileName = "Solution.sln";
diff --git a/ILSpy/Commands/ScopeSearchToNamespace.cs b/ILSpy/Commands/ScopeSearchToNamespace.cs
index 645f9d425..83dceb002 100644
--- a/ILSpy/Commands/ScopeSearchToNamespace.cs
+++ b/ILSpy/Commands/ScopeSearchToNamespace.cs
@@ -75,7 +75,7 @@ namespace ICSharpCode.ILSpy
return GetNamespace(context) != null;
}
- string GetNamespace(TextViewContext context)
+ string? GetNamespace(TextViewContext context)
{
if (context.Reference?.Reference is IEntity entity)
return entity.Namespace;
diff --git a/ILSpy/Controls/ExtensionMethods.cs b/ILSpy/Controls/ExtensionMethods.cs
index 15e40eb7b..a0931e3fb 100644
--- a/ILSpy/Controls/ExtensionMethods.cs
+++ b/ILSpy/Controls/ExtensionMethods.cs
@@ -60,7 +60,7 @@ namespace ICSharpCode.ILSpy.Controls
this.targetProperty = property;
}
- public object GetService(Type serviceType)
+ public object? GetService(Type serviceType)
{
if (serviceType == typeof(IProvideValueTarget))
return this;
diff --git a/ILSpy/Controls/TreeView/LinesRenderer.cs b/ILSpy/Controls/TreeView/LinesRenderer.cs
index ca62d3b31..4508cc071 100644
--- a/ILSpy/Controls/TreeView/LinesRenderer.cs
+++ b/ILSpy/Controls/TreeView/LinesRenderer.cs
@@ -32,7 +32,7 @@ namespace ICSharpCode.ILSpy.Controls.TreeView
static Pen pen;
- SharpTreeNodeView NodeView {
+ SharpTreeNodeView? NodeView {
get { return TemplatedParent as SharpTreeNodeView; }
}
diff --git a/ILSpy/Controls/TreeView/SharpTreeNodeView.cs b/ILSpy/Controls/TreeView/SharpTreeNodeView.cs
index a7cca8838..002cc9ba1 100644
--- a/ILSpy/Controls/TreeView/SharpTreeNodeView.cs
+++ b/ILSpy/Controls/TreeView/SharpTreeNodeView.cs
@@ -43,7 +43,7 @@ namespace ICSharpCode.ILSpy.Controls.TreeView
set { SetValue(TextBackgroundProperty, value); }
}
- public SharpTreeNode Node {
+ public SharpTreeNode? Node {
get { return DataContext as SharpTreeNode; }
}
diff --git a/ILSpy/Controls/TreeView/SharpTreeView.cs b/ILSpy/Controls/TreeView/SharpTreeView.cs
index faa7cb2f0..13b841740 100644
--- a/ILSpy/Controls/TreeView/SharpTreeView.cs
+++ b/ILSpy/Controls/TreeView/SharpTreeView.cs
@@ -420,7 +420,7 @@ namespace ICSharpCode.ILSpy.Controls.TreeView
base.ScrollIntoView(node);
}
- object OnFocusItem(object item)
+ object? OnFocusItem(object item)
{
FrameworkElement element = this.ItemContainerGenerator.ContainerFromItem(item) as FrameworkElement;
if (element != null)
@@ -531,7 +531,7 @@ namespace ICSharpCode.ILSpy.Controls.TreeView
public int Index;
}
- DropTarget GetDropTarget(SharpTreeViewItem item, DragEventArgs e)
+ DropTarget? GetDropTarget(SharpTreeViewItem item, DragEventArgs e)
{
var dropTargets = BuildDropTargets(item, e);
var y = e.GetPosition(item).Y;
diff --git a/ILSpy/Controls/TreeView/SharpTreeViewItem.cs b/ILSpy/Controls/TreeView/SharpTreeViewItem.cs
index 5ec32d855..727f8822d 100644
--- a/ILSpy/Controls/TreeView/SharpTreeViewItem.cs
+++ b/ILSpy/Controls/TreeView/SharpTreeViewItem.cs
@@ -34,7 +34,7 @@ namespace ICSharpCode.ILSpy.Controls.TreeView
new FrameworkPropertyMetadata(typeof(SharpTreeViewItem)));
}
- public SharpTreeNode Node {
+ public SharpTreeNode? Node {
get { return DataContext as SharpTreeNode; }
}
diff --git a/ILSpy/Docking/DockLayoutSettings.cs b/ILSpy/Docking/DockLayoutSettings.cs
index fc776db79..dc3926500 100644
--- a/ILSpy/Docking/DockLayoutSettings.cs
+++ b/ILSpy/Docking/DockLayoutSettings.cs
@@ -77,7 +77,7 @@ namespace ICSharpCode.ILSpy.Docking
}
}
- public XElement SaveAsXml()
+ public XElement? SaveAsXml()
{
try
{
diff --git a/ILSpy/Languages/CSharpBracketSearcher.cs b/ILSpy/Languages/CSharpBracketSearcher.cs
index 28a7a4fd2..9967d4f6b 100644
--- a/ILSpy/Languages/CSharpBracketSearcher.cs
+++ b/ILSpy/Languages/CSharpBracketSearcher.cs
@@ -33,7 +33,7 @@ namespace ICSharpCode.ILSpy
string openingBrackets = "([{";
string closingBrackets = ")]}";
- public BracketSearchResult SearchBracket(IDocument document, int offset)
+ public BracketSearchResult? SearchBracket(IDocument document, int offset)
{
if (offset > 0)
{
diff --git a/ILSpy/Languages/CSharpHighlightingTokenWriter.cs b/ILSpy/Languages/CSharpHighlightingTokenWriter.cs
index fe229607a..c6edcfd4b 100644
--- a/ILSpy/Languages/CSharpHighlightingTokenWriter.cs
+++ b/ILSpy/Languages/CSharpHighlightingTokenWriter.cs
@@ -474,7 +474,7 @@ namespace ICSharpCode.ILSpy
}
}
- ISymbol GetCurrentDefinition()
+ ISymbol? GetCurrentDefinition()
{
if (nodeStack == null || nodeStack.Count == 0)
return null;
@@ -488,7 +488,7 @@ namespace ICSharpCode.ILSpy
return null;
}
- ISymbol GetCurrentMemberReference()
+ ISymbol? GetCurrentMemberReference()
{
if (nodeStack == null || nodeStack.Count == 0)
return null;
diff --git a/ILSpy/Languages/CSharpLanguage.cs b/ILSpy/Languages/CSharpLanguage.cs
index df801511c..c62222a0b 100644
--- a/ILSpy/Languages/CSharpLanguage.cs
+++ b/ILSpy/Languages/CSharpLanguage.cs
@@ -418,7 +418,7 @@ namespace ICSharpCode.ILSpy
}
}
- public override ProjectId DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
+ public override ProjectId? DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
{
var module = assembly.GetMetadataFileOrNull();
if (module == null)
@@ -702,7 +702,7 @@ namespace ICSharpCode.ILSpy
}
}
- public override string GetEntityName(MetadataFile module, EntityHandle handle, bool fullName, bool omitGenerics)
+ public override string? GetEntityName(MetadataFile module, EntityHandle handle, bool fullName, bool omitGenerics)
{
MetadataReader metadata = module.Metadata;
switch (handle.Kind)
diff --git a/ILSpy/Languages/ILLanguage.cs b/ILSpy/Languages/ILLanguage.cs
index 22d060b37..29681b982 100644
--- a/ILSpy/Languages/ILLanguage.cs
+++ b/ILSpy/Languages/ILLanguage.cs
@@ -163,7 +163,7 @@ namespace ICSharpCode.ILSpy
dis.DisassembleNamespace(nameSpace, module, types.Select(t => (TypeDefinitionHandle)t.MetadataToken));
}
- public override ProjectId DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
+ public override ProjectId? DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
{
output.WriteLine("// " + assembly.FileName);
output.WriteLine();
@@ -195,7 +195,7 @@ namespace ICSharpCode.ILSpy
return null;
}
- public override RichText GetRichTextTooltip(IEntity entity)
+ public override RichText? GetRichTextTooltip(IEntity entity)
{
var output = new AvalonEditTextOutput() { IgnoreNewLineAndIndent = true };
var disasm = CreateDisassembler(output, MainWindow.Instance.CreateDecompilationOptions());
diff --git a/ILSpy/Languages/Language.cs b/ILSpy/Languages/Language.cs
index 26410fe24..5374a8eec 100644
--- a/ILSpy/Languages/Language.cs
+++ b/ILSpy/Languages/Language.cs
@@ -52,7 +52,7 @@ namespace ICSharpCode.ILSpy
///
public abstract string FileExtension { get; }
- public virtual string ProjectFileExtension {
+ public virtual string? ProjectFileExtension {
get { return null; }
}
@@ -107,7 +107,7 @@ namespace ICSharpCode.ILSpy
WriteCommentLine(output, nameSpace);
}
- public virtual ProjectId DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
+ public virtual ProjectId? DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
{
WriteCommentLine(output, assembly.FileName);
var asm = assembly.GetMetadataFileOrNull();
@@ -478,7 +478,7 @@ namespace ICSharpCode.ILSpy
///
/// This should produce a string representation of the entity for search to match search strings against.
///
- public virtual string GetEntityName(MetadataFile module, EntityHandle handle, bool fullName, bool omitGenerics)
+ public virtual string? GetEntityName(MetadataFile module, EntityHandle handle, bool fullName, bool omitGenerics)
{
MetadataReader metadata = module.Metadata;
switch (handle.Kind)
diff --git a/ILSpy/MainWindow.xaml.cs b/ILSpy/MainWindow.xaml.cs
index 21271efeb..87c9ce121 100644
--- a/ILSpy/MainWindow.xaml.cs
+++ b/ILSpy/MainWindow.xaml.cs
@@ -83,7 +83,7 @@ namespace ICSharpCode.ILSpy
get { return instance; }
}
- public SharpTreeView AssemblyTreeView {
+ public SharpTreeView? AssemblyTreeView {
get {
return FindResource("AssemblyTreeView") as SharpTreeView;
}
@@ -312,7 +312,7 @@ namespace ICSharpCode.ILSpy
}
}
- internal static string GetResourceString(string key)
+ internal static string? GetResourceString(string key)
{
if (string.IsNullOrEmpty(key))
{
@@ -1109,7 +1109,7 @@ namespace ICSharpCode.ILSpy
///
/// Retrieves a node using the .ToString() representations of its ancestors.
///
- public SharpTreeNode FindNodeByPath(string[] path, bool returnBestMatch)
+ public SharpTreeNode? FindNodeByPath(string[] path, bool returnBestMatch)
{
if (path == null)
return null;
@@ -1135,7 +1135,7 @@ namespace ICSharpCode.ILSpy
///
/// Gets the .ToString() representation of the node's ancestors.
///
- public static string[] GetPathForNode(SharpTreeNode node)
+ public static string[]? GetPathForNode(SharpTreeNode node)
{
if (node == null)
return null;
@@ -1149,7 +1149,7 @@ namespace ICSharpCode.ILSpy
return path.ToArray();
}
- public ILSpyTreeNode FindTreeNode(object reference)
+ public ILSpyTreeNode? FindTreeNode(object reference)
{
switch (reference)
{
@@ -1586,7 +1586,7 @@ namespace ICSharpCode.ILSpy
sessionSettings.Save();
}
- private string GetAutoLoadedAssemblyNode(SharpTreeNode node)
+ private string? GetAutoLoadedAssemblyNode(SharpTreeNode node)
{
if (node == null)
return null;
diff --git a/ILSpy/Metadata/CoffHeaderTreeNode.cs b/ILSpy/Metadata/CoffHeaderTreeNode.cs
index 78eca5bf2..ab6859024 100644
--- a/ILSpy/Metadata/CoffHeaderTreeNode.cs
+++ b/ILSpy/Metadata/CoffHeaderTreeNode.cs
@@ -116,7 +116,7 @@ namespace ICSharpCode.ILSpy.Metadata
this.detailsFieldName = detailsFieldName;
}
- public override DataTemplate SelectTemplate(object item, DependencyObject container)
+ public override DataTemplate? SelectTemplate(object item, DependencyObject container)
{
if (((Entry)item).Member == detailsFieldName)
return (DataTemplate)MetadataTableViews.Instance["HeaderFlagsDetailsDataGrid"];
diff --git a/ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs b/ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs
index d47f49a1a..3dbdd38a8 100644
--- a/ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs
+++ b/ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs
@@ -89,7 +89,7 @@ namespace ICSharpCode.ILSpy.Metadata
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int PublicKeyOrToken => MetadataTokens.GetHeapOffset(assemblyRef.PublicKeyOrToken);
- public string PublicKeyOrTokenTooltip {
+ public string? PublicKeyOrTokenTooltip {
get {
if (assemblyRef.PublicKeyOrToken.IsNil)
return null;
diff --git a/ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs b/ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs
index e6c41e5aa..45155e67e 100644
--- a/ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs
+++ b/ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs
@@ -97,7 +97,7 @@ namespace ICSharpCode.ILSpy.Metadata
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int Value => MetadataTokens.GetHeapOffset(constant.Value);
- public string ValueTooltip {
+ public string? ValueTooltip {
get {
return null;
}
diff --git a/ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs b/ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs
index bae1ceffd..1249ca69e 100644
--- a/ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs
+++ b/ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs
@@ -103,7 +103,7 @@ namespace ICSharpCode.ILSpy.Metadata
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int Value => MetadataTokens.GetHeapOffset(customAttr.Value);
- public string ValueTooltip {
+ public string? ValueTooltip {
get {
return null;
}
diff --git a/ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs b/ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs
index b719f678c..91ab69def 100644
--- a/ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs
+++ b/ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs
@@ -102,7 +102,7 @@ namespace ICSharpCode.ILSpy.Metadata
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int PermissionSet => MetadataTokens.GetHeapOffset(declSecAttr.PermissionSet);
- public string PermissionSetTooltip {
+ public string? PermissionSetTooltip {
get {
return null;
}
diff --git a/ILSpy/Metadata/CorTables/FileTableTreeNode.cs b/ILSpy/Metadata/CorTables/FileTableTreeNode.cs
index f48edcb39..896774477 100644
--- a/ILSpy/Metadata/CorTables/FileTableTreeNode.cs
+++ b/ILSpy/Metadata/CorTables/FileTableTreeNode.cs
@@ -90,7 +90,7 @@ namespace ICSharpCode.ILSpy.Metadata
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int HashValue => MetadataTokens.GetHeapOffset(assemblyFile.HashValue);
- public string HashValueTooltip {
+ public string? HashValueTooltip {
get {
if (assemblyFile.HashValue.IsNil)
return null;
diff --git a/ILSpy/Metadata/CorTables/MethodTableTreeNode.cs b/ILSpy/Metadata/CorTables/MethodTableTreeNode.cs
index b6f9ac6b4..fe5cb173c 100644
--- a/ILSpy/Metadata/CorTables/MethodTableTreeNode.cs
+++ b/ILSpy/Metadata/CorTables/MethodTableTreeNode.cs
@@ -122,7 +122,7 @@ namespace ICSharpCode.ILSpy.Metadata
}
string paramListTooltip;
- public string ParamListTooltip {
+ public string? ParamListTooltip {
get {
var param = methodDef.GetParameters().FirstOrDefault();
if (param.IsNil)
diff --git a/ILSpy/Metadata/CorTables/ModuleTableTreeNode.cs b/ILSpy/Metadata/CorTables/ModuleTableTreeNode.cs
index 490d0ed5c..1a2b26990 100644
--- a/ILSpy/Metadata/CorTables/ModuleTableTreeNode.cs
+++ b/ILSpy/Metadata/CorTables/ModuleTableTreeNode.cs
@@ -83,12 +83,12 @@ namespace ICSharpCode.ILSpy.Metadata
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int GenerationId => MetadataTokens.GetHeapOffset(moduleDef.GenerationId);
- public string GenerationIdTooltip => moduleDef.GenerationId.IsNil ? null : metadataFile.Metadata.GetGuid(moduleDef.GenerationId).ToString();
+ public string? GenerationIdTooltip => moduleDef.GenerationId.IsNil ? null : metadataFile.Metadata.GetGuid(moduleDef.GenerationId).ToString();
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int BaseGenerationId => MetadataTokens.GetHeapOffset(moduleDef.BaseGenerationId);
- public string BaseGenerationIdTooltip => moduleDef.BaseGenerationId.IsNil ? null : metadataFile.Metadata.GetGuid(moduleDef.BaseGenerationId).ToString();
+ public string? BaseGenerationIdTooltip => moduleDef.BaseGenerationId.IsNil ? null : metadataFile.Metadata.GetGuid(moduleDef.BaseGenerationId).ToString();
public ModuleEntry(MetadataFile metadataFile, ModuleDefinitionHandle handle)
{
diff --git a/ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs b/ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs
index 8f9ac73fb..1ae59f107 100644
--- a/ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs
+++ b/ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs
@@ -114,7 +114,7 @@ namespace ICSharpCode.ILSpy.Metadata
MainWindow.Instance.JumpToReference(new EntityReference(metadataFile, typeDef.BaseType, protocol: "metadata"));
}
- public string BaseTypeTooltip {
+ public string? BaseTypeTooltip {
get {
var output = new PlainTextOutput();
var provider = new DisassemblerSignatureTypeProvider(metadataFile, output);
@@ -146,7 +146,7 @@ namespace ICSharpCode.ILSpy.Metadata
}
string fieldListTooltip;
- public string FieldListTooltip {
+ public string? FieldListTooltip {
get {
var field = typeDef.GetFields().FirstOrDefault();
if (field.IsNil)
@@ -164,7 +164,7 @@ namespace ICSharpCode.ILSpy.Metadata
}
string methodListTooltip;
- public string MethodListTooltip {
+ public string? MethodListTooltip {
get {
var method = typeDef.GetMethods().FirstOrDefault();
if (method.IsNil)
diff --git a/ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs b/ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs
index f9ef9f369..9dcbe2f01 100644
--- a/ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs
+++ b/ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs
@@ -243,7 +243,7 @@ namespace ICSharpCode.ILSpy.Metadata
object rowDetails;
- public object RowDetails {
+ public object? RowDetails {
get {
if (rowDetails != null)
return rowDetails;
diff --git a/ILSpy/Metadata/DebugTables/DocumentTableTreeNode.cs b/ILSpy/Metadata/DebugTables/DocumentTableTreeNode.cs
index 320fdffff..c24b6f19f 100644
--- a/ILSpy/Metadata/DebugTables/DocumentTableTreeNode.cs
+++ b/ILSpy/Metadata/DebugTables/DocumentTableTreeNode.cs
@@ -84,7 +84,7 @@ namespace ICSharpCode.ILSpy.Metadata
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int HashAlgorithm => MetadataTokens.GetHeapOffset(document.HashAlgorithm);
- public string HashAlgorithmTooltip {
+ public string? HashAlgorithmTooltip {
get {
if (document.HashAlgorithm.IsNil)
return null;
@@ -100,7 +100,7 @@ namespace ICSharpCode.ILSpy.Metadata
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int Hash => MetadataTokens.GetHeapOffset(document.Hash);
- public string HashTooltip {
+ public string? HashTooltip {
get {
if (document.Hash.IsNil)
return null;
@@ -112,7 +112,7 @@ namespace ICSharpCode.ILSpy.Metadata
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int Language => MetadataTokens.GetHeapOffset(document.Language);
- public string LanguageTooltip {
+ public string? LanguageTooltip {
get {
if (document.Language.IsNil)
return null;
diff --git a/ILSpy/Metadata/DebugTables/MethodDebugInformationTableTreeNode.cs b/ILSpy/Metadata/DebugTables/MethodDebugInformationTableTreeNode.cs
index 80aede7fc..4059cce6d 100644
--- a/ILSpy/Metadata/DebugTables/MethodDebugInformationTableTreeNode.cs
+++ b/ILSpy/Metadata/DebugTables/MethodDebugInformationTableTreeNode.cs
@@ -86,7 +86,7 @@ namespace ICSharpCode.ILSpy.Metadata
MainWindow.Instance.JumpToReference(new EntityReference(metadataFile, debugInfo.Document, protocol: "metadata"));
}
- public string DocumentTooltip {
+ public string? DocumentTooltip {
get {
if (debugInfo.Document.IsNil)
return null;
@@ -98,7 +98,7 @@ namespace ICSharpCode.ILSpy.Metadata
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int SequencePoints => MetadataTokens.GetHeapOffset(debugInfo.SequencePointsBlob);
- public string SequencePointsTooltip {
+ public string? SequencePointsTooltip {
get {
if (debugInfo.SequencePointsBlob.IsNil)
return null;
@@ -119,7 +119,7 @@ namespace ICSharpCode.ILSpy.Metadata
MainWindow.Instance.JumpToReference(new EntityReference(metadataFile, debugInfo.LocalSignature, protocol: "metadata"));
}
- public string LocalSignatureTooltip {
+ public string? LocalSignatureTooltip {
get {
if (debugInfo.LocalSignature.IsNil)
return null;
diff --git a/ILSpy/Metadata/GoToTokenCommand.cs b/ILSpy/Metadata/GoToTokenCommand.cs
index 1c0caca2b..9a57de525 100644
--- a/ILSpy/Metadata/GoToTokenCommand.cs
+++ b/ILSpy/Metadata/GoToTokenCommand.cs
@@ -90,7 +90,7 @@ namespace ICSharpCode.ILSpy.Commands
&& GetSelectedCellContent(context.DataGrid, context.MousePosition) != null;
}
- private string GetSelectedCellContent(DataGrid grid, Point position)
+ private string? GetSelectedCellContent(DataGrid grid, Point position)
{
position = grid.PointFromScreen(position);
var hit = VisualTreeHelper.HitTest(grid, position);
diff --git a/ILSpy/Metadata/MetadataProtocolHandler.cs b/ILSpy/Metadata/MetadataProtocolHandler.cs
index c49e300d7..a0008d21e 100644
--- a/ILSpy/Metadata/MetadataProtocolHandler.cs
+++ b/ILSpy/Metadata/MetadataProtocolHandler.cs
@@ -29,7 +29,7 @@ namespace ICSharpCode.ILSpy.Metadata
[PartCreationPolicy(CreationPolicy.Shared)]
class MetadataProtocolHandler : IProtocolHandler
{
- public ILSpyTreeNode Resolve(string protocol, MetadataFile module, Handle handle, out bool newTabPage)
+ public ILSpyTreeNode? Resolve(string protocol, MetadataFile module, Handle handle, out bool newTabPage)
{
newTabPage = true;
if (protocol != "metadata")
diff --git a/ILSpy/Metadata/MetadataTableTreeNode.cs b/ILSpy/Metadata/MetadataTableTreeNode.cs
index 2df51f1c6..18e678804 100644
--- a/ILSpy/Metadata/MetadataTableTreeNode.cs
+++ b/ILSpy/Metadata/MetadataTableTreeNode.cs
@@ -66,7 +66,7 @@ namespace ICSharpCode.ILSpy.Metadata
this.scrollTarget = default;
}
- protected static string GenerateTooltip(ref string tooltip, MetadataFile module, EntityHandle handle)
+ protected static string? GenerateTooltip(ref string tooltip, MetadataFile module, EntityHandle handle)
{
if (tooltip == null)
{
diff --git a/ILSpy/Search/SearchPane.xaml.cs b/ILSpy/Search/SearchPane.xaml.cs
index a3a7584a2..8e824a3c6 100644
--- a/ILSpy/Search/SearchPane.xaml.cs
+++ b/ILSpy/Search/SearchPane.xaml.cs
@@ -435,7 +435,7 @@ namespace ICSharpCode.ILSpy.Search
}
}
- Regex CreateRegex(string s)
+ Regex? CreateRegex(string s)
{
try
{
@@ -492,7 +492,7 @@ namespace ICSharpCode.ILSpy.Search
}
}
- AbstractSearchStrategy GetSearchStrategy(SearchRequest request)
+ AbstractSearchStrategy? GetSearchStrategy(SearchRequest request)
{
if (request.Keywords.Length == 0 && request.RegEx == null)
return null;
diff --git a/ILSpy/TextView/BracketHighlightRenderer.cs b/ILSpy/TextView/BracketHighlightRenderer.cs
index 4b958d407..cf27cd7bd 100644
--- a/ILSpy/TextView/BracketHighlightRenderer.cs
+++ b/ILSpy/TextView/BracketHighlightRenderer.cs
@@ -40,7 +40,7 @@ namespace ICSharpCode.ILSpy.TextView
{
public static readonly DefaultBracketSearcher DefaultInstance = new DefaultBracketSearcher();
- public BracketSearchResult SearchBracket(IDocument document, int offset)
+ public BracketSearchResult? SearchBracket(IDocument document, int offset)
{
return null;
}
diff --git a/ILSpy/TextView/ReferenceElementGenerator.cs b/ILSpy/TextView/ReferenceElementGenerator.cs
index f1255990a..ebcfb2774 100644
--- a/ILSpy/TextView/ReferenceElementGenerator.cs
+++ b/ILSpy/TextView/ReferenceElementGenerator.cs
@@ -52,7 +52,7 @@ namespace ICSharpCode.ILSpy.TextView
return segment != null ? segment.StartOffset : -1;
}
- public override VisualLineElement ConstructElement(int offset)
+ public override VisualLineElement? ConstructElement(int offset)
{
if (this.References == null)
return null;
diff --git a/ILSpy/TextView/UIElementGenerator.cs b/ILSpy/TextView/UIElementGenerator.cs
index e0c254e61..0d0f90cba 100644
--- a/ILSpy/TextView/UIElementGenerator.cs
+++ b/ILSpy/TextView/UIElementGenerator.cs
@@ -53,7 +53,7 @@ namespace ICSharpCode.ILSpy.TextView
return -1;
}
- public override VisualLineElement ConstructElement(int offset)
+ public override VisualLineElement? ConstructElement(int offset)
{
if (this.UIElements == null)
return null;
diff --git a/ILSpy/TreeNodes/AssemblyListTreeNode.cs b/ILSpy/TreeNodes/AssemblyListTreeNode.cs
index 9808ddcfd..3b1bc8bc0 100644
--- a/ILSpy/TreeNodes/AssemblyListTreeNode.cs
+++ b/ILSpy/TreeNodes/AssemblyListTreeNode.cs
@@ -130,7 +130,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
}
#region Find*Node
- public ILSpyTreeNode FindResourceNode(Resource resource)
+ public ILSpyTreeNode? FindResourceNode(Resource resource)
{
if (resource == null)
return null;
@@ -169,14 +169,14 @@ namespace ICSharpCode.ILSpy.TreeNodes
return FindAssemblyNode(module.MetadataFile);
}
- public AssemblyTreeNode FindAssemblyNode(MetadataFile module)
+ public AssemblyTreeNode? FindAssemblyNode(MetadataFile module)
{
if (module == null)
return null;
return FindAssemblyNode(module.GetLoadedAssembly());
}
- public AssemblyTreeNode FindAssemblyNode(LoadedAssembly asm)
+ public AssemblyTreeNode? FindAssemblyNode(LoadedAssembly asm)
{
if (asm == null)
return null;
@@ -203,7 +203,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
}
return null;
- static SharpTreeNodeCollection ExpandAndGetChildren(SharpTreeNode node)
+ static SharpTreeNodeCollection? ExpandAndGetChildren(SharpTreeNode node)
{
if (node is not PackageFolderTreeNode)
return null;
@@ -216,7 +216,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
/// Looks up the type node corresponding to the type definition.
/// Returns null if no matching node is found.
///
- public TypeTreeNode FindTypeNode(ITypeDefinition def)
+ public TypeTreeNode? FindTypeNode(ITypeDefinition def)
{
if (def == null)
return null;
@@ -245,7 +245,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
/// Looks up the method node corresponding to the method definition.
/// Returns null if no matching node is found.
///
- public ILSpyTreeNode FindMethodNode(IMethod def)
+ public ILSpyTreeNode? FindMethodNode(IMethod def)
{
TypeTreeNode typeNode = FindTypeNode(def.DeclaringTypeDefinition);
if (typeNode == null)
@@ -286,7 +286,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
/// Looks up the field node corresponding to the field definition.
/// Returns null if no matching node is found.
///
- public FieldTreeNode FindFieldNode(IField def)
+ public FieldTreeNode? FindFieldNode(IField def)
{
TypeTreeNode typeNode = FindTypeNode(def.DeclaringTypeDefinition);
if (typeNode == null)
@@ -299,7 +299,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
/// Looks up the property node corresponding to the property definition.
/// Returns null if no matching node is found.
///
- public PropertyTreeNode FindPropertyNode(IProperty def)
+ public PropertyTreeNode? FindPropertyNode(IProperty def)
{
TypeTreeNode typeNode = FindTypeNode(def.DeclaringTypeDefinition);
if (typeNode == null)
@@ -312,7 +312,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
/// Looks up the event node corresponding to the event definition.
/// Returns null if no matching node is found.
///
- public EventTreeNode FindEventNode(IEvent def)
+ public EventTreeNode? FindEventNode(IEvent def)
{
TypeTreeNode typeNode = FindTypeNode(def.DeclaringTypeDefinition);
if (typeNode == null)
@@ -325,7 +325,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
/// Looks up the event node corresponding to the namespace definition.
/// Returns null if no matching node is found.
///
- public NamespaceTreeNode FindNamespaceNode(INamespace def)
+ public NamespaceTreeNode? FindNamespaceNode(INamespace def)
{
var module = def.ContributingModules.FirstOrDefault();
if (module == null)
diff --git a/ILSpy/TreeNodes/AssemblyTreeNode.cs b/ILSpy/TreeNodes/AssemblyTreeNode.cs
index d2f102ef2..1f4c0b794 100644
--- a/ILSpy/TreeNodes/AssemblyTreeNode.cs
+++ b/ILSpy/TreeNodes/AssemblyTreeNode.cs
@@ -387,7 +387,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
///
/// Finds the node for a top-level type.
///
- public TypeTreeNode FindTypeNode(ITypeDefinition type)
+ public TypeTreeNode? FindTypeNode(ITypeDefinition type)
{
if (type == null)
return null;
@@ -402,7 +402,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
///
/// Finds the node for a namespace.
///
- public NamespaceTreeNode FindNamespaceNode(string namespaceName)
+ public NamespaceTreeNode? FindNamespaceNode(string namespaceName)
{
if (string.IsNullOrEmpty(namespaceName))
return null;
@@ -730,7 +730,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
});
}
- internal static AssemblyTreeNode GetAssemblyTreeNode(SharpTreeNode node)
+ internal static AssemblyTreeNode? GetAssemblyTreeNode(SharpTreeNode node)
{
while (node != null)
{
diff --git a/ILSpy/Updates/NotifyOfUpdatesStrategy.cs b/ILSpy/Updates/NotifyOfUpdatesStrategy.cs
index 1d5123c26..4bff0a0d8 100644
--- a/ILSpy/Updates/NotifyOfUpdatesStrategy.cs
+++ b/ILSpy/Updates/NotifyOfUpdatesStrategy.cs
@@ -61,7 +61,7 @@ namespace ICSharpCode.ILSpy.Updates
/// Returns the download URL if an update is available.
/// Returns null if no update is available, or if no check was performed.
///
- public static async Task CheckForUpdatesIfEnabledAsync(ILSpySettings spySettings)
+ public static async Task CheckForUpdatesIfEnabledAsync(ILSpySettings spySettings)
{
UpdateSettings s = new UpdateSettings(spySettings);
@@ -93,7 +93,7 @@ namespace ICSharpCode.ILSpy.Updates
return CheckForUpdateInternal(s);
}
- static async Task CheckForUpdateInternal(UpdateSettings s)
+ static async Task CheckForUpdateInternal(UpdateSettings s)
{
try
{