Browse Source

focus on CS8603, return null from method

pull/3287/head
apmoskevitz 9 months ago
parent
commit
d89f85087e
  1. 4
      ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
  2. 2
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
  3. 2
      ICSharpCode.Decompiler/CSharp/OutputVisitor/TextWriterTokenWriter.cs
  4. 2
      ICSharpCode.Decompiler/CSharp/ProjectDecompiler/TargetFramework.cs
  5. 2
      ICSharpCode.Decompiler/CSharp/ProjectDecompiler/WholeProjectDecompiler.cs
  6. 8
      ICSharpCode.Decompiler/CSharp/Resolver/CSharpConversions.cs
  7. 6
      ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs
  8. 8
      ICSharpCode.Decompiler/CSharp/Resolver/OverloadResolution.cs
  9. 2
      ICSharpCode.Decompiler/CSharp/Resolver/TypeInference.cs
  10. 2
      ICSharpCode.Decompiler/CSharp/StatementBuilder.cs
  11. 4
      ICSharpCode.Decompiler/CSharp/Syntax/DepthFirstAstVisitor.cs
  12. 2
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/UnaryOperatorExpression.cs
  13. 2
      ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/OperatorDeclaration.cs
  14. 6
      ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs
  15. 4
      ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUnsafeModifier.cs
  16. 22
      ICSharpCode.Decompiler/CSharp/Transforms/PatternStatementTransform.cs
  17. 4
      ICSharpCode.Decompiler/CSharp/TypeSystem/ResolvedUsingScope.cs
  18. 2
      ICSharpCode.Decompiler/CSharp/TypeSystem/TypeOrNamespaceReference.cs
  19. 4
      ICSharpCode.Decompiler/Disassembler/DisassemblerHelpers.cs
  20. 2
      ICSharpCode.Decompiler/Documentation/IdStringMemberReference.cs
  21. 4
      ICSharpCode.Decompiler/Documentation/XmlDocLoader.cs
  22. 14
      ICSharpCode.Decompiler/Documentation/XmlDocumentationProvider.cs
  23. 10
      ICSharpCode.Decompiler/FlowAnalysis/DataFlowVisitor.cs
  24. 4
      ICSharpCode.Decompiler/Humanizer/Vocabulary.cs
  25. 2
      ICSharpCode.Decompiler/IL/ControlFlow/LoopDetection.cs
  26. 8
      ICSharpCode.Decompiler/IL/ControlFlow/SwitchAnalysis.cs
  27. 8
      ICSharpCode.Decompiler/IL/ControlFlow/SwitchDetection.cs
  28. 8
      ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs
  29. 2
      ICSharpCode.Decompiler/IL/PointerArithmeticOffset.cs
  30. 10
      ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs
  31. 2
      ICSharpCode.Decompiler/IL/Transforms/CombineExitsTransform.cs
  32. 4
      ICSharpCode.Decompiler/IL/Transforms/DeconstructionTransform.cs
  33. 4
      ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs
  34. 2
      ICSharpCode.Decompiler/IL/Transforms/DynamicCallSiteTransform.cs
  35. 16
      ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs
  36. 6
      ICSharpCode.Decompiler/IL/Transforms/HighLevelLoopTransform.cs
  37. 2
      ICSharpCode.Decompiler/IL/Transforms/ILExtraction.cs
  38. 6
      ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs
  39. 2
      ICSharpCode.Decompiler/IL/Transforms/InterpolatedStringTransform.cs
  40. 10
      ICSharpCode.Decompiler/IL/Transforms/LocalFunctionDecompiler.cs
  41. 4
      ICSharpCode.Decompiler/IL/Transforms/NullPropagationTransform.cs
  42. 4
      ICSharpCode.Decompiler/IL/Transforms/NullableLiftingTransform.cs
  43. 2
      ICSharpCode.Decompiler/IL/Transforms/ReduceNestingTransform.cs
  44. 2
      ICSharpCode.Decompiler/IL/Transforms/SplitVariables.cs
  45. 10
      ICSharpCode.Decompiler/IL/Transforms/TransformDisplayClassUsage.cs
  46. 6
      ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs
  47. 4
      ICSharpCode.Decompiler/IL/Transforms/UserDefinedLogicTransform.cs
  48. 6
      ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs
  49. 12
      ICSharpCode.Decompiler/Metadata/LightJson/JsonValue.cs
  50. 2
      ICSharpCode.Decompiler/NRExtensions.cs
  51. 10
      ICSharpCode.Decompiler/Output/TextTokenWriter.cs
  52. 2
      ICSharpCode.Decompiler/Semantics/LocalResolveResult.cs
  53. 2
      ICSharpCode.Decompiler/TypeSystem/FunctionPointerType.cs
  54. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/AttributeListBuilder.cs
  55. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/CustomAttribute.cs
  56. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/DecimalConstantHelper.cs
  57. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultAssemblyReference.cs
  58. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/DummyTypeParameter.cs
  59. 4
      ICSharpCode.Decompiler/TypeSystem/Implementation/FakeMember.cs
  60. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/GetClassTypeReference.cs
  61. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/MergedNamespace.cs
  62. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataNamespace.cs
  63. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataParameter.cs
  64. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializedMember.cs
  65. 6
      ICSharpCode.Decompiler/TypeSystem/InheritanceHelper.cs
  66. 22
      ICSharpCode.Decompiler/TypeSystem/MetadataModule.cs
  67. 2
      ICSharpCode.Decompiler/TypeSystem/ReflectionHelper.cs
  68. 2
      ICSharpCode.Decompiler/TypeSystem/TupleType.cs
  69. 2
      ICSharpCode.Decompiler/TypeSystem/TypeProvider.cs
  70. 12
      ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs
  71. 2
      ICSharpCode.Decompiler/Util/CSharpPrimitiveCast.cs
  72. 2
      ILSpy/Analyzers/TreeNodes/AnalyzedModuleTreeNode.cs
  73. 2
      ILSpy/App.xaml.cs
  74. 2
      ILSpy/AppEnv/CommandLineTools.cs
  75. 2
      ILSpy/Commands/CopyFullyQualifiedNameContextMenuEntry.cs
  76. 2
      ILSpy/Commands/SaveCodeContextMenuEntry.cs
  77. 2
      ILSpy/Commands/ScopeSearchToNamespace.cs
  78. 2
      ILSpy/Controls/ExtensionMethods.cs
  79. 2
      ILSpy/Controls/TreeView/LinesRenderer.cs
  80. 2
      ILSpy/Controls/TreeView/SharpTreeNodeView.cs
  81. 4
      ILSpy/Controls/TreeView/SharpTreeView.cs
  82. 2
      ILSpy/Controls/TreeView/SharpTreeViewItem.cs
  83. 2
      ILSpy/Docking/DockLayoutSettings.cs
  84. 2
      ILSpy/Languages/CSharpBracketSearcher.cs
  85. 4
      ILSpy/Languages/CSharpHighlightingTokenWriter.cs
  86. 4
      ILSpy/Languages/CSharpLanguage.cs
  87. 4
      ILSpy/Languages/ILLanguage.cs
  88. 6
      ILSpy/Languages/Language.cs
  89. 12
      ILSpy/MainWindow.xaml.cs
  90. 2
      ILSpy/Metadata/CoffHeaderTreeNode.cs
  91. 2
      ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs
  92. 2
      ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs
  93. 2
      ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs
  94. 2
      ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs
  95. 2
      ILSpy/Metadata/CorTables/FileTableTreeNode.cs
  96. 2
      ILSpy/Metadata/CorTables/MethodTableTreeNode.cs
  97. 4
      ILSpy/Metadata/CorTables/ModuleTableTreeNode.cs
  98. 6
      ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs
  99. 2
      ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs
  100. 6
      ILSpy/Metadata/DebugTables/DocumentTableTreeNode.cs
  101. Some files were not shown because too many files have changed in this diff Show More

4
ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

