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

2
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -265,7 +265,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -265,7 +265,7 @@ namespace ICSharpCode.Decompiler.CSharp
}
}
internal ILFunction ResolveLocalFunction(IMethod method)
internal ILFunction? ResolveLocalFunction(IMethod method)
{
Debug.Assert(method.IsLocalFunction);
method = (IMethod)((IMethod)method.MemberDefinition).ReducedFrom.MemberDefinition;

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

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

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

@ -79,7 +79,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler @@ -79,7 +79,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler
/// </summary>
public bool IsPortableClassLibrary { get; }
static string GetTargetFrameworkMoniker(string frameworkIdentifier, int version)
static string? GetTargetFrameworkMoniker(string frameworkIdentifier, int version)
{
// Reference: https://docs.microsoft.com/en-us/dotnet/standard/frameworks
switch (frameworkIdentifier)

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

@ -488,7 +488,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler @@ -488,7 +488,7 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler
const int RT_ICON = 3;
const int RT_GROUP_ICON = 14;
unsafe static byte[] CreateApplicationIcon(Win32ResourceDirectory resources)
unsafe static byte[]? CreateApplicationIcon(Win32ResourceDirectory resources)
{
var iconGroup = resources.Find(new Win32ResourceName(RT_GROUP_ICON))?.FirstDirectory()?.FirstData()?.Data;
if (iconGroup == null)

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

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

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

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

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

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

2
ICSharpCode.Decompiler/CSharp/Resolver/TypeInference.cs

@ -698,7 +698,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -698,7 +698,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
}
}
TP GetTPForType(IType v)
TP? GetTPForType(IType v)
{
if (v is NullabilityAnnotatedTypeParameter natp)
{

2
ICSharpCode.Decompiler/CSharp/StatementBuilder.cs

@ -624,7 +624,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -624,7 +624,7 @@ namespace ICSharpCode.Decompiler.CSharp
}
}
Statement TransformToForeach(UsingInstruction inst, Expression resource)
Statement? TransformToForeach(UsingInstruction inst, Expression resource)
{
if (!settings.ForEachStatement)
{

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

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

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

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

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

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

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

@ -1443,7 +1443,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -1443,7 +1443,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
const float MathF_PI = 3.14159274f;
const float MathF_E = 2.71828175f;
Expression TryExtractExpression(IType mathType, IType type, object literalValue, string memberName, bool isDouble)
Expression? TryExtractExpression(IType mathType, IType type, object literalValue, string memberName, bool isDouble)
{
Expression MakeFieldReference()
{
@ -1464,7 +1464,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -1464,7 +1464,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return new CastExpression(ConvertType(type), fieldRef);
}
Expression ExtractExpression(long n, long d)
Expression? ExtractExpression(long n, long d)
{
Expression fieldReference = MakeFieldReference();
@ -2400,7 +2400,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -2400,7 +2400,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return decl;
}
internal Constraint ConvertTypeParameterConstraint(ITypeParameter tp)
internal Constraint? ConvertTypeParameterConstraint(ITypeParameter tp)
{
if (!tp.HasDefaultConstructorConstraint && !tp.HasReferenceTypeConstraint && !tp.HasValueTypeConstraint && tp.NullabilityConstraint != Nullability.NotNullable && tp.DirectBaseTypes.All(IsObjectOrValueType))
{

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

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

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

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

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

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

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

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

4
ICSharpCode.Decompiler/Disassembler/DisassemblerHelpers.cs

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

2
ICSharpCode.Decompiler/Documentation/IdStringMemberReference.cs

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

4
ICSharpCode.Decompiler/Documentation/XmlDocLoader.cs

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

14
ICSharpCode.Decompiler/Documentation/XmlDocumentationProvider.cs

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

10
ICSharpCode.Decompiler/FlowAnalysis/DataFlowVisitor.cs

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

4
ICSharpCode.Decompiler/Humanizer/Vocabulary.cs

@ -119,7 +119,7 @@ namespace Humanizer.Inflections @@ -119,7 +119,7 @@ namespace Humanizer.Inflections
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)
{
@ -164,7 +164,7 @@ namespace Humanizer.Inflections @@ -164,7 +164,7 @@ namespace Humanizer.Inflections
_replacement = replacement;
}
public string Apply(string word)
public string? Apply(string word)
{
if (!_regex.IsMatch(word))
{

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

@ -311,7 +311,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -311,7 +311,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
/// 3) otherwise (exit point unknown, heuristically extend loop): null
/// </returns>
/// <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);
if (!hasReachableExit)

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

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

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

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

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

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

2
ICSharpCode.Decompiler/IL/PointerArithmeticOffset.cs

@ -35,7 +35,7 @@ namespace ICSharpCode.Decompiler.IL @@ -35,7 +35,7 @@ namespace ICSharpCode.Decompiler.IL
/// <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="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 unwrapZeroExtension = false)
{

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

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

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

@ -30,7 +30,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -30,7 +30,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
ExpressionTransforms.RunOnSingleStatement(combinedExit, context);
}
static Leave CombineExits(Block block)
static Leave? CombineExits(Block block)
{
if (!(block.Instructions.SecondToLastOrDefault() is IfInstruction ifInst && block.Instructions.LastOrDefault() is Leave leaveElse))
return null;

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

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

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

@ -80,7 +80,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -80,7 +80,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
internal static bool MatchDelegateConstruction(ILInstruction inst, out IMethod? targetMethod,
internal static bool MatchDelegateConstruction(ILInstruction? inst, out IMethod? targetMethod,
[NotNullWhen(true)] out ILInstruction? target, [NotNullWhen(true)] out IType? delegateType, bool allowTransformed = false)
{
targetMethod = null;
@ -165,7 +165,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -165,7 +165,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return new GenericContext(classTypeParameters, methodTypeParameters);
}
ILFunction TransformDelegateConstruction(
ILFunction? TransformDelegateConstruction(
ILInstruction value, IMethod targetMethod,
ILInstruction target, IType delegateType)
{

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

@ -147,7 +147,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -147,7 +147,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
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)
{

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -176,7 +176,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -176,7 +176,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// Main entry point for lifting; called by both the expression-transform
/// and the block transform.
/// </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;
// but can also be a BinaryNumericInstruction.
@ -479,7 +479,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -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)
{

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

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

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

@ -175,7 +175,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -175,7 +175,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// Given 'ldloc ref_local' and 'ldloca target; stloc ref_local', returns the ldloca.
/// This function must return a non-null LdLoca for every use of a SupportedRefLocal.
/// </summary>
static LdLoca GetAddressLoadForRefLocalUse(LdLoc ldloc)
static LdLoca? GetAddressLoadForRefLocalUse(LdLoc ldloc)
{
if (!ldloc.Variable.IsSingleDefinition)
return null; // only single-definition variables can be supported ref locals

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

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

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

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

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

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

6
ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs

@ -211,7 +211,7 @@ namespace ICSharpCode.Decompiler.Metadata @@ -211,7 +211,7 @@ namespace ICSharpCode.Decompiler.Metadata
}
}
public string TryResolveDotNetCoreShared(IAssemblyReference name, out string? runtimePack)
public string? TryResolveDotNetCoreShared(IAssemblyReference name, out string? runtimePack)
{
if (dotnetBasePath == null)
{
@ -286,7 +286,7 @@ namespace ICSharpCode.Decompiler.Metadata @@ -286,7 +286,7 @@ namespace ICSharpCode.Decompiler.Metadata
}
}
public static string FindDotNetExeDirectory()
public static string? FindDotNetExeDirectory()
{
string dotnetExeName = (Environment.OSVersion.Platform == PlatformID.Unix) ? "dotnet" : "dotnet.exe";
foreach (var item in Environment.GetEnvironmentVariable("PATH").Split(Path.PathSeparator))
@ -312,7 +312,7 @@ namespace ICSharpCode.Decompiler.Metadata @@ -312,7 +312,7 @@ namespace ICSharpCode.Decompiler.Metadata
return null;
}
static unsafe string GetRealPath(string path, Encoding encoding)
static unsafe string? GetRealPath(string path, Encoding encoding)
{
var bytes = encoding.GetBytes(path);
fixed (byte* input = bytes)

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

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

2
ICSharpCode.Decompiler/NRExtensions.cs

@ -92,7 +92,7 @@ namespace ICSharpCode.Decompiler @@ -92,7 +92,7 @@ namespace ICSharpCode.Decompiler
}
}
internal static string GetDocumentation(this IEntity entity)
internal static string? GetDocumentation(this IEntity entity)
{
var docProvider = XmlDocLoader.LoadDocumentation(entity.ParentModule.MetadataFile);
if (docProvider == null)

10
ICSharpCode.Decompiler/Output/TextTokenWriter.cs

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

2
ICSharpCode.Decompiler/Semantics/LocalResolveResult.cs

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

2
ICSharpCode.Decompiler/TypeSystem/FunctionPointerType.cs

@ -123,7 +123,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -123,7 +123,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
public override TypeKind Kind => ((module.TypeSystemOptions & TypeSystemOptions.FunctionPointers) != 0) ? TypeKind.FunctionPointer : TypeKind.Struct;
public override ITypeDefinition GetDefinition()
public override ITypeDefinition? GetDefinition()
{
if ((module.TypeSystemOptions & TypeSystemOptions.FunctionPointers) != 0)
{

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

@ -283,7 +283,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -283,7 +283,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return false;
}
internal IAttribute GetAttribute(MetadataReader metadata, CustomAttributeHandleCollection customAttributes, KnownAttribute attribute, SymbolKind symbolKind)
internal IAttribute? GetAttribute(MetadataReader metadata, CustomAttributeHandleCollection customAttributes, KnownAttribute attribute, SymbolKind symbolKind)
{
Debug.Assert(attribute.IsCustomAttribute());
foreach (var h in customAttributes)

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

@ -109,7 +109,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -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)
{

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

@ -32,7 +32,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -32,7 +32,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return attributeHandles.HasKnownAttribute(module.metadata, KnownAttribute.DecimalConstant);
}
public static object GetDecimalConstantValue(MetadataModule module, CustomAttributeHandleCollection attributeHandles)
public static object? GetDecimalConstantValue(MetadataModule module, CustomAttributeHandleCollection attributeHandles)
{
var metadata = module.metadata;
foreach (var attributeHandle in attributeHandles)

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

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

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

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

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

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

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

@ -84,7 +84,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -84,7 +84,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
/// </summary>
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)
{

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

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

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

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

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

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

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

@ -59,7 +59,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation @@ -59,7 +59,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
this.substitution = TypeParameterSubstitution.Compose(newSubstitution, this.substitution);
}
internal IMethod WrapAccessor(ref IMethod cachingField, IMethod accessorDefinition)
internal IMethod? WrapAccessor(ref IMethod cachingField, IMethod accessorDefinition)
{
if (accessorDefinition == null)
return null;

6
ICSharpCode.Decompiler/TypeSystem/InheritanceHelper.cs

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

22
ICSharpCode.Decompiler/TypeSystem/MetadataModule.cs

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

2
ICSharpCode.Decompiler/TypeSystem/ReflectionHelper.cs

@ -442,7 +442,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -442,7 +442,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return new GetClassTypeReference(assemblyReference, typeName.Substring(0, pos), typeName.Substring(pos + 1), tpc);
}
static string SkipAheadAndReadAssemblyName(string reflectionTypeName, int pos)
static string? SkipAheadAndReadAssemblyName(string reflectionTypeName, int pos)
{
int nestingLevel = 0;
while (pos < reflectionTypeName.Length)

2
ICSharpCode.Decompiler/TypeSystem/TupleType.cs

@ -144,7 +144,7 @@ namespace ICSharpCode.Decompiler.TypeSystem @@ -144,7 +144,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// Construct a tuple type (without element names) from the given underlying type.
/// Returns null if the input is not a valid underlying type.
/// </summary>
public static TupleType FromUnderlyingType(ICompilation compilation, IType type)
public static TupleType? FromUnderlyingType(ICompilation compilation, IType type)
{
var elementTypes = GetTupleElementTypes(type);
if (elementTypes.Length > 0)

2
ICSharpCode.Decompiler/TypeSystem/TypeProvider.cs

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

12
ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs

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

2
ICSharpCode.Decompiler/Util/CSharpPrimitiveCast.cs

@ -34,7 +34,7 @@ namespace ICSharpCode.Decompiler.Util @@ -34,7 +34,7 @@ namespace ICSharpCode.Decompiler.Util
/// </summary>
/// <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>
public static object Cast(TypeCode targetType, object input, bool checkForOverflow)
public static object? Cast(TypeCode targetType, object input, bool checkForOverflow)
{
if (input == null)
return null;

2
ILSpy/Analyzers/TreeNodes/AnalyzedModuleTreeNode.cs

@ -64,6 +64,6 @@ namespace ICSharpCode.ILSpy.Analyzers.TreeNodes @@ -64,6 +64,6 @@ namespace ICSharpCode.ILSpy.Analyzers.TreeNodes
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 @@ -122,7 +122,7 @@ namespace ICSharpCode.ILSpy
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
}
static Assembly ResolvePluginDependencies(AssemblyLoadContext context, AssemblyName assemblyName)
static Assembly? ResolvePluginDependencies(AssemblyLoadContext context, AssemblyName assemblyName)
{
var rootPath = Path.GetDirectoryName(typeof(App).Assembly.Location);
var assemblyFileName = Path.Combine(rootPath, assemblyName.Name + ".dll");

2
ILSpy/AppEnv/CommandLineTools.cs

@ -56,7 +56,7 @@ namespace ICSharpCode.ILSpy.AppEnv @@ -56,7 +56,7 @@ namespace ICSharpCode.ILSpy.AppEnv
/// - (2n) + 1 backslashes followed by a quotation mark again produce n backslashes followed by a quotation mark.
/// - n backslashes not followed by a quotation mark simply produce n backslashes.
/// </remarks>
public static string ArgumentArrayToCommandLine(params string[] arguments)
public static string? ArgumentArrayToCommandLine(params string[] arguments)
{
if (arguments == null)
return null;

2
ILSpy/Commands/CopyFullyQualifiedNameContextMenuEntry.cs

@ -42,7 +42,7 @@ namespace ICSharpCode.ILSpy @@ -42,7 +42,7 @@ namespace ICSharpCode.ILSpy
Clipboard.SetText(member.ReflectionName);
}
private IMemberTreeNode GetMemberNodeFromContext(TextViewContext context)
private IMemberTreeNode? GetMemberNodeFromContext(TextViewContext context)
{
return context.SelectedTreeNodes?.Length == 1 ? context.SelectedTreeNodes[0] as IMemberTreeNode : null;
}

2
ILSpy/Commands/SaveCodeContextMenuEntry.cs

@ -101,7 +101,7 @@ namespace ICSharpCode.ILSpy.TextView @@ -101,7 +101,7 @@ namespace ICSharpCode.ILSpy.TextView
/// will be used.</param>
///
/// <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();
dlg.FileName = "Solution.sln";

2
ILSpy/Commands/ScopeSearchToNamespace.cs

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

2
ILSpy/Controls/ExtensionMethods.cs

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

2
ILSpy/Controls/TreeView/LinesRenderer.cs

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

2
ILSpy/Controls/TreeView/SharpTreeNodeView.cs

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

4
ILSpy/Controls/TreeView/SharpTreeView.cs

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

2
ILSpy/Controls/TreeView/SharpTreeViewItem.cs

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

2
ILSpy/Docking/DockLayoutSettings.cs

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

2
ILSpy/Languages/CSharpBracketSearcher.cs

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

4
ILSpy/Languages/CSharpHighlightingTokenWriter.cs

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

4
ILSpy/Languages/CSharpLanguage.cs

@ -418,7 +418,7 @@ namespace ICSharpCode.ILSpy @@ -418,7 +418,7 @@ namespace ICSharpCode.ILSpy
}
}
public override ProjectId DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
public override ProjectId? DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
{
var module = assembly.GetMetadataFileOrNull();
if (module == null)
@ -702,7 +702,7 @@ namespace ICSharpCode.ILSpy @@ -702,7 +702,7 @@ namespace ICSharpCode.ILSpy
}
}
public override string GetEntityName(MetadataFile module, EntityHandle handle, bool fullName, bool omitGenerics)
public override string? GetEntityName(MetadataFile module, EntityHandle handle, bool fullName, bool omitGenerics)
{
MetadataReader metadata = module.Metadata;
switch (handle.Kind)

4
ILSpy/Languages/ILLanguage.cs

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

6
ILSpy/Languages/Language.cs

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

12
ILSpy/MainWindow.xaml.cs

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

2
ILSpy/Metadata/CoffHeaderTreeNode.cs

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

2
ILSpy/Metadata/CorTables/AssemblyRefTableTreeNode.cs

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

2
ILSpy/Metadata/CorTables/ConstantTableTreeNode.cs

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

2
ILSpy/Metadata/CorTables/CustomAttributeTableTreeNode.cs

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

2
ILSpy/Metadata/CorTables/DeclSecurityTableTreeNode.cs

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

2
ILSpy/Metadata/CorTables/FileTableTreeNode.cs

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

2
ILSpy/Metadata/CorTables/MethodTableTreeNode.cs

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

4
ILSpy/Metadata/CorTables/ModuleTableTreeNode.cs

@ -83,12 +83,12 @@ namespace ICSharpCode.ILSpy.Metadata @@ -83,12 +83,12 @@ namespace ICSharpCode.ILSpy.Metadata
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int GenerationId => MetadataTokens.GetHeapOffset(moduleDef.GenerationId);
public string GenerationIdTooltip => moduleDef.GenerationId.IsNil ? null : metadataFile.Metadata.GetGuid(moduleDef.GenerationId).ToString();
public string? GenerationIdTooltip => moduleDef.GenerationId.IsNil ? null : metadataFile.Metadata.GetGuid(moduleDef.GenerationId).ToString();
[ColumnInfo("X8", Kind = ColumnKind.HeapOffset)]
public int BaseGenerationId => MetadataTokens.GetHeapOffset(moduleDef.BaseGenerationId);
public string BaseGenerationIdTooltip => moduleDef.BaseGenerationId.IsNil ? null : metadataFile.Metadata.GetGuid(moduleDef.BaseGenerationId).ToString();
public string? BaseGenerationIdTooltip => moduleDef.BaseGenerationId.IsNil ? null : metadataFile.Metadata.GetGuid(moduleDef.BaseGenerationId).ToString();
public ModuleEntry(MetadataFile metadataFile, ModuleDefinitionHandle handle)
{

6
ILSpy/Metadata/CorTables/TypeDefTableTreeNode.cs

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

2
ILSpy/Metadata/DebugTables/CustomDebugInformationTableTreeNode.cs

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

6
ILSpy/Metadata/DebugTables/DocumentTableTreeNode.cs

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

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

Loading…
Cancel
Save