@ -541,7 +541,7 @@ namespace ICSharpCode.Decompiler.CSharp
return typeSystemAstBuilder; return typeSystemAstBuilder;
} }
IDocumentationProvider CreateDefaultDocumentationProvider() IDocumentationProvider? CreateDefaultDocumentationProvider()
{ {
try try
{ {
@ -1096,7 +1096,7 @@ namespace ICSharpCode.Decompiler.CSharp
return syntaxTree; return syntaxTree;
} }
ITypeDefinition FindCommonDeclaringTypeDefinition(ITypeDefinition a, ITypeDefinition b) ITypeDefinition? FindCommonDeclaringTypeDefinition(ITypeDefinition a, ITypeDefinition b)
{ {
if (a == null || b == null) if (a == null || b == null)
return null; return null;

2
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); Debug.Assert(method.IsLocalFunction);
method = (IMethod)((IMethod)method.MemberDefinition).ReducedFrom.MemberDefinition; method = (IMethod)((IMethod)method.MemberDefinition).ReducedFrom.MemberDefinition;

2
ICSharpCode.Decompiler/CSharp/OutputVisitor/TextWriterTokenWriter.cs

@ -437,7 +437,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
/// Gets the escape sequence for the specified character. /// Gets the escape sequence for the specified character.
/// </summary> /// </summary>
/// <remarks>This method does not convert ' or ".</remarks> /// <remarks>This method does not convert ' or ".</remarks>
static string ConvertChar(char ch) static string? ConvertChar(char ch)
{ {
switch (ch) switch (ch)
{ {

2
ICSharpCode.Decompiler/CSharp/ProjectDecompiler/TargetFramework.cs

@ -79,7 +79,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler
/// </summary> /// </summary>
public bool IsPortableClassLibrary { get; } 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 // Reference: https://docs.microsoft.com/en-us/dotnet/standard/frameworks
switch (frameworkIdentifier) switch (frameworkIdentifier)

2
ICSharpCode.Decompiler/CSharp/ProjectDecompiler/WholeProjectDecompiler.cs

@ -488,7 +488,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler
const int RT_ICON = 3; const int RT_ICON = 3;
const int RT_GROUP_ICON = 14; 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; var iconGroup = resources.Find(new Win32ResourceName(RT_GROUP_ICON))?.FirstDirectory()?.FirstData()?.Data;
if (iconGroup == null) if (iconGroup == null)

8
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. /// For IList{T}, ICollection{T}, IEnumerable{T} and IReadOnlyList{T}, returns T.
/// Otherwise, returns null. /// Otherwise, returns null.
/// </summary> /// </summary>
IType UnpackGenericArrayInterface(IType interfaceType) IType? UnpackGenericArrayInterface(IType interfaceType)
{ {
ParameterizedType? pt = interfaceType as ParameterizedType; ParameterizedType? pt = interfaceType as ParameterizedType;
if (pt != null) if (pt != null)
@ -938,7 +938,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
&& (StandardImplicitConversion(a, b).IsValid || StandardImplicitConversion(b, a).IsValid); && (StandardImplicitConversion(a, b).IsValid || StandardImplicitConversion(b, a).IsValid);
} }
IType FindMostEncompassedType(IEnumerable<IType> candidates) IType? FindMostEncompassedType(IEnumerable<IType> candidates)
{ {
IType? best = null; IType? best = null;
foreach (var current in candidates) foreach (var current in candidates)
@ -951,7 +951,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
return best; return best;
} }
IType FindMostEncompassingType(IEnumerable<IType> candidates) IType? FindMostEncompassingType(IEnumerable<IType> candidates)
{ {
IType? best = null; IType? best = null;
foreach (var current in candidates) foreach (var current in candidates)
@ -1482,7 +1482,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
/// <summary> /// <summary>
/// Unpacks the generic Task[T]. Returns null if the input is not Task[T]. /// Unpacks the generic Task[T]. Returns null if the input is not Task[T].
/// </summary> /// </summary>
static IType UnpackTask(IType type) static IType? UnpackTask(IType type)
{ {
ParameterizedType? pt = type as ParameterizedType; ParameterizedType? pt = type as ParameterizedType;
if (pt != null && pt.TypeParameterCount == 1 && pt.Name == "Task" && pt.Namespace == "System.Threading.Tasks") if (pt != null && pt.TypeParameterCount == 1 && pt.Name == "Task" && pt.Namespace == "System.Threading.Tasks")

6
ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs

@ -565,7 +565,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
#endregion #endregion
#region GetOverloadableOperatorName #region GetOverloadableOperatorName
static string GetOverloadableOperatorName(UnaryOperatorType op) static string? GetOverloadableOperatorName(UnaryOperatorType op)
{ {
switch (op) switch (op)
{ {
@ -980,7 +980,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
#endregion #endregion
#region Enum helper methods #region Enum helper methods
IType GetEnumUnderlyingType(IType enumType) IType? GetEnumUnderlyingType(IType enumType)
{ {
ITypeDefinition? def = enumType.GetDefinition(); ITypeDefinition? def = enumType.GetDefinition();
return def != null ? def.EnumUnderlyingType : SpecialType.UnknownType; return def != null ? def.EnumUnderlyingType : SpecialType.UnknownType;
@ -1203,7 +1203,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
#endregion #endregion
#region GetOverloadableOperatorName #region GetOverloadableOperatorName
static string GetOverloadableOperatorName(BinaryOperatorType op) static string? GetOverloadableOperatorName(BinaryOperatorType op)
{ {
switch (op) switch (op)
{ {

8
ICSharpCode.Decompiler/CSharp/Resolver/OverloadResolution.cs

@ -891,7 +891,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
#endregion #endregion
#region Output Properties #region Output Properties
public IParameterizedMember BestCandidate { public IParameterizedMember? BestCandidate {
get { return bestCandidate != null ? bestCandidate.Member : null; } get { return bestCandidate != null ? bestCandidate.Member : null; }
} }
@ -919,7 +919,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
get { return bestCandidate != null && IsApplicable(bestCandidate.Errors); } get { return bestCandidate != null && IsApplicable(bestCandidate.Errors); }
} }
public IParameterizedMember BestCandidateAmbiguousWith { public IParameterizedMember? BestCandidateAmbiguousWith {
get { return bestCandidateAmbiguousWith != null ? bestCandidateAmbiguousWith.Member : null; } get { return bestCandidateAmbiguousWith != null ? bestCandidateAmbiguousWith.Member : null; }
} }
@ -958,7 +958,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
/// ///
/// parameterIndex = GetArgumentToParameterMap()[argumentIndex] /// parameterIndex = GetArgumentToParameterMap()[argumentIndex]
/// </summary> /// </summary>
public IReadOnlyList<int> GetArgumentToParameterMap() public IReadOnlyList<int>? GetArgumentToParameterMap()
{ {
if (bestCandidate != null) if (bestCandidate != null)
return bestCandidate.ArgumentToParameterMap; return bestCandidate.ArgumentToParameterMap;
@ -1037,7 +1037,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
return args; return args;
} }
public IParameterizedMember GetBestCandidateWithSubstitutedTypeArguments() public IParameterizedMember? GetBestCandidateWithSubstitutedTypeArguments()
{ {
if (bestCandidate == null) if (bestCandidate == null)
return null; return null;

2
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) if (v is NullabilityAnnotatedTypeParameter natp)
{ {

2
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) if (!settings.ForEachStatement)
{ {

4
ICSharpCode.Decompiler/CSharp/Syntax/DepthFirstAstVisitor.cs

@ -713,7 +713,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// </summary> /// </summary>
public abstract class DepthFirstAstVisitor<T> : IAstVisitor<T> public abstract class DepthFirstAstVisitor<T> : IAstVisitor<T>
{ {
protected virtual T VisitChildren(AstNode node) protected virtual T? VisitChildren(AstNode node)
{ {
AstNode? next; AstNode? next;
for (var child = node.FirstChild; child != null; child = next) for (var child = node.FirstChild; child != null; child = next)
@ -726,7 +726,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return default(T); return default(T);
} }
public virtual T VisitNullNode(AstNode nullNode) public virtual T? VisitNullNode(AstNode nullNode)
{ {
// Should we call VisitChildren here? // Should we call VisitChildren here?
// We usually want to ignore null nodes. // We usually want to ignore null nodes.

2
ICSharpCode.Decompiler/CSharp/Syntax/Expressions/UnaryOperatorExpression.cs

@ -94,7 +94,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
&& this.Expression.DoMatch(o.Expression, match); && this.Expression.DoMatch(o.Expression, match);
} }
public static TokenRole GetOperatorRole(UnaryOperatorType op) public static TokenRole? GetOperatorRole(UnaryOperatorType op)
{ {
switch (op) switch (op)
{ {

2
ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/OperatorDeclaration.cs

@ -293,7 +293,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// <summary> /// <summary>
/// Gets the method name for the operator type. ("op_Addition", "op_Implicit", etc.) /// Gets the method name for the operator type. ("op_Addition", "op_Implicit", etc.)
/// </summary> /// </summary>
public static string GetName(OperatorType? type) public static string? GetName(OperatorType? type)
{ {
if (type == null) if (type == null)
return null; return null;

6
ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs

@ -1443,7 +1443,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
const float MathF_PI = 3.14159274f; const float MathF_PI = 3.14159274f;
const float MathF_E = 2.71828175f; 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() Expression MakeFieldReference()
{ {
@ -1464,7 +1464,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return new CastExpression(ConvertType(type), fieldRef); return new CastExpression(ConvertType(type), fieldRef);
} }
Expression ExtractExpression(long n, long d) Expression? ExtractExpression(long n, long d)
{ {
Expression fieldReference = MakeFieldReference(); Expression fieldReference = MakeFieldReference();
@ -2400,7 +2400,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return decl; 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)) if (!tp.HasDefaultConstructorConstraint && !tp.HasReferenceTypeConstraint && !tp.HasValueTypeConstraint && tp.NullabilityConstraint != Nullability.NotNullable && tp.DirectBaseTypes.All(IsObjectOrValueType))
{ {

4
ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUnsafeModifier.cs

@ -40,8 +40,8 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
protected override bool VisitChildren(AstNode node) protected override bool VisitChildren(AstNode node)
{ {
bool result = false; bool result = false;
AstNode next; AstNode? next;
for (AstNode child = node.FirstChild; child != null; child = next) for (AstNode? child = node.FirstChild; child != null; child = next)
{ {
// Store next to allow the loop to continue // Store next to allow the loop to continue
// if the visitor removes/replaces child. // if the visitor removes/replaces child.

22
ICSharpCode.Decompiler/CSharp/Transforms/PatternStatementTransform.cs

@ -77,7 +77,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
public override AstNode VisitExpressionStatement(ExpressionStatement expressionStatement) public override AstNode VisitExpressionStatement(ExpressionStatement expressionStatement)
{ {
AstNode result = TransformForeachOnMultiDimArray(expressionStatement); AstNode? result = TransformForeachOnMultiDimArray(expressionStatement);
if (result != null) if (result != null)
return result; return result;
result = TransformFor(expressionStatement); result = TransformFor(expressionStatement);
@ -182,7 +182,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
if (!m1.Success) if (!m1.Success)
return null; return null;
var variable = m1.Get<IdentifierExpression>("variable").Single().GetILVariable(); var variable = m1.Get<IdentifierExpression>("variable").Single().GetILVariable();
AstNode next = node.NextSibling; AstNode? next = node.NextSibling;
if (next is ForStatement forStatement && ForStatementUsesVariable(forStatement, variable)) if (next is ForStatement forStatement && ForStatementUsesVariable(forStatement, variable))
{ {
node.Remove(); node.Remove();
@ -477,7 +477,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
return true; return true;
} }
Statement TransformForeachOnMultiDimArray(ExpressionStatement expressionStatement) Statement? TransformForeachOnMultiDimArray(ExpressionStatement expressionStatement)
{ {
if (!context.Settings.ForEachStatement) if (!context.Settings.ForEachStatement)
return null; return null;
@ -609,7 +609,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
return true; return true;
} }
PropertyDeclaration TransformAutomaticProperty(PropertyDeclaration propertyDeclaration) PropertyDeclaration? TransformAutomaticProperty(PropertyDeclaration propertyDeclaration)
{ {
IProperty? property = propertyDeclaration.GetSymbol() as IProperty; IProperty? property = propertyDeclaration.GetSymbol() as IProperty;
if (!CanTransformToAutomaticProperty(property, !property.DeclaringTypeDefinition.Fields.Any(f => f.Name == "_" + property.Name && f.IsCompilerGenerated()))) 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; return true;
} }
Identifier ReplaceBackingFieldUsage(Identifier identifier) Identifier? ReplaceBackingFieldUsage(Identifier identifier)
{ {
if (NameCouldBeBackingFieldOfAutomaticProperty(identifier.Name, out _)) if (NameCouldBeBackingFieldOfAutomaticProperty(identifier.Name, out _))
{ {
@ -757,7 +757,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
return null; return null;
} }
Identifier ReplaceEventFieldAnnotation(Identifier identifier) Identifier? ReplaceEventFieldAnnotation(Identifier identifier)
{ {
var parent = identifier.Parent; var parent = identifier.Parent;
var mrr = parent.Annotation<MemberResolveResult>(); var mrr = parent.Annotation<MemberResolveResult>();
@ -995,7 +995,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
return true; return true;
} }
EventDeclaration TransformAutomaticEvents(CustomEventDeclaration ev) EventDeclaration? TransformAutomaticEvents(CustomEventDeclaration ev)
{ {
if (!ev.PrivateImplementationType.IsNull) if (!ev.PrivateImplementationType.IsNull)
return null; return null;
@ -1055,7 +1055,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
Body = destructorBodyPattern Body = destructorBodyPattern
}; };
DestructorDeclaration TransformDestructor(MethodDeclaration methodDef) DestructorDeclaration? TransformDestructor(MethodDeclaration methodDef)
{ {
Match m = destructorPattern.Match(methodDef); Match m = destructorPattern.Match(methodDef);
if (m.Success) if (m.Success)
@ -1072,7 +1072,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
return null; return null;
} }
DestructorDeclaration TransformDestructorBody(DestructorDeclaration dtorDef) DestructorDeclaration? TransformDestructorBody(DestructorDeclaration dtorDef)
{ {
Match m = destructorBodyPattern.Match(dtorDef.Body); Match m = destructorBodyPattern.Match(dtorDef.Body);
if (m.Success) if (m.Success)
@ -1099,7 +1099,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
/// Simplify nested 'try { try {} catch {} } finally {}'. /// Simplify nested 'try { try {} catch {} } finally {}'.
/// This transformation must run after the using/lock tranformations. /// This transformation must run after the using/lock tranformations.
/// </summary> /// </summary>
TryCatchStatement TransformTryCatchFinally(TryCatchStatement tryFinally) TryCatchStatement? TransformTryCatchFinally(TryCatchStatement tryFinally)
{ {
if (tryCatchFinallyPattern.IsMatch(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); Match m = cascadingIfElsePattern.Match(node);
if (m.Success) if (m.Success)

4
ICSharpCode.Decompiler/CSharp/TypeSystem/ResolvedUsingScope.cs

@ -213,12 +213,12 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
get { return parentNamespace.Compilation; } get { return parentNamespace.Compilation; }
} }
INamespace INamespace.GetChildNamespace(string name) INamespace? INamespace.GetChildNamespace(string name)
{ {
return null; return null;
} }
ITypeDefinition INamespace.GetTypeDefinition(string name, int typeParameterCount) ITypeDefinition? INamespace.GetTypeDefinition(string name, int typeParameterCount)
{ {
return null; return null;
} }

2
ICSharpCode.Decompiler/CSharp/TypeSystem/TypeOrNamespaceReference.cs

@ -43,7 +43,7 @@ namespace ICSharpCode.Decompiler.CSharp.TypeSystem
/// <summary> /// <summary>
/// Returns the namespace that is referenced; or null if no such namespace is found. /// Returns the namespace that is referenced; or null if no such namespace is found.
/// </summary> /// </summary>
public INamespace ResolveNamespace(CSharpResolver resolver) public INamespace? ResolveNamespace(CSharpResolver resolver)
{ {
NamespaceResolveResult? nrr = Resolve(resolver) as NamespaceResolveResult; NamespaceResolveResult? nrr = Resolve(resolver) as NamespaceResolveResult;
return nrr != null ? nrr.Namespace : null; return nrr != null ? nrr.Namespace : null;

4
ICSharpCode.Decompiler/Disassembler/DisassemblerHelpers.cs

@ -150,7 +150,7 @@ namespace ICSharpCode.Decompiler.Disassembler
writer.WriteLocalReference(name, "param_" + index); writer.WriteLocalReference(name, "param_" + index);
} }
string GetParameterName(int parameterNumber) string? GetParameterName(int parameterNumber)
{ {
var methodDefinition = metadata.GetMethodDefinition(handle); var methodDefinition = metadata.GetMethodDefinition(handle);
if ((methodDefinition.Attributes & System.Reflection.MethodAttributes.Static) != 0) if ((methodDefinition.Attributes & System.Reflection.MethodAttributes.Static) != 0)
@ -339,7 +339,7 @@ namespace ICSharpCode.Decompiler.Disassembler
} }
return sb.ToString(); return sb.ToString();
} }
public static string PrimitiveTypeName(string fullName) public static string? PrimitiveTypeName(string fullName)
{ {
switch (fullName) switch (fullName)
{ {

2
ICSharpCode.Decompiler/Documentation/IdStringMemberReference.cs

@ -61,7 +61,7 @@ namespace ICSharpCode.Decompiler.Documentation
get { return declaringTypeReference; } get { return declaringTypeReference; }
} }
public IMember Resolve(ITypeResolveContext context) public IMember? Resolve(ITypeResolveContext context)
{ {
IType declaringType = declaringTypeReference.Resolve(context); IType declaringType = declaringTypeReference.Resolve(context);
foreach (var member in declaringType.GetMembers(CanMatch, GetMemberOptions.IgnoreInheritedMembers)) foreach (var member in declaringType.GetMembers(CanMatch, GetMemberOptions.IgnoreInheritedMembers))

4
ICSharpCode.Decompiler/Documentation/XmlDocLoader.cs

@ -34,7 +34,7 @@ namespace ICSharpCode.Decompiler.Documentation
static readonly Lazy<XmlDocumentationProvider> mscorlibDocumentation = new Lazy<XmlDocumentationProvider>(LoadMscorlibDocumentation); static readonly Lazy<XmlDocumentationProvider> mscorlibDocumentation = new Lazy<XmlDocumentationProvider>(LoadMscorlibDocumentation);
static readonly ConditionalWeakTable<MetadataFile, XmlDocumentationProvider> cache = new(); static readonly ConditionalWeakTable<MetadataFile, XmlDocumentationProvider> cache = new();
static XmlDocumentationProvider LoadMscorlibDocumentation() static XmlDocumentationProvider? LoadMscorlibDocumentation()
{ {
string xmlDocFile = FindXmlDocumentation("mscorlib.dll", TargetRuntime.Net_4_0) string xmlDocFile = FindXmlDocumentation("mscorlib.dll", TargetRuntime.Net_4_0)
?? FindXmlDocumentation("mscorlib.dll", TargetRuntime.Net_2_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. /// Given the assembly file name, looks up the XML documentation file name.
/// Returns null if no XML documentation file is found. /// Returns null if no XML documentation file is found.
/// </summary> /// </summary>
internal static string LookupLocalizedXmlDoc(string fileName) internal static string? LookupLocalizedXmlDoc(string fileName)
{ {
if (string.IsNullOrEmpty(fileName)) if (string.IsNullOrEmpty(fileName))
return null; return null;

14
ICSharpCode.Decompiler/Documentation/XmlDocumentationProvider.cs

@ -81,7 +81,7 @@ namespace ICSharpCode.Decompiler.Documentation
return false; return false;
} }
internal void Add(string key, string value) internal void Add(string key, string? value)
{ {
entries[pos++] = new KeyValuePair<string, string>(key, value); entries[pos++] = new KeyValuePair<string, string>(key, value);
if (pos == entries.Length) if (pos == entries.Length)
@ -279,7 +279,7 @@ namespace ICSharpCode.Decompiler.Documentation
if (reader.LocalName == "member") if (reader.LocalName == "member")
{ {
int pos = linePosMapper.GetPositionForLine(reader.LineNumber) + Math.Max(reader.LinePosition - 2, 0); 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) if (memberAttr != null)
indexList.Add(new IndexEntry(GetHashCode(memberAttr), pos)); indexList.Add(new IndexEntry(GetHashCode(memberAttr), pos));
reader.Skip(); reader.Skip();
@ -330,7 +330,7 @@ namespace ICSharpCode.Decompiler.Documentation
return GetDocumentation(entity.GetIdString()); return GetDocumentation(entity.GetIdString());
} }
string GetDocumentation(string key, bool allowReload) string? GetDocumentation(string key, bool allowReload)
{ {
int hashcode = GetHashCode(key); int hashcode = GetHashCode(key);
var index = this.index; // read volatile field var index = this.index; // read volatile field
@ -347,7 +347,7 @@ namespace ICSharpCode.Decompiler.Documentation
XmlDocumentationCache cache = this.cache; XmlDocumentationCache cache = this.cache;
lock (cache) lock (cache)
{ {
if (!cache.TryGet(key, out string val)) if (!cache.TryGet(key, out string? val))
{ {
try try
{ {
@ -376,7 +376,7 @@ namespace ICSharpCode.Decompiler.Documentation
} }
} }
string ReloadAndGetDocumentation(string key) string? ReloadAndGetDocumentation(string key)
{ {
try try
{ {
@ -407,7 +407,7 @@ namespace ICSharpCode.Decompiler.Documentation
#endregion #endregion
#region Load / Read XML #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)) 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) if (r.NodeType == XmlNodeType.Element)
{ {
string memberAttr = r.GetAttribute("name"); string? memberAttr = r.GetAttribute("name");
if (memberAttr == key) if (memberAttr == key)
{ {
return r.ReadInnerXml(); return r.ReadInnerXml();

10
ICSharpCode.Decompiler/FlowAnalysis/DataFlowVisitor.cs

@ -237,7 +237,7 @@ namespace ICSharpCode.Decompiler.FlowAnalysis
#if DEBUG #if DEBUG
Debug.Assert(initialized, "Initialize() was not called"); 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)); Debug.Assert(previousState.LessThanOrEqual(state));
previousState.JoinWith(state); previousState.JoinWith(state);
@ -350,7 +350,7 @@ namespace ICSharpCode.Decompiler.FlowAnalysis
/// </remarks> /// </remarks>
State GetBlockInputState(Block block) State GetBlockInputState(Block block)
{ {
if (stateOnBranch.TryGetValue(block, out State s)) if (stateOnBranch.TryGetValue(block, out State? s))
{ {
return s; return s;
} }
@ -398,7 +398,7 @@ namespace ICSharpCode.Decompiler.FlowAnalysis
state.ReplaceWith(stateOnBranch[block]); state.ReplaceWith(stateOnBranch[block]);
block.AcceptVisitor(this); block.AcceptVisitor(this);
} }
if (stateOnLeave.TryGetValue(container, out State stateOnExit)) if (stateOnLeave.TryGetValue(container, out State? stateOnExit))
{ {
state.ReplaceWith(stateOnExit); state.ReplaceWith(stateOnExit);
} }
@ -463,7 +463,7 @@ namespace ICSharpCode.Decompiler.FlowAnalysis
void MergeBranchStateIntoStateOnLeave(Leave inst, State branchState) 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); targetState.JoinWith(branchState);
} }
@ -505,7 +505,7 @@ namespace ICSharpCode.Decompiler.FlowAnalysis
protected State HandleTryBlock(TryInstruction inst) protected State HandleTryBlock(TryInstruction inst)
{ {
State oldStateOnException = currentStateOnException; State oldStateOnException = currentStateOnException;
if (stateOnException.TryGetValue(inst, out State newStateOnException)) if (stateOnException.TryGetValue(inst, out State? newStateOnException))
{ {
newStateOnException.JoinWith(state); newStateOnException.JoinWith(state);
} }

4
ICSharpCode.Decompiler/Humanizer/Vocabulary.cs

@ -119,7 +119,7 @@ namespace Humanizer.Inflections
return result ?? word; return result ?? word;
} }
private string ApplyRules(IList<Rule> rules, string word, bool skipFirstRule) private string? ApplyRules(IList<Rule> rules, string word, bool skipFirstRule)
{ {
if (word == null) if (word == null)
{ {
@ -164,7 +164,7 @@ namespace Humanizer.Inflections
_replacement = replacement; _replacement = replacement;
} }
public string Apply(string word) public string? Apply(string word)
{ {
if (!_regex.IsMatch(word)) if (!_regex.IsMatch(word))
{ {

2
ICSharpCode.Decompiler/IL/ControlFlow/LoopDetection.cs

@ -311,7 +311,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
/// 3) otherwise (exit point unknown, heuristically extend loop): null /// 3) otherwise (exit point unknown, heuristically extend loop): null
/// </returns> /// </returns>
/// <remarks>This method must not write to the Visited flags on the CFG.</remarks> /// <remarks>This method must not write to the Visited flags on the CFG.</remarks>
internal ControlFlowNode FindExitPoint(ControlFlowNode loopHead, IReadOnlyList<ControlFlowNode> naturalLoop) internal ControlFlowNode? FindExitPoint(ControlFlowNode loopHead, IReadOnlyList<ControlFlowNode> naturalLoop)
{ {
bool hasReachableExit = HasReachableExit(loopHead); bool hasReachableExit = HasReachableExit(loopHead);
if (!hasReachableExit) if (!hasReachableExit)

8
ICSharpCode.Decompiler/IL/ControlFlow/SwitchAnalysis.cs

@ -126,7 +126,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
trueValues = trueValues.IntersectWith(inputValues); trueValues = trueValues.IntersectWith(inputValues);
if (trueValues.SetEquals(inputValues) || trueValues.IsEmpty) if (trueValues.SetEquals(inputValues) || trueValues.IsEmpty)
return false; return false;
Block trueBlock; Block? trueBlock;
if (trueInst.MatchBranch(out trueBlock) && AnalyzeBlock(trueBlock, trueValues)) if (trueInst.MatchBranch(out trueBlock) && AnalyzeBlock(trueBlock, trueValues))
{ {
// OK, true block was further analyzed. // OK, true block was further analyzed.
@ -159,7 +159,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
var remainingValues = inputValues.ExceptWith(trueValues); var remainingValues = inputValues.ExceptWith(trueValues);
ILInstruction falseInst = block.Instructions.Last(); ILInstruction falseInst = block.Instructions.Last();
Block falseBlock; Block? falseBlock;
if (falseInst.MatchBranch(out falseBlock) && AnalyzeBlock(falseBlock, remainingValues)) if (falseInst.MatchBranch(out falseBlock) && AnalyzeBlock(falseBlock, remainingValues))
{ {
// OK, false block was further analyzed. // OK, false block was further analyzed.
@ -237,7 +237,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
{ {
return; return;
} }
if (inst.MatchBranch(out Block targetBlock)) if (inst.MatchBranch(out Block? targetBlock))
{ {
if (targetBlockToSectionIndex.TryGetValue(targetBlock, out int index)) if (targetBlockToSectionIndex.TryGetValue(targetBlock, out int index))
{ {
@ -252,7 +252,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
Sections.Add(new KeyValuePair<LongSet, ILInstruction>(values, inst)); Sections.Add(new KeyValuePair<LongSet, ILInstruction>(values, inst));
} }
} }
else if (inst.MatchLeave(out BlockContainer targetContainer)) else if (inst.MatchLeave(out BlockContainer? targetContainer))
{ {
if (targetContainerToSectionIndex.TryGetValue(targetContainer, out int index)) if (targetContainerToSectionIndex.TryGetValue(targetContainer, out int index))
{ {

8
ICSharpCode.Decompiler/IL/ControlFlow/SwitchDetection.cs

@ -233,9 +233,9 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
var dict = new Dictionary<Block, SwitchSection>(); // branch target -> switch section var dict = new Dictionary<Block, SwitchSection>(); // branch target -> switch section
sw.Sections.RemoveAll( sw.Sections.RemoveAll(
section => { 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.Labels = primarySection.Labels.UnionWith(section.Labels);
primarySection.HasNullLabel |= section.HasNullLabel; primarySection.HasNullLabel |= section.HasNullLabel;
@ -438,13 +438,13 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
// if (comp(logic.not(call get_HasValue(ldloca nullableVar))) br NullCase // if (comp(logic.not(call get_HasValue(ldloca nullableVar))) br NullCase
// br RootBlock // 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 || if (nullableBlock == null ||
nullableBlock.Instructions.Count < 2 || nullableBlock.Instructions.Count < 2 ||
!nullableBlock.Instructions.Last().MatchBranch(analysis.RootBlock) || !nullableBlock.Instructions.Last().MatchBranch(analysis.RootBlock) ||
!nullableBlock.Instructions.SecondToLastOrDefault().MatchIfInstruction(out var cond, out var trueInst) || !nullableBlock.Instructions.SecondToLastOrDefault().MatchIfInstruction(out var cond, out var trueInst) ||
!cond.MatchLogicNot(out var getHasValue) || !cond.MatchLogicNot(out var getHasValue) ||
!NullableLiftingTransform.MatchHasValueCall(getHasValue, out ILInstruction nullableInst)) !NullableLiftingTransform.MatchHasValueCall(getHasValue, out ILInstruction? nullableInst))
return; return;
// could check that nullableInst is ldloc or ldloca and that the switch variable matches a GetValueOrDefault // could check that nullableInst is ldloc or ldloca and that the switch variable matches a GetValueOrDefault

8
ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs

@ -269,7 +269,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
return false; return false;
} }
ILInstruction newObj; ILInstruction? newObj;
if (body.Instructions.Count == 1) if (body.Instructions.Count == 1)
{ {
// No parameters passed to enumerator (not even 'this'): // 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) void ConvertBranchAfterYieldReturn(Block newBlock, Block oldBlock, int pos)
{ {
Block targetBlock; Block? targetBlock;
if (isCompiledWithMono && disposingField != null) if (isCompiledWithMono && disposingField != null)
{ {
// Mono skips over the state assignment if 'this.disposing' is set: // Mono skips over the state assignment if 'this.disposing' is set:
@ -1233,7 +1233,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
{ {
context.CancellationToken.ThrowIfCancellationRequested(); context.CancellationToken.ThrowIfCancellationRequested();
int oldState = blockState[block.ChildIndex]; 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) if (GetNewState(block) is int newState)
{ {
// OK, state change // OK, state change
@ -1436,7 +1436,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
return false; return false;
if (!call.Method.Name.StartsWith("<>__Finally")) if (!call.Method.Name.StartsWith("<>__Finally"))
return false; return false;
ITypeDefinition declaringTypeDefinition = call.Method.DeclaringTypeDefinition; ITypeDefinition? declaringTypeDefinition = call.Method.DeclaringTypeDefinition;
if (declaringTypeDefinition.MetadataToken != this.enumeratorType) if (declaringTypeDefinition.MetadataToken != this.enumeratorType)
return false; return false;
if (declaringTypeDefinition.ParentModule.MetadataFile.Metadata != metadata) if (declaringTypeDefinition.ParentModule.MetadataFile.Metadata != metadata)

2
ICSharpCode.Decompiler/IL/PointerArithmeticOffset.cs

@ -35,7 +35,7 @@ namespace ICSharpCode.Decompiler.IL
/// <param name="pointerElementType">The target type of the pointer type.</param> /// <param name="pointerElementType">The target type of the pointer type.</param>
/// <param name="checkForOverflow">Whether the pointer arithmetic operation checks for overflow.</param> /// <param name="checkForOverflow">Whether the pointer arithmetic operation checks for overflow.</param>
/// <param name="unwrapZeroExtension">Whether to allow zero extensions in the mul argument.</param> /// <param name="unwrapZeroExtension">Whether to allow zero extensions in the mul argument.</param>
public static ILInstruction Detect(ILInstruction byteOffsetInst, IType pointerElementType, public static ILInstruction? Detect(ILInstruction byteOffsetInst, IType pointerElementType,
bool checkForOverflow, bool checkForOverflow,
bool unwrapZeroExtension = false) bool unwrapZeroExtension = false)
{ {

10
ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs

@ -227,7 +227,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{ {
var v = i.Variable; var v = i.Variable;
// if there is already a valid name for the variable slot, just use it // 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; v.Name = name;
continue; continue;
@ -463,7 +463,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return SplitName(proposedName, out _); return SplitName(proposedName, out _);
} }
static string GetNameFromInstruction(ILInstruction inst) static string? GetNameFromInstruction(ILInstruction inst)
{ {
switch (inst) switch (inst)
{ {
@ -506,7 +506,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return null; return null;
} }
static string GetNameForArgument(ILInstruction parent, int i) static string? GetNameForArgument(ILInstruction parent, int i)
{ {
switch (parent) switch (parent)
{ {
@ -566,7 +566,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
type = NullableType.GetUnderlyingType(((TypeWithElementType)type).ElementType); type = NullableType.GetUnderlyingType(((TypeWithElementType)type).ElementType);
} }
string name = type.Kind switch { string? name = type.Kind switch {
TypeKind.Array => "array", TypeKind.Array => "array",
TypeKind.Pointer => "ptr", TypeKind.Pointer => "ptr",
TypeKind.TypeParameter => "val", TypeKind.TypeParameter => "val",
@ -637,7 +637,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return name; return name;
} }
static string CleanUpVariableName(string name) static string? CleanUpVariableName(string name)
{ {
// remove the backtick (generics) // remove the backtick (generics)
int pos = name.IndexOf('`'); int pos = name.IndexOf('`');

2
ICSharpCode.Decompiler/IL/Transforms/CombineExitsTransform.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
ExpressionTransforms.RunOnSingleStatement(combinedExit, context); 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)) if (!(block.Instructions.SecondToLastOrDefault() is IfInstruction ifInst && block.Instructions.LastOrDefault() is Leave leaveElse))
return null; return null;

4
ICSharpCode.Decompiler/IL/Transforms/DeconstructionTransform.cs

@ -191,8 +191,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{ {
int startPos = pos; int startPos = pos;
Action<DeconstructInstruction>? delayedActions = null; Action<DeconstructInstruction>? delayedActions = null;
if (MatchDeconstruction(block.Instructions[pos], out IMethod deconstructMethod, if (MatchDeconstruction(block.Instructions[pos], out IMethod? deconstructMethod,
out ILInstruction rootTestedOperand)) out ILInstruction? rootTestedOperand))
{ {
pos++; pos++;
} }

4
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) [NotNullWhen(true)] out ILInstruction? target, [NotNullWhen(true)] out IType? delegateType, bool allowTransformed = false)
{ {
targetMethod = null; targetMethod = null;
@ -165,7 +165,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return new GenericContext(classTypeParameters, methodTypeParameters); return new GenericContext(classTypeParameters, methodTypeParameters);
} }
ILFunction TransformDelegateConstruction( ILFunction? TransformDelegateConstruction(
ILInstruction value, IMethod targetMethod, ILInstruction value, IMethod targetMethod,
ILInstruction target, IType delegateType) ILInstruction target, IType delegateType)
{ {

2
ICSharpCode.Decompiler/IL/Transforms/DynamicCallSiteTransform.cs

@ -147,7 +147,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
container.SortBlocks(deleteUnreachableBlocks: true); container.SortBlocks(deleteUnreachableBlocks: true);
} }
ILInstruction MakeDynamicInstruction(CallSiteInfo callsite, CallVirt targetInvokeCall, List<ILInstruction> deadArguments) ILInstruction? MakeDynamicInstruction(CallSiteInfo callsite, CallVirt targetInvokeCall, List<ILInstruction> deadArguments)
{ {
switch (callsite.Kind) switch (callsite.Kind)
{ {

16
ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs

@ -141,7 +141,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
} }
else if (rightWithoutConv.MatchLdcI4(0) && inst.Kind.IsEqualityOrInequality()) 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.unsigned(ldlen array == conv i4->i(ldc.i4 0))
// => comp(ldlen.i4 array == 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) protected internal override void VisitConv(Conv inst)
{ {
inst.Argument.AcceptVisitor(this); 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)) && (!inst.CheckForOverflow || context.Settings.AssumeArrayLengthFitsIntoInt32))
{ {
context.Step("conv.i4(ldlen array) => ldlen.i4(array)", inst); 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) protected internal override void VisitNewObj(NewObj inst)
{ {
Block? block; Block? block;
if (TransformSpanTCtorContainingStackAlloc(inst, out ILInstruction locallocSpan)) if (TransformSpanTCtorContainingStackAlloc(inst, out ILInstruction? locallocSpan))
{ {
context.Step("new Span<T>(stackalloc) -> stackalloc Span<T>", inst); context.Step("new Span<T>(stackalloc) -> stackalloc Span<T>", inst);
inst.ReplaceWith(locallocSpan); inst.ReplaceWith(locallocSpan);
@ -329,7 +329,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
inst.ReplaceWith(replacement); inst.ReplaceWith(replacement);
return; 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); context.Step("new Delegate(target, ldvirtftn Method) -> ldvirtdelegate Delegate Method(target)", inst);
inst.ReplaceWith(ldVirtDelegate); inst.ReplaceWith(ldVirtDelegate);
@ -462,7 +462,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
EarlyExpressionTransforms.AddressOfLdLocToLdLoca(inst, context); EarlyExpressionTransforms.AddressOfLdLocToLdLoca(inst, context);
if (EarlyExpressionTransforms.LdObjToLdLoc(inst, context)) if (EarlyExpressionTransforms.LdObjToLdLoc(inst, context))
return; return;
if (TransformDecimalFieldToConstant(inst, out LdcDecimal decimalConstant)) if (TransformDecimalFieldToConstant(inst, out LdcDecimal? decimalConstant))
{ {
context.Step("TransformDecimalFieldToConstant", inst); context.Step("TransformDecimalFieldToConstant", inst);
inst.ReplaceWith(decimalConstant); inst.ReplaceWith(decimalConstant);
@ -549,8 +549,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
Block? falseInst = inst.FalseInst as Block; Block? falseInst = inst.FalseInst as Block;
if (falseInst == null || falseInst.Instructions.Count != 1) if (falseInst == null || falseInst.Instructions.Count != 1)
return inst; return inst;
ILVariable v; ILVariable? v;
ILInstruction value1, value2; ILInstruction? value1, value2;
if (trueInst.Instructions[0].MatchStLoc(out v, out value1) && falseInst.Instructions[0].MatchStLoc(v, out value2)) if (trueInst.Instructions[0].MatchStLoc(out v, out value1) && falseInst.Instructions[0].MatchStLoc(v, out value2))
{ {
context.Step("conditional operator", inst); context.Step("conditional operator", inst);
@ -629,7 +629,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{ {
// validate that each integer is used for exactly one value // validate that each integer is used for exactly one value
var integersUsed = new HashSet<int>(); var integersUsed = new HashSet<int>();
foreach ((string key, int val) in str2int.Map) foreach ((string? key, int val) in str2int.Map)
{ {
if (!integersUsed.Add(val)) if (!integersUsed.Add(val))
return; return;

6
ICSharpCode.Decompiler/IL/Transforms/HighLevelLoopTransform.cs

@ -156,21 +156,21 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// </summary> /// </summary>
bool MatchDoWhileLoop(BlockContainer loop) bool MatchDoWhileLoop(BlockContainer loop)
{ {
(List<IfInstruction>? conditions, ILInstruction exit, bool swap, bool split, bool unwrap) = AnalyzeDoWhileConditions(loop); (List<IfInstruction>? conditions, ILInstruction? exit, bool swap, bool split, bool unwrap) = AnalyzeDoWhileConditions(loop);
// not a do-while loop, exit. // not a do-while loop, exit.
if (conditions == null || conditions.Count == 0) if (conditions == null || conditions.Count == 0)
return false; return false;
context.Step("Transform to do-while loop: " + loop.EntryPoint.Label, loop); context.Step("Transform to do-while loop: " + loop.EntryPoint.Label, loop);
Block conditionBlock; Block conditionBlock;
// first we remove all extracted instructions from the original block. // first we remove all extracted instructions from the original block.
var originalBlock = (Block)exit.Parent; var originalBlock = exit.Parent as Block;
if (unwrap) if (unwrap)
{ {
// we found a condition block nested in a condition that is followed by a return statement: // we found a condition block nested in a condition that is followed by a return statement:
// we flip the condition and swap the blocks // we flip the condition and swap the blocks
Debug.Assert(originalBlock.Parent is IfInstruction); Debug.Assert(originalBlock.Parent is IfInstruction);
var returnCondition = (IfInstruction)originalBlock.Parent; var returnCondition = (IfInstruction)originalBlock.Parent;
var topLevelBlock = (Block)returnCondition.Parent; var topLevelBlock = returnCondition.Parent as Block;
Debug.Assert(topLevelBlock.Parent == loop); Debug.Assert(topLevelBlock.Parent == loop);
var leaveFunction = topLevelBlock.Instructions[returnCondition.ChildIndex + 1]; var leaveFunction = topLevelBlock.Instructions[returnCondition.ChildIndex + 1];
Debug.Assert(leaveFunction.MatchReturn(out _)); Debug.Assert(leaveFunction.MatchReturn(out _));

2
ICSharpCode.Decompiler/IL/Transforms/ILExtraction.cs

@ -97,7 +97,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// ///
/// May return null if extraction is not possible. /// May return null if extraction is not possible.
/// </summary> /// </summary>
public static ILVariable Extract(ILInstruction instToExtract, ILTransformContext context) public static ILVariable? Extract(ILInstruction instToExtract, ILTransformContext context)
{ {
var function = instToExtract.Ancestors.OfType<ILFunction>().First(); var function = instToExtract.Ancestors.OfType<ILFunction>().First();
ExtractionContext ctx = new ExtractionContext(function, context); ExtractionContext ctx = new ExtractionContext(function, context);

6
ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs

@ -577,7 +577,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{ {
if (findResult.Type == FindResultType.NamedArgument) if (findResult.Type == FindResultType.NamedArgument)
{ {
var originalStore = (StLoc)inlinedExpression.Parent; var originalStore = inlinedExpression.Parent as StLoc;
return !originalStore.ILStackWasEmpty; return !originalStore.ILStackWasEmpty;
} }
Debug.Assert(findResult.Type == FindResultType.Found); Debug.Assert(findResult.Type == FindResultType.Found);
@ -784,7 +784,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
if (expr.MatchLdLoc(v) || expr.MatchLdLoca(v)) if (expr.MatchLdLoc(v) || expr.MatchLdLoca(v))
{ {
// Match found, we can inline // 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) if ((options & InliningOptions.AllowChangingOrderOfEvaluationForExceptions) != 0)
{ {
@ -867,7 +867,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// <summary> /// <summary>
/// Finds the first call instruction within the instructions that were inlined into inst. /// Finds the first call instruction within the instructions that were inlined into inst.
/// </summary> /// </summary>
internal static CallInstruction FindFirstInlinedCall(ILInstruction inst) internal static CallInstruction? FindFirstInlinedCall(ILInstruction inst)
{ {
foreach (var child in inst.Children) foreach (var child in inst.Children)
{ {

2
ICSharpCode.Decompiler/IL/Transforms/InterpolatedStringTransform.cs

@ -32,7 +32,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return; return;
int interpolationStart = pos; int interpolationStart = pos;
int interpolationEnd; int interpolationEnd;
ILInstruction insertionPoint; ILInstruction? insertionPoint;
// stloc v(newobj DefaultInterpolatedStringHandler..ctor(ldc.i4 literalLength, ldc.i4 formattedCount)) // stloc v(newobj DefaultInterpolatedStringHandler..ctor(ldc.i4 literalLength, ldc.i4 formattedCount))
if (block.Instructions[pos] is StLoc { if (block.Instructions[pos] is StLoc {
Variable: ILVariable { Kind: VariableKind.Local } v, Variable: ILVariable { Kind: VariableKind.Local } v,

10
ICSharpCode.Decompiler/IL/Transforms/LocalFunctionDecompiler.cs

@ -308,7 +308,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
} }
} }
private ILInstruction FindCompatibleArgument(LocalFunctionInfo info, IList<ILInstruction> arguments, bool ignoreStructure = false) private ILInstruction? FindCompatibleArgument(LocalFunctionInfo info, IList<ILInstruction> arguments, bool ignoreStructure = false)
{ {
foreach (var arg in arguments) foreach (var arg in arguments)
{ {
@ -321,7 +321,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return null; return null;
} }
private ILVariable ResolveAncestorScopeReference(ILInstruction inst) private ILVariable? ResolveAncestorScopeReference(ILInstruction inst)
{ {
if (!inst.MatchLdFld(out var target, out var field)) if (!inst.MatchLdFld(out var target, out var field))
return null; return null;
@ -338,7 +338,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return null; return null;
} }
private ILFunction GetDeclaringFunction(ILFunction localFunction) private ILFunction? GetDeclaringFunction(ILFunction localFunction)
{ {
if (localFunction.DeclarationScope == null) if (localFunction.DeclarationScope == null)
return 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 methodDefinition = context.PEFile.Metadata.GetMethodDefinition((MethodDefinitionHandle)targetMethod.MetadataToken);
var genericContext = GenericContextFromTypeArguments(targetMethod, skipCount); var genericContext = GenericContextFromTypeArguments(targetMethod, skipCount);
@ -723,7 +723,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
function.DeclarationScope = FindCommonAncestorInstruction<BlockContainer>(function.DeclarationScope, closureVar.CaptureScope); function.DeclarationScope = FindCommonAncestorInstruction<BlockContainer>(function.DeclarationScope, closureVar.CaptureScope);
return true; return true;
ILInstruction GetClosureInitializer(ILVariable variable) ILInstruction? GetClosureInitializer(ILVariable variable)
{ {
var type = variable.Type.UnwrapByRef().GetDefinition(); var type = variable.Type.UnwrapByRef().GetDefinition();
if (type == null) if (type == null)

4
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. /// Check if "condition ? trueInst : falseInst" can be simplified using the null-conditional operator.
/// Returns the replacement instruction, or null if no replacement is possible. /// Returns the replacement instruction, or null if no replacement is possible.
/// </summary> /// </summary>
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(context.Settings.NullPropagation);
Debug.Assert(!condition.MatchLogicNot(out _), "Caller should pass in positive condition"); Debug.Assert(!condition.MatchLogicNot(out _), "Caller should pass in positive condition");
@ -107,7 +107,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// <summary> /// <summary>
/// testedVar != null ? nonNullInst : nullInst /// testedVar != null ? nonNullInst : nullInst
/// </summary> /// </summary>
ILInstruction TryNullPropagation(ILVariable testedVar, ILInstruction nonNullInst, ILInstruction nullInst, ILInstruction? TryNullPropagation(ILVariable testedVar, ILInstruction nonNullInst, ILInstruction nullInst,
Mode mode) Mode mode)
{ {
bool removedRewrapOrNullableCtor = false; bool removedRewrapOrNullableCtor = false;

4
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 /// Main entry point for lifting; called by both the expression-transform
/// and the block transform. /// and the block transform.
/// </summary> /// </summary>
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; // ifInst is usually the IfInstruction to which condition belongs;
// but can also be a BinaryNumericInstruction. // 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) if (Instruction is Comp comp)
{ {

2
ICSharpCode.Decompiler/IL/Transforms/ReduceNestingTransform.cs

@ -451,7 +451,7 @@ namespace ICSharpCode.Decompiler.IL
/// ///
/// [else-]if (parent-cond) else { ifInst } /// [else-]if (parent-cond) else { ifInst }
/// </summary> /// </summary>
private IfInstruction GetElseIfParent(IfInstruction ifInst) private IfInstruction? GetElseIfParent(IfInstruction ifInst)
{ {
Debug.Assert(ifInst.Parent is Block); Debug.Assert(ifInst.Parent is Block);
if (Block.Unwrap(ifInst.Parent) == ifInst && // only instruction in block if (Block.Unwrap(ifInst.Parent) == ifInst && // only instruction in block

2
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. /// 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. /// This function must return a non-null LdLoca for every use of a SupportedRefLocal.
/// </summary> /// </summary>
static LdLoca GetAddressLoadForRefLocalUse(LdLoc ldloc) static LdLoca? GetAddressLoadForRefLocalUse(LdLoc ldloc)
{ {
if (!ldloc.Variable.IsSingleDefinition) if (!ldloc.Variable.IsSingleDefinition)
return null; // only single-definition variables can be supported ref locals return null; // only single-definition variables can be supported ref locals

10
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) switch (v.Kind)
{ {
@ -265,7 +265,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
} }
} }
DisplayClass DetectDisplayClass(ILVariable v) DisplayClass? DetectDisplayClass(ILVariable v)
{ {
ITypeDefinition? definition; ITypeDefinition? definition;
if (v.Kind != VariableKind.StackSlot) 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)) if (v.StoreInstructions.Count != 1 || !(v.StoreInstructions[0] is StLoc store && store.Parent is Block initializerBlock && initializerBlock.Kind == BlockKind.ObjectInitializer))
return null; 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. /// 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. /// The if any of the variables/fields in the chain cannot be propagated, null is returned.
/// </summary> /// </summary>
ILVariable ResolveVariableToPropagate(ILInstruction value, IType? expectedType = null) ILVariable? ResolveVariableToPropagate(ILInstruction value, IType? expectedType = null)
{ {
ILVariable v; ILVariable v;
switch (value) 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, /// mcs likes to optimize closures in yield state machines away by moving the captured variables' fields into the state machine type,
/// We construct a <see cref="DisplayClass"/> that spans the whole method body. /// We construct a <see cref="DisplayClass"/> that spans the whole method body.
/// </summary> /// </summary>
DisplayClass HandleMonoStateMachine(ILFunction function, ILVariable thisVariable) DisplayClass? HandleMonoStateMachine(ILFunction function, ILVariable thisVariable)
{ {
if (!(function.StateMachineCompiledWithMono && thisVariable.IsThis())) if (!(function.StateMachineCompiledWithMono && thisVariable.IsThis()))
return null; return null;

6
ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs

@ -459,7 +459,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
if (!MatchArgumentList(invocation.Arguments[1], out var arguments)) if (!MatchArgumentList(invocation.Arguments[1], out var arguments))
arguments = new[] { invocation.Arguments[1] }; arguments = new[] { invocation.Arguments[1] };
ILInstruction Convert() ILInstruction? Convert()
{ {
Func<ILInstruction>[] toBeConverted = new Func<ILInstruction>[arguments.Count]; Func<ILInstruction>[] toBeConverted = new Func<ILInstruction>[arguments.Count];
for (int i = 0; i < arguments.Count; i++) for (int i = 0; i < arguments.Count; i++)
@ -683,7 +683,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return call.Arguments[0]; return call.Arguments[0];
} }
Func<ILInstruction>[] ConvertCallArguments(IList<ILInstruction> arguments, IMethod method) Func<ILInstruction>[]? ConvertCallArguments(IList<ILInstruction> arguments, IMethod method)
{ {
var converted = new Func<ILInstruction>[arguments.Count]; var converted = new Func<ILInstruction>[arguments.Count];
Debug.Assert(arguments.Count == method.Parameters.Count); Debug.Assert(arguments.Count == method.Parameters.Count);
@ -1359,7 +1359,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return (null, SpecialType.UnknownType); return (null, SpecialType.UnknownType);
} }
ILInstruction ConvertValue(ILInstruction value, ILInstruction context) ILInstruction? ConvertValue(ILInstruction value, ILInstruction context)
{ {
switch (value) switch (value)
{ {

4
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) /// if (call op_True(ldloc lhsVar)) ldloc lhsVar else call op_BitwiseOr(ldloc lhsVar, rhsInst)
/// -> user.logic op_BitwiseOr(ldloc lhsVar, rhsInst) /// -> user.logic op_BitwiseOr(ldloc lhsVar, rhsInst)
/// </summary> /// </summary>
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)) if (!MatchCondition(condition, out var lhsVar, out var conditionMethodName))
return null; return null;
@ -164,7 +164,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return result; return result;
} }
public static ILInstruction TransformDynamic(ILInstruction condition, ILInstruction trueInst, ILInstruction falseInst) public static ILInstruction? TransformDynamic(ILInstruction condition, ILInstruction trueInst, ILInstruction falseInst)
{ {
// Check condition: // Check condition:
System.Linq.Expressions.ExpressionType unaryOp; System.Linq.Expressions.ExpressionType unaryOp;

6
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) 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"; string dotnetExeName = (Environment.OSVersion.Platform == PlatformID.Unix) ? "dotnet" : "dotnet.exe";
foreach (var item in Environment.GetEnvironmentVariable("PATH").Split(Path.PathSeparator)) foreach (var item in Environment.GetEnvironmentVariable("PATH").Split(Path.PathSeparator))
@ -312,7 +312,7 @@ namespace ICSharpCode.Decompiler.Metadata
return null; return null;
} }
static unsafe string GetRealPath(string path, Encoding encoding) static unsafe string? GetRealPath(string path, Encoding encoding)
{ {
var bytes = encoding.GetBytes(path); var bytes = encoding.GetBytes(path);
fixed (byte* input = bytes) fixed (byte* input = bytes)

12
ICSharpCode.Decompiler/Metadata/LightJson/JsonValue.cs

@ -329,7 +329,7 @@ namespace LightJson
/// Gets this value as a String type. /// Gets this value as a String type.
/// </summary> /// </summary>
/// <value>This value as a String type.</value> /// <value>This value as a String type.</value>
public string AsString { public string? AsString {
get { get {
switch (this.Type) switch (this.Type)
{ {
@ -354,7 +354,7 @@ namespace LightJson
/// Gets this value as an JsonObject. /// Gets this value as an JsonObject.
/// </summary> /// </summary>
/// <value>This value as an JsonObject.</value> /// <value>This value as an JsonObject.</value>
public JsonObject AsJsonObject { public JsonObject? AsJsonObject {
get { get {
return this.IsJsonObject return this.IsJsonObject
? (JsonObject)this.reference ? (JsonObject)this.reference
@ -366,7 +366,7 @@ namespace LightJson
/// Gets this value as an JsonArray. /// Gets this value as an JsonArray.
/// </summary> /// </summary>
/// <value>This value as an JsonArray.</value> /// <value>This value as an JsonArray.</value>
public JsonArray AsJsonArray { public JsonArray? AsJsonArray {
get { get {
return this.IsJsonArray return this.IsJsonArray
? (JsonArray)this.reference ? (JsonArray)this.reference
@ -397,7 +397,7 @@ namespace LightJson
/// Gets this (inner) value as a System.object. /// Gets this (inner) value as a System.object.
/// </summary> /// </summary>
/// <value>This (inner) value as a System.object.</value> /// <value>This (inner) value as a System.object.</value>
public object AsObject { public object? AsObject {
get { get {
switch (this.Type) switch (this.Type)
{ {
@ -808,7 +808,7 @@ namespace LightJson
} }
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public JsonObject ObjectView { public JsonObject? ObjectView {
get { get {
if (this.jsonValue.IsJsonObject) if (this.jsonValue.IsJsonObject)
{ {
@ -822,7 +822,7 @@ namespace LightJson
} }
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public JsonArray ArrayView { public JsonArray? ArrayView {
get { get {
if (this.jsonValue.IsJsonArray) if (this.jsonValue.IsJsonArray)
{ {

2
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); var docProvider = XmlDocLoader.LoadDocumentation(entity.ParentModule.MetadataFile);
if (docProvider == null) if (docProvider == null)

10
ICSharpCode.Decompiler/Output/TextTokenWriter.cs

@ -108,7 +108,7 @@ namespace ICSharpCode.Decompiler
output.Write(name); output.Write(name);
} }
ISymbol GetCurrentMemberReference() ISymbol? GetCurrentMemberReference()
{ {
AstNode node = nodeStack.Peek(); AstNode node = nodeStack.Peek();
var symbol = node.GetSymbol(); var symbol = node.GetSymbol();
@ -130,7 +130,7 @@ namespace ICSharpCode.Decompiler
return FilterMember(symbol); return FilterMember(symbol);
} }
ISymbol FilterMember(ISymbol symbol) ISymbol? FilterMember(ISymbol symbol)
{ {
if (symbol == null) if (symbol == null)
return null; return null;
@ -141,7 +141,7 @@ namespace ICSharpCode.Decompiler
return symbol; return symbol;
} }
object GetCurrentLocalReference() object? GetCurrentLocalReference()
{ {
AstNode node = nodeStack.Peek(); AstNode node = nodeStack.Peek();
ILVariable variable = node.Annotation<ILVariableResolveResult>()?.Variable; ILVariable variable = node.Annotation<ILVariableResolveResult>()?.Variable;
@ -169,7 +169,7 @@ namespace ICSharpCode.Decompiler
return null; return null;
} }
object GetCurrentLocalDefinition(Identifier id) object? GetCurrentLocalDefinition(Identifier id)
{ {
AstNode node = nodeStack.Peek(); AstNode node = nodeStack.Peek();
if (node is Identifier && node.Parent != null) if (node is Identifier && node.Parent != null)
@ -213,7 +213,7 @@ namespace ICSharpCode.Decompiler
return null; return null;
} }
ISymbol GetCurrentDefinition() ISymbol? GetCurrentDefinition()
{ {
if (nodeStack == null || nodeStack.Count == 0) if (nodeStack == null || nodeStack.Count == 0)
return null; return null;

2
ICSharpCode.Decompiler/Semantics/LocalResolveResult.cs

@ -62,7 +62,7 @@ namespace ICSharpCode.Decompiler.Semantics
get { return variable.IsConst; } get { return variable.IsConst; }
} }
public override object ConstantValue { public override object? ConstantValue {
get { return IsParameter ? null : variable.GetConstantValue(); } get { return IsParameter ? null : variable.GetConstantValue(); }
} }

2
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 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) if ((module.TypeSystemOptions & TypeSystemOptions.FunctionPointers) != 0)
{ {

2
ICSharpCode.Decompiler/TypeSystem/Implementation/AttributeListBuilder.cs

@ -283,7 +283,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return false; 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()); Debug.Assert(attribute.IsCustomAttribute());
foreach (var h in customAttributes) foreach (var h in customAttributes)

2
ICSharpCode.Decompiler/TypeSystem/Implementation/CustomAttribute.cs

@ -109,7 +109,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
} }
} }
internal static IMember MemberForNamedArgument(IType attributeType, CustomAttributeNamedArgument<IType> namedArgument) internal static IMember? MemberForNamedArgument(IType attributeType, CustomAttributeNamedArgument<IType> namedArgument)
{ {
switch (namedArgument.Kind) switch (namedArgument.Kind)
{ {

2
ICSharpCode.Decompiler/TypeSystem/Implementation/DecimalConstantHelper.cs

@ -32,7 +32,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return attributeHandles.HasKnownAttribute(module.metadata, KnownAttribute.DecimalConstant); 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; var metadata = module.metadata;
foreach (var attributeHandle in attributeHandles) foreach (var attributeHandle in attributeHandles)

2
ICSharpCode.Decompiler/TypeSystem/Implementation/DefaultAssemblyReference.cs

@ -39,7 +39,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
shortName = assemblyName; shortName = assemblyName;
} }
public IModule Resolve(ITypeResolveContext context) public IModule? Resolve(ITypeResolveContext context)
{ {
IModule current = context.CurrentModule; IModule current = context.CurrentModule;
if (current != null && string.Equals(shortName, current.AssemblyName, StringComparison.OrdinalIgnoreCase)) if (current != null && string.Equals(shortName, current.AssemblyName, StringComparison.OrdinalIgnoreCase))

2
ICSharpCode.Decompiler/TypeSystem/Implementation/DummyTypeParameter.cs

@ -163,7 +163,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
get { return VarianceModifier.Invariant; } get { return VarianceModifier.Invariant; }
} }
IEntity ITypeParameter.Owner { IEntity? ITypeParameter.Owner {
get { return null; } get { return null; }
} }

4
ICSharpCode.Decompiler/TypeSystem/Implementation/FakeMember.cs

@ -63,7 +63,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
IEnumerable<IAttribute> IEntity.GetAttributes() => EmptyList<IAttribute>.Instance; IEnumerable<IAttribute> IEntity.GetAttributes() => EmptyList<IAttribute>.Instance;
bool IEntity.HasAttribute(KnownAttribute attribute) => false; 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; public Accessibility Accessibility { get; set; } = Accessibility.Public;
@ -114,7 +114,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
bool IField.IsVolatile => false; bool IField.IsVolatile => false;
bool IVariable.IsConst => false; bool IVariable.IsConst => false;
object IVariable.GetConstantValue(bool throwOnInvalidMetadata) => null; object? IVariable.GetConstantValue(bool throwOnInvalidMetadata) => null;
IType IVariable.Type => ReturnType; IType IVariable.Type => ReturnType;
public override SymbolKind SymbolKind => SymbolKind.Field; public override SymbolKind SymbolKind => SymbolKind.Field;

2
ICSharpCode.Decompiler/TypeSystem/Implementation/GetClassTypeReference.cs

@ -84,7 +84,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
/// </summary> /// </summary>
public FullTypeName FullTypeName { get { return fullTypeName; } } 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) foreach (var asm in compilation.Modules)
{ {

2
ICSharpCode.Decompiler/TypeSystem/Implementation/MergedNamespace.cs

@ -108,7 +108,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
get { return GetChildNamespaces().Values; } get { return GetChildNamespaces().Values; }
} }
public INamespace GetChildNamespace(string name) public INamespace? GetChildNamespace(string name)
{ {
INamespace ns; INamespace ns;
if (GetChildNamespaces().TryGetValue(name, out ns)) if (GetChildNamespaces().TryGetValue(name, out ns))

2
ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataNamespace.cs

@ -86,7 +86,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
ICompilation ICompilationProvider.Compilation => module.Compilation; ICompilation ICompilationProvider.Compilation => module.Compilation;
INamespace INamespace.GetChildNamespace(string name) INamespace? INamespace.GetChildNamespace(string name)
{ {
foreach (var ns in ChildNamespaces) foreach (var ns in ChildNamespaces)
{ {

2
ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataParameter.cs

@ -156,7 +156,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
bool IVariable.IsConst => false; bool IVariable.IsConst => false;
public object GetConstantValue(bool throwOnInvalidMetadata) public object? GetConstantValue(bool throwOnInvalidMetadata)
{ {
try try
{ {

2
ICSharpCode.Decompiler/TypeSystem/Implementation/SpecializedMember.cs

@ -59,7 +59,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
this.substitution = TypeParameterSubstitution.Compose(newSubstitution, this.substitution); 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) if (accessorDefinition == null)
return null; return null;

6
ICSharpCode.Decompiler/TypeSystem/InheritanceHelper.cs

@ -109,7 +109,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// <summary> /// <summary>
/// Finds the member declared in 'derivedType' that has the same signature (could override) 'baseMember'. /// Finds the member declared in 'derivedType' that has the same signature (could override) 'baseMember'.
/// </summary> /// </summary>
public static IMember GetDerivedMember(IMember baseMember, ITypeDefinition derivedType) public static IMember? GetDerivedMember(IMember baseMember, ITypeDefinition derivedType)
{ {
if (baseMember == null) if (baseMember == null)
throw new ArgumentNullException(nameof(baseMember)); 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()) foreach (var baseType in typeDef.GetNonInterfaceBaseTypes().Reverse())
{ {
@ -217,7 +217,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
} while (member.IsOverride && (member = InheritanceHelper.GetBaseMember(member)) != null); } 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<IMember> visitedMembers = new HashSet<IMember>(); HashSet<IMember> visitedMembers = new HashSet<IMember>();
do do

22
ICSharpCode.Decompiler/TypeSystem/MetadataModule.cs

@ -192,7 +192,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return LazyInit.GetOrSet(ref this.internalsVisibleTo, result); return LazyInit.GetOrSet(ref this.internalsVisibleTo, result);
} }
static string GetShortName(string fullAssemblyName) static string? GetShortName(string fullAssemblyName)
{ {
if (fullAssemblyName == null) if (fullAssemblyName == null)
return null; return null;
@ -217,7 +217,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
} }
} }
public ITypeDefinition GetDefinition(TypeDefinitionHandle handle) public ITypeDefinition? GetDefinition(TypeDefinitionHandle handle)
{ {
if (handle.IsNil) if (handle.IsNil)
return null; return null;
@ -233,7 +233,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return LazyInit.GetOrSet(ref typeDefs[row], typeDef); return LazyInit.GetOrSet(ref typeDefs[row], typeDef);
} }
public IField GetDefinition(FieldDefinitionHandle handle) public IField? GetDefinition(FieldDefinitionHandle handle)
{ {
if (handle.IsNil) if (handle.IsNil)
return null; return null;
@ -249,7 +249,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return LazyInit.GetOrSet(ref fieldDefs[row], field); return LazyInit.GetOrSet(ref fieldDefs[row], field);
} }
public IMethod GetDefinition(MethodDefinitionHandle handle) public IMethod? GetDefinition(MethodDefinitionHandle handle)
{ {
if (handle.IsNil) if (handle.IsNil)
return null; return null;
@ -266,7 +266,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return LazyInit.GetOrSet(ref methodDefs[row], method); return LazyInit.GetOrSet(ref methodDefs[row], method);
} }
public IProperty GetDefinition(PropertyDefinitionHandle handle) public IProperty? GetDefinition(PropertyDefinitionHandle handle)
{ {
if (handle.IsNil) if (handle.IsNil)
return null; return null;
@ -283,7 +283,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return LazyInit.GetOrSet(ref propertyDefs[row], property); return LazyInit.GetOrSet(ref propertyDefs[row], property);
} }
public IEvent GetDefinition(EventDefinitionHandle handle) public IEvent? GetDefinition(EventDefinitionHandle handle)
{ {
if (handle.IsNil) if (handle.IsNil)
return null; return null;
@ -308,7 +308,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
#region Resolve Module #region Resolve Module
public IModule ResolveModule(AssemblyReferenceHandle handle) public IModule? ResolveModule(AssemblyReferenceHandle handle)
{ {
if (handle.IsNil) if (handle.IsNil)
return null; return null;
@ -332,7 +332,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return Compilation.FindModuleByReference(asmRef); return Compilation.FindModuleByReference(asmRef);
} }
public IModule ResolveModule(ModuleReferenceHandle handle) public IModule? ResolveModule(ModuleReferenceHandle handle)
{ {
if (handle.IsNil) if (handle.IsNil)
return null; return null;
@ -348,7 +348,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return null; return null;
} }
public IModule GetDeclaringModule(TypeReferenceHandle handle) public IModule? GetDeclaringModule(TypeReferenceHandle handle)
{ {
if (handle.IsNil) if (handle.IsNil)
return null; return null;
@ -747,7 +747,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// * May return specialized members, where generics are involved. /// * May return specialized members, where generics are involved.
/// * Other types of handles that don't correspond to TS entities, will return <c>null</c>. /// * Other types of handles that don't correspond to TS entities, will return <c>null</c>.
/// </remarks> /// </remarks>
public IEntity ResolveEntity(EntityHandle entityHandle, GenericContext context = default) public IEntity? ResolveEntity(EntityHandle entityHandle, GenericContext context = default)
{ {
switch (entityHandle.Kind) switch (entityHandle.Kind)
{ {
@ -904,7 +904,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
} }
return new UnknownType(typeName); return new UnknownType(typeName);
IModule ResolveModule(ExportedType type) IModule? ResolveModule(ExportedType type)
{ {
switch (type.Implementation.Kind) switch (type.Implementation.Kind)
{ {

2
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); 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; int nestingLevel = 0;
while (pos < reflectionTypeName.Length) while (pos < reflectionTypeName.Length)

2
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. /// Construct a tuple type (without element names) from the given underlying type.
/// Returns null if the input is not a valid underlying type. /// Returns null if the input is not a valid underlying type.
/// </summary> /// </summary>
public static TupleType FromUnderlyingType(ICompilation compilation, IType type) public static TupleType? FromUnderlyingType(ICompilation compilation, IType type)
{ {
var elementTypes = GetTupleElementTypes(type); var elementTypes = GetTupleElementTypes(type);
if (elementTypes.Length > 0) if (elementTypes.Length > 0)

2
ICSharpCode.Decompiler/TypeSystem/TypeProvider.cs

@ -160,7 +160,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return type ?? new UnknownType(fullTypeName, IsReferenceType(reader, handle, rawTypeKind)); return type ?? new UnknownType(fullTypeName, IsReferenceType(reader, handle, rawTypeKind));
} }
public IType GetTypeFromSerializedName(string name) public IType? GetTypeFromSerializedName(string name)
{ {
if (name == null) if (name == null)
{ {

12
ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs

@ -354,7 +354,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// <remarks> /// <remarks>
/// Returns null if the type is not a delegate type; or if the invoke method could not be found. /// Returns null if the type is not a delegate type; or if the invoke method could not be found.
/// </remarks> /// </remarks>
public static IMethod GetDelegateInvokeMethod(this IType type) public static IMethod? GetDelegateInvokeMethod(this IType type)
{ {
if (type == null) if (type == null)
throw new ArgumentNullException(nameof(type)); throw new ArgumentNullException(nameof(type));
@ -461,7 +461,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// Gets the type definition for the specified unresolved type. /// Gets the type definition for the specified unresolved type.
/// Returns null if the unresolved type does not belong to this assembly. /// Returns null if the unresolved type does not belong to this assembly.
/// </summary> /// </summary>
public static ITypeDefinition GetTypeDefinition(this IModule module, FullTypeName fullTypeName) public static ITypeDefinition? GetTypeDefinition(this IModule module, FullTypeName fullTypeName)
{ {
if (module == null) if (module == null)
throw new ArgumentNullException("assembly"); throw new ArgumentNullException("assembly");
@ -481,7 +481,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return typeDef; 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) foreach (var nestedType in typeDef.NestedTypes)
{ {
@ -626,7 +626,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
#endregion #endregion
#region ResolveResult #region ResolveResult
public static ISymbol GetSymbol(this ResolveResult rr) public static ISymbol? GetSymbol(this ResolveResult rr)
{ {
if (rr is LocalResolveResult) if (rr is LocalResolveResult)
{ {
@ -713,7 +713,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return false; 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) 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)) if (string.IsNullOrEmpty(name))
return compilation.RootNamespace; return compilation.RootNamespace;

2
ICSharpCode.Decompiler/Util/CSharpPrimitiveCast.cs

@ -34,7 +34,7 @@ namespace ICSharpCode.Decompiler.Util
/// </summary> /// </summary>
/// <exception cref="OverflowException">Overflow checking is enabled and an overflow occurred.</exception> /// <exception cref="OverflowException">Overflow checking is enabled and an overflow occurred.</exception>
/// <exception cref="InvalidCastException">The cast is invalid, e.g. casting a boolean to an integer.</exception> /// <exception cref="InvalidCastException">The cast is invalid, e.g. casting a boolean to an integer.</exception>
public static object Cast(TypeCode targetType, object input, bool checkForOverflow) public static object? Cast(TypeCode targetType, object input, bool checkForOverflow)
{ {
if (input == null) if (input == null)
return null; return null;

2
ILSpy/Analyzers/TreeNodes/AnalyzedModuleTreeNode.cs

@ -64,6 +64,6 @@ namespace ICSharpCode.ILSpy.Analyzers.TreeNodes
MainWindow.Instance.JumpToReference(analyzedModule.MetadataFile); MainWindow.Instance.JumpToReference(analyzedModule.MetadataFile);
} }
public override IEntity Member => null; public override IEntity? Member => null;
} }
} }

2
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 #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 rootPath = Path.GetDirectoryName(typeof(App).Assembly.Location);
var assemblyFileName = Path.Combine(rootPath, assemblyName.Name + ".dll"); var assemblyFileName = Path.Combine(rootPath, assemblyName.Name + ".dll");

2
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. /// - (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. /// - n backslashes not followed by a quotation mark simply produce n backslashes.
/// </remarks> /// </remarks>
public static string ArgumentArrayToCommandLine(params string[] arguments) public static string? ArgumentArrayToCommandLine(params string[] arguments)
{ {
if (arguments == null) if (arguments == null)
return null; return null;

2
ILSpy/Commands/CopyFullyQualifiedNameContextMenuEntry.cs

@ -42,7 +42,7 @@ namespace ICSharpCode.ILSpy
Clipboard.SetText(member.ReflectionName); 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; return context.SelectedTreeNodes?.Length == 1 ? context.SelectedTreeNodes[0] as IMemberTreeNode : null;
} }

2
ILSpy/Commands/SaveCodeContextMenuEntry.cs

@ -101,7 +101,7 @@ namespace ICSharpCode.ILSpy.TextView
/// will be used.</param> /// will be used.</param>
/// ///
/// <returns>The full path of the selected target file, or <c>null</c> if the user canceled.</returns> /// <returns>The full path of the selected target file, or <c>null</c> if the user canceled.</returns>
static string SelectSolutionFile() static string? SelectSolutionFile()
{ {
SaveFileDialog dlg = new SaveFileDialog(); SaveFileDialog dlg = new SaveFileDialog();
dlg.FileName = "Solution.sln"; dlg.FileName = "Solution.sln";

2
ILSpy/Commands/ScopeSearchToNamespace.cs

@ -75,7 +75,7 @@ namespace ICSharpCode.ILSpy
return GetNamespace(context) != null; return GetNamespace(context) != null;
} }
string GetNamespace(TextViewContext context) string? GetNamespace(TextViewContext context)
{ {
if (context.Reference?.Reference is IEntity entity) if (context.Reference?.Reference is IEntity entity)
return entity.Namespace; return entity.Namespace;

2
ILSpy/Controls/ExtensionMethods.cs

@ -60,7 +60,7 @@ namespace ICSharpCode.ILSpy.Controls
this.targetProperty = property; this.targetProperty = property;
} }
public object GetService(Type serviceType) public object? GetService(Type serviceType)
{ {
if (serviceType == typeof(IProvideValueTarget)) if (serviceType == typeof(IProvideValueTarget))
return this; return this;

2
ILSpy/Controls/TreeView/LinesRenderer.cs

@ -32,7 +32,7 @@ namespace ICSharpCode.ILSpy.Controls.TreeView
static Pen pen; static Pen pen;
SharpTreeNodeView NodeView { SharpTreeNodeView? NodeView {
get { return TemplatedParent as SharpTreeNodeView; } get { return TemplatedParent as SharpTreeNodeView; }
} }

2
ILSpy/Controls/TreeView/SharpTreeNodeView.cs

@ -43,7 +43,7 @@ namespace ICSharpCode.ILSpy.Controls.TreeView
set { SetValue(TextBackgroundProperty, value); } set { SetValue(TextBackgroundProperty, value); }
} }
public SharpTreeNode Node { public SharpTreeNode? Node {
get { return DataContext as SharpTreeNode; } get { return DataContext as SharpTreeNode; }
} }

4
ILSpy/Controls/TreeView/SharpTreeView.cs

@ -420,7 +420,7 @@ namespace ICSharpCode.ILSpy.Controls.TreeView
base.ScrollIntoView(node); base.ScrollIntoView(node);
} }
object OnFocusItem(object item) object? OnFocusItem(object item)
{ {
FrameworkElement element = this.ItemContainerGenerator.ContainerFromItem(item) as FrameworkElement; FrameworkElement element = this.ItemContainerGenerator.ContainerFromItem(item) as FrameworkElement;
if (element != null) if (element != null)
@ -531,7 +531,7 @@ namespace ICSharpCode.ILSpy.Controls.TreeView
public int Index; public int Index;
} }
DropTarget GetDropTarget(SharpTreeViewItem item, DragEventArgs e) DropTarget? GetDropTarget(SharpTreeViewItem item, DragEventArgs e)
{ {
var dropTargets = BuildDropTargets(item, e); var dropTargets = BuildDropTargets(item, e);
var y = e.GetPosition(item).Y; var y = e.GetPosition(item).Y;

2
ILSpy/Controls/TreeView/SharpTreeViewItem.cs

@ -34,7 +34,7 @@ namespace ICSharpCode.ILSpy.Controls.TreeView
new FrameworkPropertyMetadata(typeof(SharpTreeViewItem))); new FrameworkPropertyMetadata(typeof(SharpTreeViewItem)));
} }
public SharpTreeNode Node { public SharpTreeNode? Node {
get { return DataContext as SharpTreeNode; } get { return DataContext as SharpTreeNode; }
} }

2
ILSpy/Docking/DockLayoutSettings.cs

@ -77,7 +77,7 @@ namespace ICSharpCode.ILSpy.Docking
} }
} }
public XElement SaveAsXml() public XElement? SaveAsXml()
{ {
try try
{ {

2
ILSpy/Languages/CSharpBracketSearcher.cs

@ -33,7 +33,7 @@ namespace ICSharpCode.ILSpy
string openingBrackets = "([{"; string openingBrackets = "([{";
string closingBrackets = ")]}"; string closingBrackets = ")]}";
public BracketSearchResult SearchBracket(IDocument document, int offset) public BracketSearchResult? SearchBracket(IDocument document, int offset)
{ {
if (offset > 0) if (offset > 0)
{ {

4
ILSpy/Languages/CSharpHighlightingTokenWriter.cs

@ -474,7 +474,7 @@ namespace ICSharpCode.ILSpy
} }
} }
ISymbol GetCurrentDefinition() ISymbol? GetCurrentDefinition()
{ {
if (nodeStack == null || nodeStack.Count == 0) if (nodeStack == null || nodeStack.Count == 0)
return null; return null;
@ -488,7 +488,7 @@ namespace ICSharpCode.ILSpy
return null; return null;
} }
ISymbol GetCurrentMemberReference() ISymbol? GetCurrentMemberReference()
{ {
if (nodeStack == null || nodeStack.Count == 0) if (nodeStack == null || nodeStack.Count == 0)
return null; return null;

4
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(); var module = assembly.GetMetadataFileOrNull();
if (module == null) 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; MetadataReader metadata = module.Metadata;
switch (handle.Kind) switch (handle.Kind)

4
ILSpy/Languages/ILLanguage.cs

@ -163,7 +163,7 @@ namespace ICSharpCode.ILSpy
dis.DisassembleNamespace(nameSpace, module, types.Select(t => (TypeDefinitionHandle)t.MetadataToken)); 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("// " + assembly.FileName);
output.WriteLine(); output.WriteLine();
@ -195,7 +195,7 @@ namespace ICSharpCode.ILSpy
return null; return null;
} }
public override RichText GetRichTextTooltip(IEntity entity) public override RichText? GetRichTextTooltip(IEntity entity)
{ {
var output = new AvalonEditTextOutput() { IgnoreNewLineAndIndent = true }; var output = new AvalonEditTextOutput() { IgnoreNewLineAndIndent = true };
var disasm = CreateDisassembler(output, MainWindow.Instance.CreateDecompilationOptions()); var disasm = CreateDisassembler(output, MainWindow.Instance.CreateDecompilationOptions());

6
ILSpy/Languages/Language.cs

@ -52,7 +52,7 @@ namespace ICSharpCode.ILSpy
/// </summary> /// </summary>
public abstract string FileExtension { get; } public abstract string FileExtension { get; }
public virtual string ProjectFileExtension { public virtual string? ProjectFileExtension {
get { return null; } get { return null; }
} }
@ -107,7 +107,7 @@ namespace ICSharpCode.ILSpy
WriteCommentLine(output, nameSpace); 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); WriteCommentLine(output, assembly.FileName);
var asm = assembly.GetMetadataFileOrNull(); var asm = assembly.GetMetadataFileOrNull();
@ -478,7 +478,7 @@ namespace ICSharpCode.ILSpy
/// <summary> /// <summary>
/// This should produce a string representation of the entity for search to match search strings against. /// This should produce a string representation of the entity for search to match search strings against.
/// </summary> /// </summary>
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; MetadataReader metadata = module.Metadata;
switch (handle.Kind) switch (handle.Kind)

12
ILSpy/MainWindow.xaml.cs

@ -83,7 +83,7 @@ namespace ICSharpCode.ILSpy
get { return instance; } get { return instance; }
} }
public SharpTreeView AssemblyTreeView { public SharpTreeView? AssemblyTreeView {
get { get {
return FindResource("AssemblyTreeView") as SharpTreeView; 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)) if (string.IsNullOrEmpty(key))
{ {
@ -1109,7 +1109,7 @@ namespace ICSharpCode.ILSpy
/// <summary> /// <summary>
/// Retrieves a node using the .ToString() representations of its ancestors. /// Retrieves a node using the .ToString() representations of its ancestors.
/// </summary> /// </summary>
public SharpTreeNode FindNodeByPath(string[] path, bool returnBestMatch) public SharpTreeNode? FindNodeByPath(string[] path, bool returnBestMatch)
{ {
if (path == null) if (path == null)
return null; return null;
@ -1135,7 +1135,7 @@ namespace ICSharpCode.ILSpy
/// <summary> /// <summary>
/// Gets the .ToString() representation of the node's ancestors. /// Gets the .ToString() representation of the node's ancestors.
/// </summary> /// </summary>
public static string[] GetPathForNode(SharpTreeNode node) public static string[]? GetPathForNode(SharpTreeNode node)
{ {
if (node == null) if (node == null)
return null; return null;
@ -1149,7 +1149,7 @@ namespace ICSharpCode.ILSpy
return path.ToArray(); return path.ToArray();
} }
public ILSpyTreeNode FindTreeNode(object reference) public ILSpyTreeNode? FindTreeNode(object reference)
{ {
switch (reference) switch (reference)
{ {
@ -1586,7 +1586,7 @@ namespace ICSharpCode.ILSpy
sessionSettings.Save(); sessionSettings.Save();
} }
private string GetAutoLoadedAssemblyNode(SharpTreeNode node) private string? GetAutoLoadedAssemblyNode(SharpTreeNode node)
{ {
if (node == null) if (node == null)
return null; return null;

2
ILSpy/Metadata/CoffHeaderTreeNode.cs

@ -116,7 +116,7 @@ namespace ICSharpCode.ILSpy.Metadata
this.detailsFieldName = detailsFieldName; this.detailsFieldName = detailsFieldName;
} }
public override DataTemplate SelectTemplate(object item, DependencyObject container) public override DataTemplate? SelectTemplate(object item, DependencyObject container)
{ {
if (((Entry)item).Member == detailsFieldName) if (((Entry)item).Member == detailsFieldName)
return (DataTemplate)MetadataTableViews.Instance["HeaderFlagsDetailsDataGrid"]; return (DataTemplate)MetadataTableViews.Instance["HeaderFlagsDetailsDataGrid"];

2
ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs

@ -89,7 +89,7 @@ namespace ICSharpCode.ILSpy.Metadata
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int PublicKeyOrToken => MetadataTokens.GetHeapOffset(assemblyRef.PublicKeyOrToken); public int PublicKeyOrToken => MetadataTokens.GetHeapOffset(assemblyRef.PublicKeyOrToken);
public string PublicKeyOrTokenTooltip { public string? PublicKeyOrTokenTooltip {
get { get {
if (assemblyRef.PublicKeyOrToken.IsNil) if (assemblyRef.PublicKeyOrToken.IsNil)
return null; return null;

2
ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs

@ -97,7 +97,7 @@ namespace ICSharpCode.ILSpy.Metadata
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int Value => MetadataTokens.GetHeapOffset(constant.Value); public int Value => MetadataTokens.GetHeapOffset(constant.Value);
public string ValueTooltip { public string? ValueTooltip {
get { get {
return null; return null;
} }

2
ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs

@ -103,7 +103,7 @@ namespace ICSharpCode.ILSpy.Metadata
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int Value => MetadataTokens.GetHeapOffset(customAttr.Value); public int Value => MetadataTokens.GetHeapOffset(customAttr.Value);
public string ValueTooltip { public string? ValueTooltip {
get { get {
return null; return null;
} }

2
ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs

@ -102,7 +102,7 @@ namespace ICSharpCode.ILSpy.Metadata
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int PermissionSet => MetadataTokens.GetHeapOffset(declSecAttr.PermissionSet); public int PermissionSet => MetadataTokens.GetHeapOffset(declSecAttr.PermissionSet);
public string PermissionSetTooltip { public string? PermissionSetTooltip {
get { get {
return null; return null;
} }

2
ILSpy/Metadata/CorTables/FileTableTreeNode.cs

@ -90,7 +90,7 @@ namespace ICSharpCode.ILSpy.Metadata
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int HashValue => MetadataTokens.GetHeapOffset(assemblyFile.HashValue); public int HashValue => MetadataTokens.GetHeapOffset(assemblyFile.HashValue);
public string HashValueTooltip { public string? HashValueTooltip {
get { get {
if (assemblyFile.HashValue.IsNil) if (assemblyFile.HashValue.IsNil)
return null; return null;

2
ILSpy/Metadata/CorTables/MethodTableTreeNode.cs

@ -122,7 +122,7 @@ namespace ICSharpCode.ILSpy.Metadata
} }
string paramListTooltip; string paramListTooltip;
public string ParamListTooltip { public string? ParamListTooltip {
get { get {
var param = methodDef.GetParameters().FirstOrDefault(); var param = methodDef.GetParameters().FirstOrDefault();
if (param.IsNil) if (param.IsNil)

4
ILSpy/Metadata/CorTables/ModuleTableTreeNode.cs

@ -83,12 +83,12 @@ namespace ICSharpCode.ILSpy.Metadata
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int GenerationId => MetadataTokens.GetHeapOffset(moduleDef.GenerationId); 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)] [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int BaseGenerationId => MetadataTokens.GetHeapOffset(moduleDef.BaseGenerationId); 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) public ModuleEntry(MetadataFile metadataFile, ModuleDefinitionHandle handle)
{ {

6
ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs

@ -114,7 +114,7 @@ namespace ICSharpCode.ILSpy.Metadata
MainWindow.Instance.JumpToReference(new EntityReference(metadataFile, typeDef.BaseType, protocol: "metadata")); MainWindow.Instance.JumpToReference(new EntityReference(metadataFile, typeDef.BaseType, protocol: "metadata"));
} }
public string BaseTypeTooltip { public string? BaseTypeTooltip {
get { get {
var output = new PlainTextOutput(); var output = new PlainTextOutput();
var provider = new DisassemblerSignatureTypeProvider(metadataFile, output); var provider = new DisassemblerSignatureTypeProvider(metadataFile, output);
@ -146,7 +146,7 @@ namespace ICSharpCode.ILSpy.Metadata
} }
string fieldListTooltip; string fieldListTooltip;
public string FieldListTooltip { public string? FieldListTooltip {
get { get {
var field = typeDef.GetFields().FirstOrDefault(); var field = typeDef.GetFields().FirstOrDefault();
if (field.IsNil) if (field.IsNil)
@ -164,7 +164,7 @@ namespace ICSharpCode.ILSpy.Metadata
} }
string methodListTooltip; string methodListTooltip;
public string MethodListTooltip { public string? MethodListTooltip {
get { get {
var method = typeDef.GetMethods().FirstOrDefault(); var method = typeDef.GetMethods().FirstOrDefault();
if (method.IsNil) if (method.IsNil)

2
ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs

@ -243,7 +243,7 @@ namespace ICSharpCode.ILSpy.Metadata
object rowDetails; object rowDetails;
public object RowDetails { public object? RowDetails {
get { get {
if (rowDetails != null) if (rowDetails != null)
return rowDetails; return rowDetails;

6
ILSpy/Metadata/DebugTables/DocumentTableTreeNode.cs

@ -84,7 +84,7 @@ namespace ICSharpCode.ILSpy.Metadata
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int HashAlgorithm => MetadataTokens.GetHeapOffset(document.HashAlgorithm); public int HashAlgorithm => MetadataTokens.GetHeapOffset(document.HashAlgorithm);
public string HashAlgorithmTooltip { public string? HashAlgorithmTooltip {
get { get {
if (document.HashAlgorithm.IsNil) if (document.HashAlgorithm.IsNil)
return null; return null;
@ -100,7 +100,7 @@ namespace ICSharpCode.ILSpy.Metadata
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int Hash => MetadataTokens.GetHeapOffset(document.Hash); public int Hash => MetadataTokens.GetHeapOffset(document.Hash);
public string HashTooltip { public string? HashTooltip {
get { get {
if (document.Hash.IsNil) if (document.Hash.IsNil)
return null; return null;
@ -112,7 +112,7 @@ namespace ICSharpCode.ILSpy.Metadata
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)] [ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int Language => MetadataTokens.GetHeapOffset(document.Language); public int Language => MetadataTokens.GetHeapOffset(document.Language);
public string LanguageTooltip { public string? LanguageTooltip {
get { get {
if (document.Language.IsNil) if (document.Language.IsNil)
return null; return null;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save