Browse Source

focus on CS8625, convert to error

pull/3287/head
apmoskevitz 11 months ago
parent
commit
0430c3b519
  1. 32
      .editorconfig
  2. 10
      ICSharpCode.BamlDecompiler/BamlElement.cs
  3. 2
      ICSharpCode.BamlDecompiler/Handlers/Blocks/ConstructorParametersHandler.cs
  4. 2
      ICSharpCode.BamlDecompiler/Handlers/Blocks/DocumentHandler.cs
  5. 2
      ICSharpCode.BamlDecompiler/Handlers/Blocks/ElementHandler.cs
  6. 2
      ICSharpCode.BamlDecompiler/Handlers/Blocks/KeyElementStartHandler.cs
  7. 2
      ICSharpCode.BamlDecompiler/Handlers/Blocks/PropertyArrayHandler.cs
  8. 2
      ICSharpCode.BamlDecompiler/Handlers/Blocks/PropertyComplexHandler.cs
  9. 2
      ICSharpCode.BamlDecompiler/Handlers/Blocks/PropertyDictionaryHandler.cs
  10. 2
      ICSharpCode.BamlDecompiler/Handlers/Blocks/PropertyListHandler.cs
  11. 2
      ICSharpCode.BamlDecompiler/Handlers/Records/AssemblyInfoHandler.cs
  12. 2
      ICSharpCode.BamlDecompiler/Handlers/Records/AttributeInfoHandler.cs
  13. 2
      ICSharpCode.BamlDecompiler/Handlers/Records/ConnectionIdHandler.cs
  14. 2
      ICSharpCode.BamlDecompiler/Handlers/Records/ConstructorParameterTypeHandler.cs
  15. 2
      ICSharpCode.BamlDecompiler/Handlers/Records/ContentPropertyHandler.cs
  16. 2
      ICSharpCode.BamlDecompiler/Handlers/Records/DefAttributeHandler.cs
  17. 2
      ICSharpCode.BamlDecompiler/Handlers/Records/DefAttributeKeyStringHandler.cs
  18. 2
      ICSharpCode.BamlDecompiler/Handlers/Records/DefAttributeKeyTypeHandler.cs
  19. 2
      ICSharpCode.BamlDecompiler/Handlers/Records/DeferableContentStartHandler.cs
  20. 2
      ICSharpCode.BamlDecompiler/Handlers/Records/LineNumberAndPositionHandler.cs
  21. 2
      ICSharpCode.BamlDecompiler/Handlers/Records/LinePositionHandler.cs
  22. 2
      ICSharpCode.BamlDecompiler/Handlers/Records/LiteralContentHandler.cs
  23. 2
      ICSharpCode.BamlDecompiler/Handlers/Records/OptimizedStaticResourceHandler.cs
  24. 2
      ICSharpCode.BamlDecompiler/Handlers/Records/PIMappingHandler.cs
  25. 2
      ICSharpCode.BamlDecompiler/Handlers/Records/PresentationOptionsAttributeHandler.cs
  26. 2
      ICSharpCode.BamlDecompiler/Handlers/Records/PropertyCustomHandler.cs
  27. 2
      ICSharpCode.BamlDecompiler/Handlers/Records/PropertyHandler.cs
  28. 5
      ICSharpCode.BamlDecompiler/Handlers/Records/PropertyTypeReferenceHandler.cs
  29. 2
      ICSharpCode.BamlDecompiler/Handlers/Records/PropertyWithExtensionHandler.cs
  30. 6
      ICSharpCode.BamlDecompiler/Handlers/Records/PropertyWithStaticResourceIdHandler.cs
  31. 6
      ICSharpCode.BamlDecompiler/Handlers/Records/StaticResourceIdHandler.cs
  32. 2
      ICSharpCode.BamlDecompiler/Handlers/Records/StaticResourceStartHandler.cs
  33. 4
      ICSharpCode.BamlDecompiler/Handlers/Records/TextHandler.cs
  34. 4
      ICSharpCode.BamlDecompiler/Handlers/Records/TypeInfoHandler.cs
  35. 2
      ICSharpCode.BamlDecompiler/Handlers/Records/XmlnsPropertyHandler.cs
  36. 2
      ICSharpCode.BamlDecompiler/IHandlers.cs
  37. 2
      ICSharpCode.BamlDecompiler/Rewrite/ConnectionIdRewritePass.cs
  38. 6
      ICSharpCode.BamlDecompiler/Xaml/NamespaceMap.cs
  39. 2
      ICSharpCode.BamlDecompiler/Xaml/XamlProperty.cs
  40. 6
      ICSharpCode.BamlDecompiler/Xaml/XamlResourceKey.cs
  41. 4
      ICSharpCode.BamlDecompiler/Xaml/XamlType.cs
  42. 9
      ICSharpCode.BamlDecompiler/XamlContext.cs
  43. 5
      ICSharpCode.BamlDecompiler/XmlnsDictionary.cs
  44. 2
      ICSharpCode.Decompiler.PowerShell/GetDecompiledProjectCmdlet.cs
  45. 2
      ICSharpCode.Decompiler.Tests/Semantics/OverloadResolutionTests.cs
  46. 4
      ICSharpCode.Decompiler/CSharp/OutputVisitor/ITokenWriter.cs
  47. 2
      ICSharpCode.Decompiler/CSharp/OutputVisitor/InsertMissingTokensDecorator.cs
  48. 2
      ICSharpCode.Decompiler/CSharp/OutputVisitor/InsertRequiredSpacesDecorator.cs
  49. 4
      ICSharpCode.Decompiler/CSharp/OutputVisitor/InsertSpecialsDecorator.cs
  50. 2
      ICSharpCode.Decompiler/CSharp/OutputVisitor/TextWriterTokenWriter.cs
  51. 8
      ICSharpCode.Decompiler/CSharp/Resolver/AwaitResolveResult.cs
  52. 8
      ICSharpCode.Decompiler/CSharp/Resolver/CSharpConversions.cs
  53. 6
      ICSharpCode.Decompiler/CSharp/Resolver/CSharpResolver.cs
  54. 4
      ICSharpCode.Decompiler/CSharp/Resolver/LambdaResolveResult.cs
  55. 8
      ICSharpCode.Decompiler/CSharp/Resolver/MemberLookup.cs
  56. 6
      ICSharpCode.Decompiler/CSharp/Resolver/MethodGroupResolveResult.cs
  57. 8
      ICSharpCode.Decompiler/CSharp/Resolver/OverloadResolution.cs
  58. 10
      ICSharpCode.Decompiler/CSharp/Resolver/TypeInference.cs
  59. 2
      ICSharpCode.Decompiler/CSharp/SequencePointBuilder.cs
  60. 2
      ICSharpCode.Decompiler/CSharp/Syntax/CSharpTokenNode.cs
  61. 2
      ICSharpCode.Decompiler/CSharp/Syntax/Expressions/IndexerExpression.cs
  62. 8
      ICSharpCode.Decompiler/CSharp/Syntax/PatternMatching/Match.cs
  63. 6
      ICSharpCode.Decompiler/CSharp/Syntax/Role.cs
  64. 6
      ICSharpCode.Decompiler/CSharp/Transforms/ContextTrackingVisitor.cs
  65. 2
      ICSharpCode.Decompiler/CSharp/Transforms/DeclareVariables.cs
  66. 2
      ICSharpCode.Decompiler/CSharp/Transforms/NormalizeBlockStatements.cs
  67. 2
      ICSharpCode.Decompiler/CSharp/Transforms/PatternStatementTransform.cs
  68. 2
      ICSharpCode.Decompiler/CSharp/Transforms/PrettifyAssignments.cs
  69. 2
      ICSharpCode.Decompiler/CSharp/Transforms/ReplaceMethodCallsWithOperators.cs
  70. 4
      ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs
  71. 2
      ICSharpCode.Decompiler/DebugInfo/ImportScopeInfo.cs
  72. 2
      ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs
  73. 2
      ICSharpCode.Decompiler/Disassembler/OpCodeInfo.cs
  74. 10
      ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs
  75. 8
      ICSharpCode.Decompiler/FlowAnalysis/ControlFlowNode.cs
  76. 2
      ICSharpCode.Decompiler/FlowAnalysis/ReachingDefinitionsVisitor.cs
  77. 2
      ICSharpCode.Decompiler/IL/ControlFlow/DetectPinnedRegions.cs
  78. 2
      ICSharpCode.Decompiler/IL/ControlFlow/SwitchAnalysis.cs
  79. 8
      ICSharpCode.Decompiler/IL/ControlFlow/SwitchDetection.cs
  80. 14
      ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs
  81. 2
      ICSharpCode.Decompiler/IL/Instructions/DeconstructInstruction.cs
  82. 2
      ICSharpCode.Decompiler/IL/Transforms/DeconstructionTransform.cs
  83. 6
      ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs
  84. 2
      ICSharpCode.Decompiler/IL/Transforms/LockTransform.cs
  85. 2
      ICSharpCode.Decompiler/IL/Transforms/NullableLiftingTransform.cs
  86. 8
      ICSharpCode.Decompiler/IL/Transforms/ReduceNestingTransform.cs
  87. 2
      ICSharpCode.Decompiler/IL/Transforms/TransformArrayInitializers.cs
  88. 4
      ICSharpCode.Decompiler/IL/Transforms/TransformAssignment.cs
  89. 14
      ICSharpCode.Decompiler/IL/Transforms/TransformDisplayClassUsage.cs
  90. 18
      ICSharpCode.Decompiler/Metadata/LightJson/JsonValue.cs
  91. 2
      ICSharpCode.Decompiler/Output/TextTokenWriter.cs
  92. 4
      ICSharpCode.Decompiler/SRMExtensions.cs
  93. 2
      ICSharpCode.Decompiler/Semantics/InvocationResolveResult.cs
  94. 8
      ICSharpCode.Decompiler/TypeSystem/ApplyAttributeTypeVisitor.cs
  95. 2
      ICSharpCode.Decompiler/TypeSystem/FullTypeName.cs
  96. 6
      ICSharpCode.Decompiler/TypeSystem/Implementation/GetMembersHelper.cs
  97. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/MetadataNamespace.cs
  98. 2
      ICSharpCode.Decompiler/TypeSystem/Implementation/UnknownType.cs
  99. 14
      ICSharpCode.Decompiler/TypeSystem/TupleType.cs
  100. 14
      ICSharpCode.Decompiler/Util/ResXResourceWriter.cs
  101. Some files were not shown because too many files have changed in this diff Show More

32
.editorconfig

@ -151,9 +151,14 @@ dotnet_diagnostic.MEF006.severity = silent
dotnet_diagnostic.IDE2003.severity = silent dotnet_diagnostic.IDE2003.severity = silent
#cleared null error types #nullability diagnostics
dotnet_diagnostic.CS8597.severity = error dotnet_diagnostic.CS8597.severity = error
dotnet_diagnostic.CS8605.severity = error dotnet_diagnostic.CS8600.severity = warning
dotnet_diagnostic.CS8601.severity = warning
dotnet_diagnostic.CS8602.severity = warning
dotnet_diagnostic.CS8603.severity = warning
dotnet_diagnostic.CS8604.severity = warning
dotnet_diagnostic.CS8605.severity = warning
dotnet_diagnostic.CS8606.severity = error dotnet_diagnostic.CS8606.severity = error
dotnet_diagnostic.CS8607.severity = error dotnet_diagnostic.CS8607.severity = error
dotnet_diagnostic.CS8608.severity = error dotnet_diagnostic.CS8608.severity = error
@ -164,9 +169,16 @@ dotnet_diagnostic.CS8612.severity = error
dotnet_diagnostic.CS8613.severity = error dotnet_diagnostic.CS8613.severity = error
dotnet_diagnostic.CS8614.severity = error dotnet_diagnostic.CS8614.severity = error
dotnet_diagnostic.CS8615.severity = error dotnet_diagnostic.CS8615.severity = error
dotnet_diagnostic.CS8617.severity = warning
dotnet_diagnostic.CS8618.severity = warning
dotnet_diagnostic.CS8619.severity = warning
dotnet_diagnostic.CS8620.severity = warning
dotnet_diagnostic.CS8621.severity = error dotnet_diagnostic.CS8621.severity = error
dotnet_diagnostic.CS8622.severity = error dotnet_diagnostic.CS8622.severity = error
dotnet_diagnostic.CS8624.severity = error dotnet_diagnostic.CS8624.severity = error
dotnet_diagnostic.CS8625.severity = error
dotnet_diagnostic.CS8629.severity = warning
dotnet_diagnostic.CS8631.severity = warning
dotnet_diagnostic.CS8633.severity = error dotnet_diagnostic.CS8633.severity = error
dotnet_diagnostic.CS8634.severity = error dotnet_diagnostic.CS8634.severity = error
dotnet_diagnostic.CS8643.severity = error dotnet_diagnostic.CS8643.severity = error
@ -193,17 +205,5 @@ dotnet_diagnostic.CS8775.severity = error
dotnet_diagnostic.CS8777.severity = error dotnet_diagnostic.CS8777.severity = error
#nullable error types still not cleaned up #nullable error types still not cleaned up
dotnet_diagnostic.CS8600.severity = warning
dotnet_diagnostic.CS8601.severity = warning
dotnet_diagnostic.CS8602.severity = warning
dotnet_diagnostic.CS8603.severity = warning
dotnet_diagnostic.CS8604.severity = warning
dotnet_diagnostic.CS8605.severity = warning
dotnet_diagnostic.CS8615.severity = warning
dotnet_diagnostic.CS8617.severity = warning
dotnet_diagnostic.CS8618.severity = warning
dotnet_diagnostic.CS8619.severity = warning
dotnet_diagnostic.CS8620.severity = warning
dotnet_diagnostic.CS8625.severity = warning
dotnet_diagnostic.CS8629.severity = warning
dotnet_diagnostic.CS8631.severity = warning

10
ICSharpCode.BamlDecompiler/BamlElement.cs

@ -41,13 +41,13 @@ namespace ICSharpCode.BamlDecompiler
String = value; String = value;
} }
public readonly XElement Element; public readonly XElement? Element;
public readonly string String; public readonly string? String;
public static implicit operator XamlNode(XElement value) => new XamlNode(value); public static implicit operator XamlNode(XElement value) => new XamlNode(value);
public static implicit operator XamlNode(string value) => new XamlNode(value); public static implicit operator XamlNode(string value) => new XamlNode(value);
public static implicit operator XElement(XamlNode node) => node.Element; public static implicit operator XElement?(XamlNode node) => node.Element;
public static implicit operator string(XamlNode node) => node.String; public static implicit operator string?(XamlNode node) => node.String;
} }
internal class BamlElement internal class BamlElement
@ -55,7 +55,7 @@ namespace ICSharpCode.BamlDecompiler
public BamlNode Node { get; } public BamlNode Node { get; }
public XamlNode Xaml { get; set; } public XamlNode Xaml { get; set; }
public BamlElement Parent { get; set; } public BamlElement? Parent { get; set; }
public IList<BamlElement> Children { get; } public IList<BamlElement> Children { get; }
public BamlElement(BamlNode node) public BamlElement(BamlNode node)

2
ICSharpCode.BamlDecompiler/Handlers/Blocks/ConstructorParametersHandler.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.ConstructorParametersStart; public BamlRecordType Type => BamlRecordType.ConstructorParametersStart;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var doc = new BamlElement(node); var doc = new BamlElement(node);
doc.Xaml = new XElement(ctx.GetPseudoName("Ctor")); doc.Xaml = new XElement(ctx.GetPseudoName("Ctor"));

2
ICSharpCode.BamlDecompiler/Handlers/Blocks/DocumentHandler.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.DocumentStart; public BamlRecordType Type => BamlRecordType.DocumentStart;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var doc = new BamlElement(node); var doc = new BamlElement(node);
doc.Xaml = new XElement(ctx.GetPseudoName("Document")); doc.Xaml = new XElement(ctx.GetPseudoName("Document"));

2
ICSharpCode.BamlDecompiler/Handlers/Blocks/ElementHandler.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.ElementStart; public BamlRecordType Type => BamlRecordType.ElementStart;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (ElementStartRecord)((BamlBlockNode)node).Header; var record = (ElementStartRecord)((BamlBlockNode)node).Header;
var doc = new BamlElement(node); var doc = new BamlElement(node);

2
ICSharpCode.BamlDecompiler/Handlers/Blocks/KeyElementStartHandler.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
BamlRecordType IHandler.Type => BamlRecordType.KeyElementStart; BamlRecordType IHandler.Type => BamlRecordType.KeyElementStart;
BamlElement IHandler.Translate(XamlContext ctx, BamlNode node, BamlElement parent) BamlElement? IHandler.Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
XamlResourceKey.Create(node); XamlResourceKey.Create(node);
return null; return null;

2
ICSharpCode.BamlDecompiler/Handlers/Blocks/PropertyArrayHandler.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.PropertyArrayStart; public BamlRecordType Type => BamlRecordType.PropertyArrayStart;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (PropertyArrayStartRecord)((BamlBlockNode)node).Header; var record = (PropertyArrayStartRecord)((BamlBlockNode)node).Header;
var doc = new BamlElement(node); var doc = new BamlElement(node);

2
ICSharpCode.BamlDecompiler/Handlers/Blocks/PropertyComplexHandler.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.PropertyComplexStart; public BamlRecordType Type => BamlRecordType.PropertyComplexStart;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (PropertyComplexStartRecord)((BamlBlockNode)node).Header; var record = (PropertyComplexStartRecord)((BamlBlockNode)node).Header;
var doc = new BamlElement(node); var doc = new BamlElement(node);

2
ICSharpCode.BamlDecompiler/Handlers/Blocks/PropertyDictionaryHandler.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.PropertyDictionaryStart; public BamlRecordType Type => BamlRecordType.PropertyDictionaryStart;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (PropertyDictionaryStartRecord)((BamlBlockNode)node).Header; var record = (PropertyDictionaryStartRecord)((BamlBlockNode)node).Header;
var doc = new BamlElement(node); var doc = new BamlElement(node);

2
ICSharpCode.BamlDecompiler/Handlers/Blocks/PropertyListHandler.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.PropertyListStart; public BamlRecordType Type => BamlRecordType.PropertyListStart;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (PropertyListStartRecord)((BamlBlockNode)node).Header; var record = (PropertyListStartRecord)((BamlBlockNode)node).Header;
var doc = new BamlElement(node); var doc = new BamlElement(node);

2
ICSharpCode.BamlDecompiler/Handlers/Records/AssemblyInfoHandler.cs

@ -28,6 +28,6 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.AssemblyInfo; public BamlRecordType Type => BamlRecordType.AssemblyInfo;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) => null; public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent) => null;
} }
} }

2
ICSharpCode.BamlDecompiler/Handlers/Records/AttributeInfoHandler.cs

@ -28,6 +28,6 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.AttributeInfo; public BamlRecordType Type => BamlRecordType.AttributeInfo;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) => null; public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent) => null;
} }
} }

2
ICSharpCode.BamlDecompiler/Handlers/Records/ConnectionIdHandler.cs

@ -28,7 +28,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.ConnectionId; public BamlRecordType Type => BamlRecordType.ConnectionId;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (ConnectionIdRecord)((BamlRecordNode)node).Record; var record = (ConnectionIdRecord)((BamlRecordNode)node).Record;

2
ICSharpCode.BamlDecompiler/Handlers/Records/ConstructorParameterTypeHandler.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.ConstructorParameterType; public BamlRecordType Type => BamlRecordType.ConstructorParameterType;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (ConstructorParameterTypeRecord)((BamlRecordNode)node).Record; var record = (ConstructorParameterTypeRecord)((BamlRecordNode)node).Record;

2
ICSharpCode.BamlDecompiler/Handlers/Records/ContentPropertyHandler.cs

@ -28,7 +28,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.ContentProperty; public BamlRecordType Type => BamlRecordType.ContentProperty;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (ContentPropertyRecord)((BamlRecordNode)node).Record; var record = (ContentPropertyRecord)((BamlRecordNode)node).Record;
// TODO: What to do here? // TODO: What to do here?

2
ICSharpCode.BamlDecompiler/Handlers/Records/DefAttributeHandler.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.DefAttribute; public BamlRecordType Type => BamlRecordType.DefAttribute;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (DefAttributeRecord)((BamlRecordNode)node).Record; var record = (DefAttributeRecord)((BamlRecordNode)node).Record;

2
ICSharpCode.BamlDecompiler/Handlers/Records/DefAttributeKeyStringHandler.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.DefAttributeKeyString; public BamlRecordType Type => BamlRecordType.DefAttributeKeyString;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
XamlResourceKey.Create(node); XamlResourceKey.Create(node);
return null; return null;

2
ICSharpCode.BamlDecompiler/Handlers/Records/DefAttributeKeyTypeHandler.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.DefAttributeKeyType; public BamlRecordType Type => BamlRecordType.DefAttributeKeyType;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
XamlResourceKey.Create(node); XamlResourceKey.Create(node);
return null; return null;

2
ICSharpCode.BamlDecompiler/Handlers/Records/DeferableContentStartHandler.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.DeferableContentStart; public BamlRecordType Type => BamlRecordType.DeferableContentStart;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (DeferableContentStartRecord)((BamlRecordNode)node).Record; var record = (DeferableContentStartRecord)((BamlRecordNode)node).Record;

2
ICSharpCode.BamlDecompiler/Handlers/Records/LineNumberAndPositionHandler.cs

@ -28,6 +28,6 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.LineNumberAndPosition; public BamlRecordType Type => BamlRecordType.LineNumberAndPosition;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) => null; public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent) => null;
} }
} }

2
ICSharpCode.BamlDecompiler/Handlers/Records/LinePositionHandler.cs

@ -28,6 +28,6 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.LinePosition; public BamlRecordType Type => BamlRecordType.LinePosition;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) => null; public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent) => null;
} }
} }

2
ICSharpCode.BamlDecompiler/Handlers/Records/LiteralContentHandler.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.LiteralContent; public BamlRecordType Type => BamlRecordType.LiteralContent;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (LiteralContentRecord)((BamlRecordNode)node).Record; var record = (LiteralContentRecord)((BamlRecordNode)node).Record;

2
ICSharpCode.BamlDecompiler/Handlers/Records/OptimizedStaticResourceHandler.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.OptimizedStaticResource; public BamlRecordType Type => BamlRecordType.OptimizedStaticResource;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (OptimizedStaticResourceRecord)((BamlRecordNode)node).Record; var record = (OptimizedStaticResourceRecord)((BamlRecordNode)node).Record;
var key = XamlResourceKey.FindKeyInSiblings(node); var key = XamlResourceKey.FindKeyInSiblings(node);

2
ICSharpCode.BamlDecompiler/Handlers/Records/PIMappingHandler.cs

@ -28,6 +28,6 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.PIMapping; public BamlRecordType Type => BamlRecordType.PIMapping;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) => null; public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent) => null;
} }
} }

2
ICSharpCode.BamlDecompiler/Handlers/Records/PresentationOptionsAttributeHandler.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.PresentationOptionsAttribute; public BamlRecordType Type => BamlRecordType.PresentationOptionsAttribute;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (PresentationOptionsAttributeRecord)((BamlRecordNode)node).Record; var record = (PresentationOptionsAttributeRecord)((BamlRecordNode)node).Record;

2
ICSharpCode.BamlDecompiler/Handlers/Records/PropertyCustomHandler.cs

@ -179,7 +179,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
return property.IsAttachedTo(type); return property.IsAttachedTo(type);
} }
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (PropertyCustomRecord)((BamlRecordNode)node).Record; var record = (PropertyCustomRecord)((BamlRecordNode)node).Record;
var serTypeId = ((short)record.SerializerTypeId & 0xfff); var serTypeId = ((short)record.SerializerTypeId & 0xfff);

2
ICSharpCode.BamlDecompiler/Handlers/Records/PropertyHandler.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public virtual BamlRecordType Type => BamlRecordType.Property; public virtual BamlRecordType Type => BamlRecordType.Property;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (PropertyRecord)((BamlRecordNode)node).Record; var record = (PropertyRecord)((BamlRecordNode)node).Record;

5
ICSharpCode.BamlDecompiler/Handlers/Records/PropertyTypeReferenceHandler.cs

@ -22,10 +22,9 @@
using System.Xml.Linq; using System.Xml.Linq;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.BamlDecompiler.Baml; using ICSharpCode.BamlDecompiler.Baml;
using ICSharpCode.BamlDecompiler.Xaml; using ICSharpCode.BamlDecompiler.Xaml;
using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.BamlDecompiler.Handlers namespace ICSharpCode.BamlDecompiler.Handlers
{ {
@ -33,7 +32,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.PropertyTypeReference; public BamlRecordType Type => BamlRecordType.PropertyTypeReference;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (PropertyTypeReferenceRecord)((BamlRecordNode)node).Record; var record = (PropertyTypeReferenceRecord)((BamlRecordNode)node).Record;
var attr = ctx.ResolveProperty(record.AttributeId); var attr = ctx.ResolveProperty(record.AttributeId);

2
ICSharpCode.BamlDecompiler/Handlers/Records/PropertyWithExtensionHandler.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.PropertyWithExtension; public BamlRecordType Type => BamlRecordType.PropertyWithExtension;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (PropertyWithExtensionRecord)((BamlRecordNode)node).Record; var record = (PropertyWithExtensionRecord)((BamlRecordNode)node).Record;
var extTypeId = ((short)record.Flags & 0xfff); var extTypeId = ((short)record.Flags & 0xfff);

6
ICSharpCode.BamlDecompiler/Handlers/Records/PropertyWithStaticResourceIdHandler.cs

@ -32,7 +32,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.PropertyWithStaticResourceId; public BamlRecordType Type => BamlRecordType.PropertyWithStaticResourceId;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (PropertyWithStaticResourceIdRecord)((BamlRecordNode)node).Record; var record = (PropertyWithStaticResourceIdRecord)((BamlRecordNode)node).Record;
var doc = new BamlElement(node); var doc = new BamlElement(node);
@ -43,8 +43,8 @@ namespace ICSharpCode.BamlDecompiler.Handlers
doc.Xaml.Element.AddAnnotation(elemAttr); doc.Xaml.Element.AddAnnotation(elemAttr);
parent.Xaml.Element.Add(doc.Xaml.Element); parent.Xaml.Element.Add(doc.Xaml.Element);
BamlNode found = node; BamlNode? found = node;
XamlResourceKey key; XamlResourceKey? key;
do do
{ {
key = XamlResourceKey.FindKeyInAncestors(found.Parent, out found); key = XamlResourceKey.FindKeyInAncestors(found.Parent, out found);

6
ICSharpCode.BamlDecompiler/Handlers/Records/StaticResourceIdHandler.cs

@ -27,12 +27,12 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.StaticResourceId; public BamlRecordType Type => BamlRecordType.StaticResourceId;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (StaticResourceIdRecord)((BamlRecordNode)node).Record; var record = (StaticResourceIdRecord)((BamlRecordNode)node).Record;
BamlNode found = node; BamlNode? found = node;
XamlResourceKey key; XamlResourceKey? key;
do do
{ {
key = XamlResourceKey.FindKeyInAncestors(found.Parent, out found); key = XamlResourceKey.FindKeyInAncestors(found.Parent, out found);

2
ICSharpCode.BamlDecompiler/Handlers/Records/StaticResourceStartHandler.cs

@ -29,7 +29,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.StaticResourceStart; public BamlRecordType Type => BamlRecordType.StaticResourceStart;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (StaticResourceStartRecord)((BamlBlockNode)node).Record; var record = (StaticResourceStartRecord)((BamlBlockNode)node).Record;
var key = XamlResourceKey.FindKeyInSiblings(node); var key = XamlResourceKey.FindKeyInSiblings(node);

4
ICSharpCode.BamlDecompiler/Handlers/Records/TextHandler.cs

@ -28,7 +28,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.Text; public BamlRecordType Type => BamlRecordType.Text;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (TextRecord)((BamlRecordNode)node).Record; var record = (TextRecord)((BamlRecordNode)node).Record;
@ -42,7 +42,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.TextWithId; public BamlRecordType Type => BamlRecordType.TextWithId;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (TextWithIdRecord)((BamlRecordNode)node).Record; var record = (TextWithIdRecord)((BamlRecordNode)node).Record;

4
ICSharpCode.BamlDecompiler/Handlers/Records/TypeInfoHandler.cs

@ -28,13 +28,13 @@ namespace ICSharpCode.BamlDecompiler.Handlers
{ {
public BamlRecordType Type => BamlRecordType.TypeInfo; public BamlRecordType Type => BamlRecordType.TypeInfo;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) => null; public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent) => null;
} }
internal class TypeSerializerInfoHandler : IHandler internal class TypeSerializerInfoHandler : IHandler
{ {
public BamlRecordType Type => BamlRecordType.TypeSerializerInfo; public BamlRecordType Type => BamlRecordType.TypeSerializerInfo;
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) => null; public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent) => null;
} }
} }

2
ICSharpCode.BamlDecompiler/Handlers/Records/XmlnsPropertyHandler.cs

@ -52,7 +52,7 @@ namespace ICSharpCode.BamlDecompiler.Handlers
} }
} }
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) public BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent)
{ {
var record = (XmlnsPropertyRecord)((BamlRecordNode)node).Record; var record = (XmlnsPropertyRecord)((BamlRecordNode)node).Record;
foreach (var asmId in record.AssemblyIds) foreach (var asmId in record.AssemblyIds)

2
ICSharpCode.BamlDecompiler/IHandlers.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.BamlDecompiler
internal interface IHandler internal interface IHandler
{ {
BamlRecordType Type { get; } BamlRecordType Type { get; }
BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent); BamlElement? Translate(XamlContext ctx, BamlNode node, BamlElement? parent);
} }
internal interface IDeferHandler internal interface IDeferHandler

2
ICSharpCode.BamlDecompiler/Rewrite/ConnectionIdRewritePass.cs

@ -250,7 +250,7 @@ namespace ICSharpCode.BamlDecompiler.Rewrite
} }
} }
bool MatchFieldAssignment(ILInstruction inst, [NotNullWhen(true)] out FieldAssignment field) bool MatchFieldAssignment(ILInstruction inst, [NotNullWhen(true)] out FieldAssignment? field)
{ {
field = null; field = null;
if (!inst.MatchStFld(out _, out var fld, out var value) || !value.MatchCastClass(out var arg, out _) if (!inst.MatchStFld(out _, out var fld, out var value) || !value.MatchCastClass(out var arg, out _)

6
ICSharpCode.BamlDecompiler/Xaml/NamespaceMap.cs

@ -29,17 +29,17 @@ namespace ICSharpCode.BamlDecompiler.Xaml
{ {
internal class NamespaceMap internal class NamespaceMap
{ {
public string XmlnsPrefix { get; set; } public string? XmlnsPrefix { get; set; }
public string FullAssemblyName { get; set; } public string FullAssemblyName { get; set; }
public string XMLNamespace { get; set; } public string XMLNamespace { get; set; }
public string CLRNamespace { get; set; } public string? CLRNamespace { get; set; }
public NamespaceMap(string prefix, string fullAssemblyName, string xmlNs) public NamespaceMap(string prefix, string fullAssemblyName, string xmlNs)
: this(prefix, fullAssemblyName, xmlNs, null) : this(prefix, fullAssemblyName, xmlNs, null)
{ {
} }
public NamespaceMap(string prefix, string fullAssemblyName, string xmlNs, string clrNs) public NamespaceMap(string? prefix, string fullAssemblyName, string xmlNs, string? clrNs)
{ {
XmlnsPrefix = prefix; XmlnsPrefix = prefix;
FullAssemblyName = fullAssemblyName; FullAssemblyName = fullAssemblyName;

2
ICSharpCode.BamlDecompiler/Xaml/XamlProperty.cs

@ -82,7 +82,7 @@ namespace ICSharpCode.BamlDecompiler.Xaml
return true; return true;
} }
public XName ToXName(XamlContext ctx, XElement parent, bool isFullName = true) public XName ToXName(XamlContext ctx, XElement? parent, bool isFullName = true)
{ {
var typeName = DeclaringType.ToXName(ctx); var typeName = DeclaringType.ToXName(ctx);
XName name; XName name;

6
ICSharpCode.BamlDecompiler/Xaml/XamlResourceKey.cs

@ -78,7 +78,7 @@ namespace ICSharpCode.BamlDecompiler.Xaml
public BamlElement KeyElement { get; set; } public BamlElement KeyElement { get; set; }
public IList<BamlNode> StaticResources { get; } public IList<BamlNode> StaticResources { get; }
public static XamlResourceKey FindKeyInSiblings(BamlNode node) public static XamlResourceKey? FindKeyInSiblings(BamlNode node)
{ {
var children = node.Parent.Children; var children = node.Parent.Children;
var index = children.IndexOf(node); var index = children.IndexOf(node);
@ -90,9 +90,9 @@ namespace ICSharpCode.BamlDecompiler.Xaml
return null; return null;
} }
public static XamlResourceKey FindKeyInAncestors(BamlNode node) => FindKeyInAncestors(node, out var found); public static XamlResourceKey? FindKeyInAncestors(BamlNode node) => FindKeyInAncestors(node, out var found);
public static XamlResourceKey FindKeyInAncestors(BamlNode node, out BamlNode found) public static XamlResourceKey? FindKeyInAncestors(BamlNode node, out BamlNode? found)
{ {
BamlNode n = node; BamlNode n = node;
do do

4
ICSharpCode.BamlDecompiler/Xaml/XamlType.cs

@ -37,7 +37,7 @@ namespace ICSharpCode.BamlDecompiler.Xaml
public string TypeNamespace { get; } public string TypeNamespace { get; }
public string TypeName { get; } public string TypeName { get; }
public XNamespace Namespace { get; private set; } public XNamespace? Namespace { get; private set; }
public IType ResolvedType { get; set; } public IType ResolvedType { get; set; }
public XamlType(IModule assembly, string fullAssemblyName, string ns, string name) public XamlType(IModule assembly, string fullAssemblyName, string ns, string name)
@ -45,7 +45,7 @@ namespace ICSharpCode.BamlDecompiler.Xaml
{ {
} }
public XamlType(IModule assembly, string fullAssemblyName, string ns, string name, XNamespace xmlns) public XamlType(IModule assembly, string fullAssemblyName, string ns, string name, XNamespace? xmlns)
{ {
Assembly = assembly; Assembly = assembly;
FullAssemblyName = fullAssemblyName; FullAssemblyName = fullAssemblyName;

9
ICSharpCode.BamlDecompiler/XamlContext.cs

@ -27,10 +27,9 @@ using System.Reflection.Metadata;
using System.Threading; using System.Threading;
using System.Xml.Linq; using System.Xml.Linq;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.BamlDecompiler.Baml; using ICSharpCode.BamlDecompiler.Baml;
using ICSharpCode.BamlDecompiler.Xaml; using ICSharpCode.BamlDecompiler.Xaml;
using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.BamlDecompiler namespace ICSharpCode.BamlDecompiler
{ {
@ -207,8 +206,8 @@ namespace ICSharpCode.BamlDecompiler
continue; continue;
var xmlNs = attr.FixedArguments[0].Value as string; var xmlNs = attr.FixedArguments[0].Value as string;
var typeNs = attr.FixedArguments[1].Value as string; var typeNs = attr.FixedArguments[1].Value as string;
Debug.Assert((object)xmlNs != null && (object)typeNs != null); Debug.Assert((object?)xmlNs != null && (object?)typeNs != null);
if ((object)xmlNs == null || (object)typeNs == null) if ((object?)xmlNs == null || (object?)typeNs == null)
continue; continue;
if (typeNamespace == typeNs) if (typeNamespace == typeNs)
@ -221,7 +220,7 @@ namespace ICSharpCode.BamlDecompiler
return possibleXmlNs.FirstOrDefault(); return possibleXmlNs.FirstOrDefault();
} }
public XName GetKnownNamespace(string name, string xmlNamespace, XElement context = null) public XName GetKnownNamespace(string name, string xmlNamespace, XElement? context = null)
{ {
var xNs = GetXmlNamespace(xmlNamespace); var xNs = GetXmlNamespace(xmlNamespace);
XName xName; XName xName;

5
ICSharpCode.BamlDecompiler/XmlnsDictionary.cs

@ -22,11 +22,10 @@
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.BamlDecompiler.Xaml;
using ICSharpCode.Decompiler.Metadata; using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.BamlDecompiler.Xaml;
namespace ICSharpCode.BamlDecompiler namespace ICSharpCode.BamlDecompiler
{ {
internal class XmlnsScope : List<NamespaceMap> internal class XmlnsScope : List<NamespaceMap>
@ -58,7 +57,7 @@ namespace ICSharpCode.BamlDecompiler
public XmlnsDictionary() => CurrentScope = null; public XmlnsDictionary() => CurrentScope = null;
public XmlnsScope CurrentScope { get; set; } public XmlnsScope? CurrentScope { get; set; }
public void PushScope(BamlElement element) => CurrentScope = new XmlnsScope(CurrentScope, element); public void PushScope(BamlElement element) => CurrentScope = new XmlnsScope(CurrentScope, element);

2
ICSharpCode.Decompiler.PowerShell/GetDecompiledProjectCmdlet.cs

@ -25,7 +25,7 @@ namespace ICSharpCode.Decompiler.PowerShell
readonly object syncObject = new object(); readonly object syncObject = new object();
int completed; int completed;
string fileName; string fileName;
ProgressRecord progress; ProgressRecord? progress;
public void Report(DecompilationProgress value) public void Report(DecompilationProgress value)
{ {

2
ICSharpCode.Decompiler.Tests/Semantics/OverloadResolutionTests.cs

@ -258,7 +258,7 @@ namespace ICSharpCode.Decompiler.Tests.Semantics
get { throw new NotImplementedException(); } get { throw new NotImplementedException(); }
} }
public override IType GetInferredReturnType(IType[] parameterTypes) public override IType GetInferredReturnType(IType[]? parameterTypes)
{ {
return inferredReturnType; return inferredReturnType;
} }

4
ICSharpCode.Decompiler/CSharp/OutputVisitor/ITokenWriter.cs

@ -46,7 +46,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
/// <summary> /// <summary>
/// Writes a primitive/literal value /// Writes a primitive/literal value
/// </summary> /// </summary>
public abstract void WritePrimitiveValue(object value, LiteralFormat format = LiteralFormat.None); public abstract void WritePrimitiveValue(object? value, LiteralFormat format = LiteralFormat.None);
public abstract void WritePrimitiveType(string type); public abstract void WritePrimitiveType(string type);
@ -129,7 +129,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
decoratedWriter.WriteToken(role, token); decoratedWriter.WriteToken(role, token);
} }
public override void WritePrimitiveValue(object value, LiteralFormat format = LiteralFormat.None) public override void WritePrimitiveValue(object? value, LiteralFormat format = LiteralFormat.None)
{ {
decoratedWriter.WritePrimitiveValue(value, format); decoratedWriter.WritePrimitiveValue(value, format);
} }

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

@ -138,7 +138,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
base.WriteIdentifier(identifier); base.WriteIdentifier(identifier);
} }
public override void WritePrimitiveValue(object value, LiteralFormat format = LiteralFormat.None) public override void WritePrimitiveValue(object? value, LiteralFormat format = LiteralFormat.None)
{ {
Expression? node = nodes.Peek().LastOrDefault() as Expression; Expression? node = nodes.Peek().LastOrDefault() as Expression;
var startLocation = locationProvider.Location; var startLocation = locationProvider.Location;

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

@ -148,7 +148,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
lastWritten = LastWritten.Whitespace; lastWritten = LastWritten.Whitespace;
} }
public override void WritePrimitiveValue(object value, LiteralFormat format = LiteralFormat.None) public override void WritePrimitiveValue(object? value, LiteralFormat format = LiteralFormat.None)
{ {
if (lastWritten == LastWritten.KeywordOrIdentifier) if (lastWritten == LastWritten.KeywordOrIdentifier)
{ {

4
ICSharpCode.Decompiler/CSharp/OutputVisitor/InsertSpecialsDecorator.cs

@ -82,7 +82,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
/// <summary> /// <summary>
/// Writes all specials from start to end (exclusive). Does not touch the positionStack. /// Writes all specials from start to end (exclusive). Does not touch the positionStack.
/// </summary> /// </summary>
void WriteSpecials(AstNode start, AstNode end) void WriteSpecials(AstNode start, AstNode? end)
{ {
for (AstNode? pos = start; pos != end; pos = pos.NextSibling) for (AstNode? pos = start; pos != end; pos = pos.NextSibling)
{ {
@ -118,7 +118,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
WriteSpecialsUpToRole(role, null); WriteSpecialsUpToRole(role, null);
} }
void WriteSpecialsUpToRole(Role role, AstNode nextNode) void WriteSpecialsUpToRole(Role role, AstNode? nextNode)
{ {
if (positionStack.Count == 0) if (positionStack.Count == 0)
{ {

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

@ -233,7 +233,7 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
return writer.ToString(); return writer.ToString();
} }
public override void WritePrimitiveValue(object value, LiteralFormat format = LiteralFormat.None) public override void WritePrimitiveValue(object? value, LiteralFormat format = LiteralFormat.None)
{ {
if (value == null) if (value == null)
{ {

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

@ -42,20 +42,20 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
/// <summary> /// <summary>
/// Property representing the IsCompleted property on the awaiter type. Can be null if the awaiter type or the property was not found, or when awaiting a dynamic expression. /// Property representing the IsCompleted property on the awaiter type. Can be null if the awaiter type or the property was not found, or when awaiting a dynamic expression.
/// </summary> /// </summary>
public readonly IProperty IsCompletedProperty; public readonly IProperty? IsCompletedProperty;
/// <summary> /// <summary>
/// Method representing the OnCompleted method on the awaiter type. Can be null if the awaiter type or the method was not found, or when awaiting a dynamic expression. /// Method representing the OnCompleted method on the awaiter type. Can be null if the awaiter type or the method was not found, or when awaiting a dynamic expression.
/// This can also refer to an UnsafeOnCompleted method, if the awaiter type implements <c>System.Runtime.CompilerServices.ICriticalNotifyCompletion</c>. /// This can also refer to an UnsafeOnCompleted method, if the awaiter type implements <c>System.Runtime.CompilerServices.ICriticalNotifyCompletion</c>.
/// </summary> /// </summary>
public readonly IMethod OnCompletedMethod; public readonly IMethod? OnCompletedMethod;
/// <summary> /// <summary>
/// Method representing the GetResult method on the awaiter type. Can be null if the awaiter type or the method was not found, or when awaiting a dynamic expression. /// Method representing the GetResult method on the awaiter type. Can be null if the awaiter type or the method was not found, or when awaiting a dynamic expression.
/// </summary> /// </summary>
public readonly IMethod GetResultMethod; public readonly IMethod? GetResultMethod;
public AwaitResolveResult(IType resultType, ResolveResult getAwaiterInvocation, IType awaiterType, IProperty isCompletedProperty, IMethod onCompletedMethod, IMethod getResultMethod) public AwaitResolveResult(IType resultType, ResolveResult getAwaiterInvocation, IType awaiterType, IProperty? isCompletedProperty, IMethod? onCompletedMethod, IMethod? getResultMethod)
: base(resultType) : base(resultType)
{ {
if (awaiterType == null) if (awaiterType == null)

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

@ -792,7 +792,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
#endregion #endregion
#region Implicit Constant-Expression Conversion #region Implicit Constant-Expression Conversion
bool ImplicitConstantExpressionConversion(ResolveResult rr, IType toType) bool ImplicitConstantExpressionConversion(ResolveResult? rr, IType toType)
{ {
if (rr == null || !rr.IsCompileTimeConstant) if (rr == null || !rr.IsCompileTimeConstant)
return false; return false;
@ -983,7 +983,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
return Conversion.UserDefinedConversion(selected[0].Method, isLifted: selected[0].IsLifted, isImplicit: isImplicit, isAmbiguous: true, conversionBeforeUserDefinedOperator: ExplicitConversion(source, mostSpecificSource), conversionAfterUserDefinedOperator: ExplicitConversion(mostSpecificTarget, target)); return Conversion.UserDefinedConversion(selected[0].Method, isLifted: selected[0].IsLifted, isImplicit: isImplicit, isAmbiguous: true, conversionBeforeUserDefinedOperator: ExplicitConversion(source, mostSpecificSource), conversionAfterUserDefinedOperator: ExplicitConversion(mostSpecificTarget, target));
} }
Conversion UserDefinedImplicitConversion(ResolveResult fromResult, IType fromType, IType toType) Conversion UserDefinedImplicitConversion(ResolveResult? fromResult, IType fromType, IType toType)
{ {
// C# 4.0 spec §6.4.4 User-defined implicit conversions // C# 4.0 spec §6.4.4 User-defined implicit conversions
var operators = GetApplicableConversionOperators(fromResult, fromType, toType, false); var operators = GetApplicableConversionOperators(fromResult, fromType, toType, false);
@ -1025,7 +1025,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
} }
} }
Conversion UserDefinedExplicitConversion(ResolveResult fromResult, IType fromType, IType toType) Conversion UserDefinedExplicitConversion(ResolveResult? fromResult, IType fromType, IType toType)
{ {
// C# 4.0 spec §6.4.5 User-defined explicit conversions // C# 4.0 spec §6.4.5 User-defined explicit conversions
var operators = GetApplicableConversionOperators(fromResult, fromType, toType, true); var operators = GetApplicableConversionOperators(fromResult, fromType, toType, true);
@ -1112,7 +1112,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
return NullableType.GetUnderlyingType(type); return NullableType.GetUnderlyingType(type);
} }
List<OperatorInfo> GetApplicableConversionOperators(ResolveResult fromResult, IType fromType, IType toType, bool isExplicit) List<OperatorInfo> GetApplicableConversionOperators(ResolveResult? fromResult, IType fromType, IType toType, bool isExplicit)
{ {
// Find the candidate operators: // Find the candidate operators:
Predicate<IMethod> opFilter; Predicate<IMethod> opFilter;

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

@ -1712,7 +1712,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
return null; return null;
} }
ResolveResult? LookInUsingScopeNamespace(ResolvedUsingScope usingScope, INamespace n, string identifier, IReadOnlyList<IType> typeArguments, bool parameterizeResultType) ResolveResult? LookInUsingScopeNamespace(ResolvedUsingScope? usingScope, INamespace n, string identifier, IReadOnlyList<IType> typeArguments, bool parameterizeResultType)
{ {
if (n == null) if (n == null)
return null; return null;
@ -2222,7 +2222,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
#region ResolveInvocation #region ResolveInvocation
IList<ResolveResult> AddArgumentNamesIfNecessary(ResolveResult[] arguments, string[] argumentNames) IList<ResolveResult> AddArgumentNamesIfNecessary(ResolveResult[] arguments, string[]? argumentNames)
{ {
if (argumentNames == null) if (argumentNames == null)
{ {
@ -2239,7 +2239,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
} }
} }
private ResolveResult ResolveInvocation(ResolveResult target, ResolveResult[] arguments, string[] argumentNames, bool allowOptionalParameters) private ResolveResult ResolveInvocation(ResolveResult target, ResolveResult[] arguments, string[]? argumentNames, bool allowOptionalParameters)
{ {
// C# 4.0 spec: §7.6.5 // C# 4.0 spec: §7.6.5

4
ICSharpCode.Decompiler/CSharp/Resolver/LambdaResolveResult.cs

@ -65,7 +65,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
/// This method determines the return type inferred from the lambda body, which is used as part of C# type inference. /// This method determines the return type inferred from the lambda body, which is used as part of C# type inference.
/// Use the <see cref="ReturnType"/> property to retrieve the actual return type as determined by the target delegate type. /// Use the <see cref="ReturnType"/> property to retrieve the actual return type as determined by the target delegate type.
/// </remarks> /// </remarks>
public abstract IType GetInferredReturnType(IType[] parameterTypes); public abstract IType GetInferredReturnType(IType[]? parameterTypes);
/// <summary> /// <summary>
/// Gets the list of parameters. /// Gets the list of parameters.
@ -138,7 +138,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public override ResolveResult Body { get; } public override ResolveResult Body { get; }
public override IType GetInferredReturnType(IType[] parameterTypes) public override IType GetInferredReturnType(IType[]? parameterTypes)
{ {
// We don't know how to compute which type would be inferred if // We don't know how to compute which type would be inferred if
// given other parameter types. // given other parameter types.

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

@ -259,18 +259,18 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
public readonly IType DeclaringType; public readonly IType DeclaringType;
// When a nested type is hidden, it is simply removed from the list. // When a nested type is hidden, it is simply removed from the list.
public List<IType> NestedTypes; public List<IType>? NestedTypes;
// When members are hidden, they are merely marked as hidden. // When members are hidden, they are merely marked as hidden.
// We still need to store the hidden methods so that the 'override' processing can // We still need to store the hidden methods so that the 'override' processing can
// find them, so that it won't introduce the override as a new method. // find them, so that it won't introduce the override as a new method.
public readonly List<IParameterizedMember> Methods; public readonly List<IParameterizedMember>? Methods;
public bool MethodsAreHidden; public bool MethodsAreHidden;
public IMember NonMethod; public IMember? NonMethod;
public bool NonMethodIsHidden; public bool NonMethodIsHidden;
public LookupGroup(IType declaringType, List<IType> nestedTypes, List<IParameterizedMember> methods, IMember nonMethod) public LookupGroup(IType declaringType, List<IType>? nestedTypes, List<IParameterizedMember>? methods, IMember? nonMethod)
{ {
this.DeclaringType = declaringType; this.DeclaringType = declaringType;
this.NestedTypes = nestedTypes; this.NestedTypes = nestedTypes;

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

@ -83,7 +83,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
readonly string methodName; readonly string methodName;
public MethodGroupResolveResult(ResolveResult? targetResult, string methodName, public MethodGroupResolveResult(ResolveResult? targetResult, string methodName,
IReadOnlyList<MethodListWithDeclaringType> methods, IReadOnlyList<IType> typeArguments) IReadOnlyList<MethodListWithDeclaringType> methods, IReadOnlyList<IType>? typeArguments)
: base(SpecialType.NoType) : base(SpecialType.NoType)
{ {
if (methods == null) if (methods == null)
@ -143,10 +143,10 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
/// List of extension methods, used to avoid re-calculating it in ResolveInvocation() when it was already /// List of extension methods, used to avoid re-calculating it in ResolveInvocation() when it was already
/// calculated by ResolveMemberAccess(). /// calculated by ResolveMemberAccess().
/// </summary> /// </summary>
internal List<List<IMethod>> extensionMethods; internal List<List<IMethod>>? extensionMethods;
// the resolver is used to fetch extension methods on demand // the resolver is used to fetch extension methods on demand
internal CSharpResolver resolver; internal CSharpResolver? resolver;
/// <summary> /// <summary>
/// Gets all candidate extension methods. /// Gets all candidate extension methods.

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

@ -130,7 +130,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
readonly CSharpConversions conversions; readonly CSharpConversions conversions;
//List<Candidate> candidates = new List<Candidate>(); //List<Candidate> candidates = new List<Candidate>();
Candidate bestCandidate; Candidate bestCandidate;
Candidate bestCandidateAmbiguousWith; Candidate? bestCandidateAmbiguousWith;
IType[] explicitlyGivenTypeArguments; IType[] explicitlyGivenTypeArguments;
bool bestCandidateWasValidated; bool bestCandidateWasValidated;
OverloadResolutionErrors bestCandidateValidationResult; OverloadResolutionErrors bestCandidateValidationResult;
@ -994,7 +994,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
return GetArgumentsWithConversions(null, GetBestCandidateWithSubstitutedTypeArguments()); return GetArgumentsWithConversions(null, GetBestCandidateWithSubstitutedTypeArguments());
} }
IList<ResolveResult> GetArgumentsWithConversions(ResolveResult targetResolveResult, IParameterizedMember bestCandidateForNamedArguments) IList<ResolveResult> GetArgumentsWithConversions(ResolveResult? targetResolveResult, IParameterizedMember? bestCandidateForNamedArguments)
{ {
var conversions = this.ArgumentConversions; var conversions = this.ArgumentConversions;
ResolveResult[] args = new ResolveResult[arguments.Length]; ResolveResult[] args = new ResolveResult[arguments.Length];
@ -1072,9 +1072,9 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
/// <param name="returnTypeOverride"> /// <param name="returnTypeOverride">
/// If not null, use this instead of the ReturnType of the member as the type of the created resolve result. /// If not null, use this instead of the ReturnType of the member as the type of the created resolve result.
/// </param> /// </param>
public CSharpInvocationResolveResult CreateResolveResult(ResolveResult targetResolveResult, IList<ResolveResult>? initializerStatements = null, IType? returnTypeOverride = null) public CSharpInvocationResolveResult CreateResolveResult(ResolveResult? targetResolveResult, IList<ResolveResult>? initializerStatements = null, IType? returnTypeOverride = null)
{ {
IParameterizedMember member = GetBestCandidateWithSubstitutedTypeArguments(); IParameterizedMember? member = GetBestCandidateWithSubstitutedTypeArguments();
if (member == null) if (member == null)
throw new InvalidOperationException(); throw new InvalidOperationException();

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

@ -94,11 +94,11 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
} }
#endregion #endregion
TP[] typeParameters; TP[]? typeParameters;
IType[] parameterTypes; IType[]? parameterTypes;
ResolveResult[] arguments; ResolveResult[]? arguments;
bool[,] dependencyMatrix; bool[,]? dependencyMatrix;
IReadOnlyList<IType> classTypeArguments; IReadOnlyList<IType>? classTypeArguments;
#region InferTypeArguments (main function) #region InferTypeArguments (main function)
/// <summary> /// <summary>

2
ICSharpCode.Decompiler/CSharp/SequencePointBuilder.cs

@ -76,7 +76,7 @@ namespace ICSharpCode.Decompiler.CSharp
/// <summary> /// <summary>
/// The function containing this sequence point. /// The function containing this sequence point.
/// </summary> /// </summary>
internal ILFunction Function; internal ILFunction? Function;
public StatePerSequencePoint(AstNode primaryNode) public StatePerSequencePoint(AstNode primaryNode)
{ {

2
ICSharpCode.Decompiler/CSharp/Syntax/CSharpTokenNode.cs

@ -100,7 +100,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
} }
} }
public CSharpTokenNode(TextLocation location, TokenRole role) public CSharpTokenNode(TextLocation location, TokenRole? role)
{ {
this.startLocation = location; this.startLocation = location;
if (role != null) if (role != null)

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

@ -54,7 +54,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
{ {
} }
public IndexerExpression(Expression target, IEnumerable<Expression>? arguments) public IndexerExpression(Expression? target, IEnumerable<Expression>? arguments)
{ {
AddChild(target, Roles.TargetExpression); AddChild(target, Roles.TargetExpression);
if (arguments != null) if (arguments != null)

8
ICSharpCode.Decompiler/CSharp/Syntax/PatternMatching/Match.cs

@ -27,7 +27,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching
{ {
// TODO: maybe we should add an implicit Match->bool conversion? (implicit operator bool(Match m) { return m != null; }) // TODO: maybe we should add an implicit Match->bool conversion? (implicit operator bool(Match m) { return m != null; })
List<KeyValuePair<string, INode>> results; List<KeyValuePair<string, INode?>>? results;
public bool Success { public bool Success {
get { return results != null; } get { return results != null; }
@ -36,7 +36,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching
internal static Match CreateNew() internal static Match CreateNew()
{ {
Match m; Match m;
m.results = new List<KeyValuePair<string, INode>>(); m.results = new List<KeyValuePair<string, INode?>>();
return m; return m;
} }
@ -88,7 +88,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching
{ {
if (groupName != null && node != null) if (groupName != null && node != null)
{ {
results.Add(new KeyValuePair<string, INode>(groupName, node)); results.Add(new KeyValuePair<string, INode?>(groupName, node));
} }
} }
@ -96,7 +96,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax.PatternMatching
{ {
if (groupName != null) if (groupName != null)
{ {
results.Add(new KeyValuePair<string, INode>(groupName, null)); results.Add(new KeyValuePair<string, INode?>(groupName, null));
} }
} }
} }

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

@ -69,7 +69,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public class Role<T> : Role where T : class? public class Role<T> : Role where T : class?
{ {
readonly string name; // helps with debugging the AST readonly string name; // helps with debugging the AST
readonly T nullObject; readonly T? nullObject;
/// <summary> /// <summary>
/// Gets the null object used when there's no node with this role. /// Gets the null object used when there's no node with this role.
@ -79,7 +79,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
/// Roles used for non-collections should always have a null object, so that no AST property returns null. /// Roles used for non-collections should always have a null object, so that no AST property returns null.
/// However, if a role used for collections only, it may leave out the null object. /// However, if a role used for collections only, it may leave out the null object.
/// </remarks> /// </remarks>
public T NullObject { public T? NullObject {
get { return nullObject; } get { return nullObject; }
} }
@ -97,7 +97,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
this.nullObject = null!; this.nullObject = null!;
} }
public Role(string name, T nullObject) public Role(string name, T? nullObject)
{ {
this.name = name ?? throw new ArgumentNullException(nameof(name)); this.name = name ?? throw new ArgumentNullException(nameof(name));
this.nullObject = nullObject; this.nullObject = nullObject;

6
ICSharpCode.Decompiler/CSharp/Transforms/ContextTrackingVisitor.cs

@ -28,8 +28,8 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
/// </summary> /// </summary>
public abstract class ContextTrackingVisitor<TResult> : DepthFirstAstVisitor<TResult> public abstract class ContextTrackingVisitor<TResult> : DepthFirstAstVisitor<TResult>
{ {
protected ITypeDefinition currentTypeDefinition; protected ITypeDefinition? currentTypeDefinition;
protected IMethod currentMethod; protected IMethod? currentMethod;
protected void Initialize(TransformContext context) protected void Initialize(TransformContext context)
{ {
@ -45,7 +45,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
public override TResult VisitTypeDeclaration(TypeDeclaration typeDeclaration) public override TResult VisitTypeDeclaration(TypeDeclaration typeDeclaration)
{ {
ITypeDefinition oldType = currentTypeDefinition; ITypeDefinition? oldType = currentTypeDefinition;
try try
{ {
currentTypeDefinition = typeDeclaration.GetSymbol() as ITypeDefinition; currentTypeDefinition = typeDeclaration.GetSymbol() as ITypeDefinition;

2
ICSharpCode.Decompiler/CSharp/Transforms/DeclareVariables.cs

@ -139,7 +139,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
} }
readonly Dictionary<ILVariable, VariableToDeclare> variableDict = new Dictionary<ILVariable, VariableToDeclare>(); readonly Dictionary<ILVariable, VariableToDeclare> variableDict = new Dictionary<ILVariable, VariableToDeclare>();
TransformContext context; TransformContext? context;
public void Run(AstNode rootNode, TransformContext context) public void Run(AstNode rootNode, TransformContext context)
{ {

2
ICSharpCode.Decompiler/CSharp/Transforms/NormalizeBlockStatements.cs

@ -12,7 +12,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
{ {
TransformContext context; TransformContext context;
bool hasNamespace; bool hasNamespace;
NamespaceDeclaration singleNamespaceDeclaration; NamespaceDeclaration? singleNamespaceDeclaration;
public override void VisitSyntaxTree(SyntaxTree syntaxTree) public override void VisitSyntaxTree(SyntaxTree syntaxTree)
{ {

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

@ -35,7 +35,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
public sealed class PatternStatementTransform : ContextTrackingVisitor<AstNode>, IAstTransform public sealed class PatternStatementTransform : ContextTrackingVisitor<AstNode>, IAstTransform
{ {
readonly DeclareVariables declareVariables = new DeclareVariables(); readonly DeclareVariables declareVariables = new DeclareVariables();
TransformContext context; TransformContext? context;
public void Run(AstNode rootNode, TransformContext context) public void Run(AstNode rootNode, TransformContext context)
{ {

2
ICSharpCode.Decompiler/CSharp/Transforms/PrettifyAssignments.cs

@ -39,7 +39,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
/// </remarks> /// </remarks>
class PrettifyAssignments : DepthFirstAstVisitor, IAstTransform class PrettifyAssignments : DepthFirstAstVisitor, IAstTransform
{ {
TransformContext context; TransformContext? context;
public override void VisitAssignmentExpression(AssignmentExpression assignment) public override void VisitAssignmentExpression(AssignmentExpression assignment)
{ {

2
ICSharpCode.Decompiler/CSharp/Transforms/ReplaceMethodCallsWithOperators.cs

@ -41,7 +41,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
MemberName = "TypeHandle" MemberName = "TypeHandle"
}; };
TransformContext context; TransformContext? context;
public override void VisitInvocationExpression(InvocationExpression invocationExpression) public override void VisitInvocationExpression(InvocationExpression invocationExpression)
{ {

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

@ -37,8 +37,8 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
/// </summary> /// </summary>
public class TransformFieldAndConstructorInitializers : DepthFirstAstVisitor, IAstTransform public class TransformFieldAndConstructorInitializers : DepthFirstAstVisitor, IAstTransform
{ {
TransformContext context; TransformContext? context;
Dictionary<IField, IL.ILVariable> fieldToVariableMap; Dictionary<IField, IL.ILVariable>? fieldToVariableMap;
public void Run(AstNode node, TransformContext context) public void Run(AstNode node, TransformContext context)
{ {

2
ICSharpCode.Decompiler/DebugInfo/ImportScopeInfo.cs

@ -23,7 +23,7 @@ namespace ICSharpCode.Decompiler.DebugInfo
{ {
class ImportScopeInfo class ImportScopeInfo
{ {
public readonly ImportScopeInfo Parent; public readonly ImportScopeInfo? Parent;
public ImportScopeHandle Handle; public ImportScopeHandle Handle;
public readonly HashSet<string> Imports = new HashSet<string>(); public readonly HashSet<string> Imports = new HashSet<string>();

2
ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs

@ -68,7 +68,7 @@ namespace ICSharpCode.Decompiler.Disassembler
/// </summary> /// </summary>
public IDebugInfoProvider DebugInfo { get; set; } public IDebugInfoProvider DebugInfo { get; set; }
IList<DebugInfo.SequencePoint> sequencePoints; IList<DebugInfo.SequencePoint>? sequencePoints;
int nextSequencePointIndex; int nextSequencePointIndex;
// cache info // cache info

2
ICSharpCode.Decompiler/Disassembler/OpCodeInfo.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.Decompiler.Disassembler
public readonly ILOpCode Code; public readonly ILOpCode Code;
public readonly string Name; public readonly string Name;
string encodedName; string? encodedName;
public OpCodeInfo(ILOpCode code, string name) public OpCodeInfo(ILOpCode code, string name)
{ {

10
ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs

@ -1912,16 +1912,16 @@ namespace ICSharpCode.Decompiler.Disassembler
} }
sealed class EnumNameCollection<T> : IEnumerable<KeyValuePair<long, string>> where T : struct sealed class EnumNameCollection<T> : IEnumerable<KeyValuePair<long, string?>> where T : struct
{ {
List<KeyValuePair<long, string>> names = new List<KeyValuePair<long, string>>(); List<KeyValuePair<long, string?>> names = new List<KeyValuePair<long, string?>>();
public void Add(T flag, string name) public void Add(T flag, string? name)
{ {
this.names.Add(new KeyValuePair<long, string>(Convert.ToInt64(flag), name)); this.names.Add(new KeyValuePair<long, string?>(Convert.ToInt64(flag), name));
} }
public IEnumerator<KeyValuePair<long, string>> GetEnumerator() public IEnumerator<KeyValuePair<long, string?>> GetEnumerator()
{ {
return names.GetEnumerator(); return names.GetEnumerator();
} }

8
ICSharpCode.Decompiler/FlowAnalysis/ControlFlowNode.cs

@ -38,7 +38,7 @@ namespace ICSharpCode.Decompiler.FlowAnalysis
/// <summary> /// <summary>
/// User data. /// User data.
/// </summary> /// </summary>
public object UserData; public object? UserData;
/// <summary> /// <summary>
/// Visited flag, used in various algorithms. /// Visited flag, used in various algorithms.
@ -62,13 +62,13 @@ namespace ICSharpCode.Decompiler.FlowAnalysis
/// Gets the immediate dominator (the parent in the dominator tree). /// Gets the immediate dominator (the parent in the dominator tree).
/// Null if dominance has not been calculated; or if the node is unreachable. /// Null if dominance has not been calculated; or if the node is unreachable.
/// </summary> /// </summary>
public ControlFlowNode ImmediateDominator { get; internal set; } public ControlFlowNode? ImmediateDominator { get; internal set; }
/// <summary> /// <summary>
/// List of children in the dominator tree. /// List of children in the dominator tree.
/// Null if dominance has not been calculated; or if the node is unreachable. /// Null if dominance has not been calculated; or if the node is unreachable.
/// </summary> /// </summary>
public List<ControlFlowNode> DominatorTreeChildren { get; internal set; } public List<ControlFlowNode>? DominatorTreeChildren { get; internal set; }
/// <summary> /// <summary>
/// List of incoming control flow edges. /// List of incoming control flow edges.
@ -120,7 +120,7 @@ namespace ICSharpCode.Decompiler.FlowAnalysis
public bool Dominates(ControlFlowNode node) public bool Dominates(ControlFlowNode node)
{ {
// TODO: this can be made O(1) by numbering the dominator tree // TODO: this can be made O(1) by numbering the dominator tree
ControlFlowNode tmp = node; ControlFlowNode? tmp = node;
while (tmp != null) while (tmp != null)
{ {
if (tmp == this) if (tmp == this)

2
ICSharpCode.Decompiler/FlowAnalysis/ReachingDefinitionsVisitor.cs

@ -331,7 +331,7 @@ namespace ICSharpCode.Decompiler.FlowAnalysis
for (int vi = 0; vi < storesByVar.Length; vi++) for (int vi = 0; vi < storesByVar.Length; vi++)
{ {
if (activeVariables[vi]) if (activeVariables[vi])
storesByVar[vi] = new List<ILInstruction> { null }; storesByVar[vi] = new List<ILInstruction?> { null };
} }
foreach (var inst in scope.Descendants) foreach (var inst in scope.Descendants)
{ {

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

@ -57,7 +57,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
/// </summary> /// </summary>
public class DetectPinnedRegions : IILTransform public class DetectPinnedRegions : IILTransform
{ {
ILTransformContext context; ILTransformContext? context;
public void Run(ILFunction function, ILTransformContext context) public void Run(ILFunction function, ILTransformContext context)
{ {

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

@ -24,7 +24,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
/// The variable that is used to represent the switch expression. /// The variable that is used to represent the switch expression.
/// <c>null</c> while analyzing the first block. /// <c>null</c> while analyzing the first block.
/// </summary> /// </summary>
ILVariable switchVar; ILVariable? switchVar;
/// <summary> /// <summary>
/// The variable to be used as the argument of the switch instruction. /// The variable to be used as the argument of the switch instruction.

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

@ -38,10 +38,10 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
{ {
private readonly SwitchAnalysis analysis = new SwitchAnalysis(); private readonly SwitchAnalysis analysis = new SwitchAnalysis();
private ILTransformContext context; private ILTransformContext? context;
private BlockContainer currentContainer; private BlockContainer? currentContainer;
private ControlFlowGraph controlFlowGraph; private ControlFlowGraph? controlFlowGraph;
private LoopContext loopContext; private LoopContext? loopContext;
/// <summary> /// <summary>
/// When detecting a switch, it is important to distinguish Branch instructions which will /// When detecting a switch, it is important to distinguish Branch instructions which will

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

@ -73,15 +73,15 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
/// <summary>The field in the compiler-generated class holding the current state of the state machine</summary> /// <summary>The field in the compiler-generated class holding the current state of the state machine</summary>
/// <remarks>Set in AnalyzeCtor() for MS, MatchEnumeratorCreationPattern() or AnalyzeMoveNext() for Mono</remarks> /// <remarks>Set in AnalyzeCtor() for MS, MatchEnumeratorCreationPattern() or AnalyzeMoveNext() for Mono</remarks>
IField stateField; IField? stateField;
/// <summary>The backing field of the 'Current' property in the compiler-generated class</summary> /// <summary>The backing field of the 'Current' property in the compiler-generated class</summary>
/// <remarks>Set in AnalyzeCurrentProperty()</remarks> /// <remarks>Set in AnalyzeCurrentProperty()</remarks>
IField currentField; IField? currentField;
/// <summary>The disposing field of the compiler-generated enumerator class.</summary> /// <summary>The disposing field of the compiler-generated enumerator class.</summary>
/// <remarks>Set in ConstructExceptionTable() for assembly compiled with Mono</remarks> /// <remarks>Set in ConstructExceptionTable() for assembly compiled with Mono</remarks>
IField disposingField; IField? disposingField;
/// <summary>Maps the fields of the compiler-generated class to the original parameters.</summary> /// <summary>Maps the fields of the compiler-generated class to the original parameters.</summary>
/// <remarks>Set in MatchEnumeratorCreationPattern() and ResolveIEnumerableIEnumeratorFieldMapping()</remarks> /// <remarks>Set in MatchEnumeratorCreationPattern() and ResolveIEnumerableIEnumeratorFieldMapping()</remarks>
@ -90,7 +90,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
/// <summary>This dictionary stores the information extracted from the Dispose() method: /// <summary>This dictionary stores the information extracted from the Dispose() method:
/// for each "Finally Method", it stores the set of states for which the method is being called.</summary> /// for each "Finally Method", it stores the set of states for which the method is being called.</summary>
/// <remarks>Set in ConstructExceptionTable()</remarks> /// <remarks>Set in ConstructExceptionTable()</remarks>
Dictionary<IMethod, LongSet> finallyMethodToStateRange; Dictionary<IMethod, LongSet>? finallyMethodToStateRange;
/// <summary> /// <summary>
/// For each finally method, stores the target state when entering the finally block, /// For each finally method, stores the target state when entering the finally block,
@ -106,17 +106,17 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
/// <summary> /// <summary>
/// Local bool variable in MoveNext() that signifies whether to skip finally bodies. /// Local bool variable in MoveNext() that signifies whether to skip finally bodies.
/// </summary> /// </summary>
ILVariable skipFinallyBodies; ILVariable? skipFinallyBodies;
/// <summary> /// <summary>
/// Local bool variable in MoveNext() that signifies whether to execute finally bodies. /// Local bool variable in MoveNext() that signifies whether to execute finally bodies.
/// </summary> /// </summary>
ILVariable doFinallyBodies; ILVariable? doFinallyBodies;
/// <summary> /// <summary>
/// Set of variables might hold copies of the generated state field. /// Set of variables might hold copies of the generated state field.
/// </summary> /// </summary>
HashSet<ILVariable> cachedStateVars; HashSet<ILVariable>? cachedStateVars;
#region Run() method #region Run() method
public void Run(ILFunction function, ILTransformContext context) public void Run(ILFunction function, ILTransformContext context)

2
ICSharpCode.Decompiler/IL/Instructions/DeconstructInstruction.cs

@ -211,7 +211,7 @@ namespace ICSharpCode.Decompiler.IL
return input.MatchLdLoc(out inputVariable) || input.MatchLdLoca(out inputVariable); return input.MatchLdLoc(out inputVariable) || input.MatchLdLoca(out inputVariable);
} }
internal static bool IsAssignment(ILInstruction inst, ICompilation typeSystem, [NotNullWhen(true)] out IType? expectedType, [NotNullWhen(true)] out ILInstruction? value) internal static bool IsAssignment(ILInstruction inst, ICompilation? typeSystem, [NotNullWhen(true)] out IType? expectedType, [NotNullWhen(true)] out ILInstruction? value)
{ {
expectedType = null; expectedType = null;
value = null; value = null;

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

@ -34,7 +34,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// </summary> /// </summary>
class DeconstructionTransform : IStatementTransform class DeconstructionTransform : IStatementTransform
{ {
StatementTransformContext context; StatementTransformContext? context;
readonly Dictionary<ILVariable, int> deconstructionResultsLookup = new Dictionary<ILVariable, int>(); readonly Dictionary<ILVariable, int> deconstructionResultsLookup = new Dictionary<ILVariable, int>();
ILVariable[]? deconstructionResults; ILVariable[]? deconstructionResults;
ILVariable? tupleVariable; ILVariable? tupleVariable;

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

@ -741,10 +741,10 @@ namespace ICSharpCode.Decompiler.IL.Transforms
internal readonly struct FindResult internal readonly struct FindResult
{ {
public readonly FindResultType Type; public readonly FindResultType Type;
public readonly ILInstruction LoadInst; // ldloc or ldloca instruction that loads the variable to be inlined public readonly ILInstruction? LoadInst; // ldloc or ldloca instruction that loads the variable to be inlined
public readonly ILInstruction CallArgument; // argument of call that needs to be promoted to a named argument public readonly ILInstruction? CallArgument; // argument of call that needs to be promoted to a named argument
private FindResult(FindResultType type, ILInstruction loadInst, ILInstruction callArg) private FindResult(FindResultType type, ILInstruction? loadInst, ILInstruction? callArg)
{ {
this.Type = type; this.Type = type;
this.LoadInst = loadInst; this.LoadInst = loadInst;

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

@ -294,7 +294,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return true; return true;
} }
bool MatchExitBlock(Block entryPoint, ILVariable flag, ILVariable obj) bool MatchExitBlock(Block entryPoint, ILVariable? flag, ILVariable obj)
{ {
if (entryPoint.Instructions.Count != 2 || entryPoint.IncomingEdgeCount != 1) if (entryPoint.Instructions.Count != 2 || entryPoint.IncomingEdgeCount != 1)
return false; return false;

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

@ -42,7 +42,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
struct NullableLiftingTransform struct NullableLiftingTransform
{ {
readonly ILTransformContext context; readonly ILTransformContext context;
List<ILVariable> nullableVars; List<ILVariable>? nullableVars;
public NullableLiftingTransform(ILTransformContext context) public NullableLiftingTransform(ILTransformContext context)
{ {

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

@ -54,7 +54,7 @@ namespace ICSharpCode.Decompiler.IL
} }
} }
private void Visit(BlockContainer container, Block continueTarget) private void Visit(BlockContainer container, Block? continueTarget)
{ {
switch (container.Kind) switch (container.Kind)
{ {
@ -84,7 +84,7 @@ namespace ICSharpCode.Decompiler.IL
/// <param name="block"></param> /// <param name="block"></param>
/// <param name="continueTarget">Marks the target block of continue statements.</param> /// <param name="continueTarget">Marks the target block of continue statements.</param>
/// <param name="nextInstruction">The instruction following the end point of the block. Can only be null if the end point is unreachable.</param> /// <param name="nextInstruction">The instruction following the end point of the block. Can only be null if the end point is unreachable.</param>
private void Visit(Block block, Block continueTarget, ILInstruction? nextInstruction = null) private void Visit(Block block, Block? continueTarget, ILInstruction? nextInstruction = null)
{ {
Debug.Assert(block.HasFlag(InstructionFlags.EndPointUnreachable) || nextInstruction != null); Debug.Assert(block.HasFlag(InstructionFlags.EndPointUnreachable) || nextInstruction != null);
@ -174,7 +174,7 @@ namespace ICSharpCode.Decompiler.IL
/// For an if statement with an unreachable end point and no else block, /// For an if statement with an unreachable end point and no else block,
/// inverts to match IL order of the first statement of each branch /// inverts to match IL order of the first statement of each branch
/// </summary> /// </summary>
private void ImproveILOrdering(Block block, IfInstruction ifInst, Block continueTarget) private void ImproveILOrdering(Block block, IfInstruction ifInst, Block? continueTarget)
{ {
if (!block.HasFlag(InstructionFlags.EndPointUnreachable) if (!block.HasFlag(InstructionFlags.EndPointUnreachable)
|| !ifInst.TrueInst.HasFlag(InstructionFlags.EndPointUnreachable) || !ifInst.TrueInst.HasFlag(InstructionFlags.EndPointUnreachable)
@ -368,7 +368,7 @@ namespace ICSharpCode.Decompiler.IL
/// <summary> /// <summary>
/// Checks if an exit is a duplicable keyword exit (return; break; continue;) /// Checks if an exit is a duplicable keyword exit (return; break; continue;)
/// </summary> /// </summary>
private bool CanDuplicateExit(ILInstruction exit, Block continueTarget, out ILInstruction keywordExit) private bool CanDuplicateExit(ILInstruction exit, Block? continueTarget, out ILInstruction keywordExit)
{ {
keywordExit = exit; keywordExit = exit;
if (exit != null && exit.MatchBranch(continueTarget)) if (exit != null && exit.MatchBranch(continueTarget))

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

@ -34,7 +34,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// </summary> /// </summary>
public class TransformArrayInitializers : IStatementTransform public class TransformArrayInitializers : IStatementTransform
{ {
StatementTransformContext context; StatementTransformContext? context;
void IStatementTransform.Run(Block block, int pos, StatementTransformContext context) void IStatementTransform.Run(Block block, int pos, StatementTransformContext context)
{ {

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

@ -545,7 +545,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return true; return true;
} }
internal static bool IsImplicitTruncation(ILInstruction value, IType type, ICompilation compilation, bool allowNullableValue = false) internal static bool IsImplicitTruncation(ILInstruction value, IType type, ICompilation? compilation, bool allowNullableValue = false)
{ {
return CheckImplicitTruncation(value, type, compilation, allowNullableValue) != ImplicitTruncationResult.ValuePreserved; return CheckImplicitTruncation(value, type, compilation, allowNullableValue) != ImplicitTruncationResult.ValuePreserved;
} }
@ -571,7 +571,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// Gets whether 'stobj type(..., value)' would evaluate to a different value than 'value' /// Gets whether 'stobj type(..., value)' would evaluate to a different value than 'value'
/// due to implicit truncation. /// due to implicit truncation.
/// </summary> /// </summary>
internal static ImplicitTruncationResult CheckImplicitTruncation(ILInstruction value, IType type, ICompilation compilation, bool allowNullableValue = false) internal static ImplicitTruncationResult CheckImplicitTruncation(ILInstruction value, IType type, ICompilation? compilation, bool allowNullableValue = false)
{ {
if (!type.IsSmallIntegerType()) if (!type.IsSmallIntegerType())
{ {

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

@ -52,7 +52,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{ {
private readonly DisplayClass container; private readonly DisplayClass container;
private readonly IField field; private readonly IField field;
private ILVariable declaredVariable; private ILVariable? declaredVariable;
public string Name => field.Name; public string Name => field.Name;
@ -70,7 +70,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
Debug.Assert(declaredVariable == null || declaredVariable.StateMachineField == field); Debug.Assert(declaredVariable == null || declaredVariable.StateMachineField == field);
} }
public void Propagate(ILVariable variable) public void Propagate(ILVariable? variable)
{ {
this.declaredVariable = variable; this.declaredVariable = variable;
this.CanPropagate = variable != null; this.CanPropagate = variable != null;
@ -94,8 +94,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
public readonly ILVariable Variable; public readonly ILVariable Variable;
public readonly ITypeDefinition Type; public readonly ITypeDefinition Type;
public readonly Dictionary<IField, VariableToDeclare> VariablesToDeclare; public readonly Dictionary<IField, VariableToDeclare> VariablesToDeclare;
public BlockContainer CaptureScope; public BlockContainer? CaptureScope;
public ILInstruction Initializer; public ILInstruction? Initializer;
public DisplayClass(ILVariable variable, ITypeDefinition type) public DisplayClass(ILVariable variable, ITypeDefinition type)
{ {
@ -105,8 +105,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
} }
} }
ILTransformContext context; ILTransformContext? context;
ITypeResolveContext decompilationContext; ITypeResolveContext? decompilationContext;
readonly Dictionary<ILVariable, DisplayClass> displayClasses = new Dictionary<ILVariable, DisplayClass>(); readonly Dictionary<ILVariable, DisplayClass> displayClasses = new Dictionary<ILVariable, DisplayClass>();
readonly Dictionary<ILVariable, ILVariable> displayClassCopyMap = new Dictionary<ILVariable, ILVariable>(); readonly Dictionary<ILVariable, ILVariable> displayClassCopyMap = new Dictionary<ILVariable, ILVariable>();
@ -502,7 +502,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return code; return code;
} }
VariableToDeclare AddVariable(DisplayClass result, StObj statement, IField field) VariableToDeclare AddVariable(DisplayClass result, StObj? statement, IField field)
{ {
VariableToDeclare variable = new VariableToDeclare(result, field); VariableToDeclare variable = new VariableToDeclare(result, field);
if (statement != null) if (statement != null)

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

@ -24,7 +24,7 @@ namespace LightJson
public static readonly JsonValue Null = new JsonValue(JsonValueType.Null, default(double), null); public static readonly JsonValue Null = new JsonValue(JsonValueType.Null, default(double), null);
private readonly JsonValueType type; private readonly JsonValueType type;
private readonly object reference; private readonly object? reference;
private readonly double value; private readonly double value;
/// <summary> /// <summary>
@ -139,7 +139,7 @@ namespace LightJson
/// The internal value reference of the JsonValue. /// The internal value reference of the JsonValue.
/// This value is used when the Json type is String, JsonObject, or JsonArray. /// This value is used when the Json type is String, JsonObject, or JsonArray.
/// </param> /// </param>
private JsonValue(JsonValueType type, double value, object reference) private JsonValue(JsonValueType type, double value, object? reference)
{ {
this.type = type; this.type = type;
this.value = value; this.value = value;
@ -357,7 +357,7 @@ namespace LightJson
public JsonObject? AsJsonObject { public JsonObject? AsJsonObject {
get { get {
return this.IsJsonObject return this.IsJsonObject
? (JsonObject)this.reference ? (JsonObject?)this.reference
: null; : null;
} }
} }
@ -369,7 +369,7 @@ namespace LightJson
public JsonArray? AsJsonArray { public JsonArray? AsJsonArray {
get { get {
return this.IsJsonArray return this.IsJsonArray
? (JsonArray)this.reference ? (JsonArray?)this.reference
: null; : null;
} }
} }
@ -382,7 +382,7 @@ namespace LightJson
get { get {
DateTime value; DateTime value;
if (this.IsString && DateTime.TryParse((string)this.reference, out value)) if (this.IsString && DateTime.TryParse((string?)this.reference, out value))
{ {
return value; return value;
} }
@ -427,7 +427,7 @@ namespace LightJson
get { get {
if (this.IsJsonObject) if (this.IsJsonObject)
{ {
return ((JsonObject)this.reference)[key]; return ((JsonObject?)this.reference)[key];
} }
else else
{ {
@ -438,7 +438,7 @@ namespace LightJson
set { set {
if (this.IsJsonObject) if (this.IsJsonObject)
{ {
((JsonObject)this.reference)[key] = value; ((JsonObject?)this.reference)[key] = value;
} }
else else
{ {
@ -458,7 +458,7 @@ namespace LightJson
get { get {
if (this.IsJsonArray) if (this.IsJsonArray)
{ {
return ((JsonArray)this.reference)[index]; return ((JsonArray?)this.reference)[index];
} }
else else
{ {
@ -469,7 +469,7 @@ namespace LightJson
set { set {
if (this.IsJsonArray) if (this.IsJsonArray)
{ {
((JsonArray)this.reference)[index] = value; ((JsonArray?)this.reference)[index] = value;
} }
else else
{ {

2
ICSharpCode.Decompiler/Output/TextTokenWriter.cs

@ -363,7 +363,7 @@ namespace ICSharpCode.Decompiler
output.WriteLine(); output.WriteLine();
} }
public override void WritePrimitiveValue(object value, LiteralFormat format = LiteralFormat.None) public override void WritePrimitiveValue(object? value, LiteralFormat format = LiteralFormat.None)
{ {
new TextWriterTokenWriter(new TextOutputWriter(output)).WritePrimitiveValue(value, format); new TextWriterTokenWriter(new TextOutputWriter(output)).WritePrimitiveValue(value, format);
} }

4
ICSharpCode.Decompiler/SRMExtensions.cs

@ -628,7 +628,7 @@ namespace ICSharpCode.Decompiler
#endregion #endregion
public static unsafe BlobReader GetInitialValue(this FieldDefinition field, MetadataFile pefile, public static unsafe BlobReader GetInitialValue(this FieldDefinition field, MetadataFile pefile,
ICompilation typeSystem) ICompilation? typeSystem)
{ {
if (!field.HasFlag(FieldAttributes.HasFieldRVA)) if (!field.HasFlag(FieldAttributes.HasFieldRVA))
return default; return default;
@ -647,7 +647,7 @@ namespace ICSharpCode.Decompiler
sealed class FieldValueSizeDecoder : ISignatureTypeProvider<int, GenericContext> sealed class FieldValueSizeDecoder : ISignatureTypeProvider<int, GenericContext>
{ {
readonly MetadataModule module; readonly MetadataModule? module;
readonly int pointerSize; readonly int pointerSize;
public FieldValueSizeDecoder(ICompilation? typeSystem = null) public FieldValueSizeDecoder(ICompilation? typeSystem = null)

2
ICSharpCode.Decompiler/Semantics/InvocationResolveResult.cs

@ -42,7 +42,7 @@ namespace ICSharpCode.Decompiler.Semantics
/// </summary> /// </summary>
public readonly IList<ResolveResult> InitializerStatements; public readonly IList<ResolveResult> InitializerStatements;
public InvocationResolveResult(ResolveResult targetResult, IParameterizedMember member, public InvocationResolveResult(ResolveResult? targetResult, IParameterizedMember member,
IList<ResolveResult>? arguments = null, IList<ResolveResult>? arguments = null,
IList<ResolveResult>? initializerStatements = null, IList<ResolveResult>? initializerStatements = null,
IType? returnTypeOverride = null) IType? returnTypeOverride = null)

8
ICSharpCode.Decompiler/TypeSystem/ApplyAttributeTypeVisitor.cs

@ -175,11 +175,11 @@ namespace ICSharpCode.Decompiler.TypeSystem
readonly bool hasDynamicAttribute; readonly bool hasDynamicAttribute;
readonly bool[] dynamicAttributeData; readonly bool[] dynamicAttributeData;
readonly bool hasNativeIntegersAttribute; readonly bool hasNativeIntegersAttribute;
readonly bool[] nativeIntegersAttributeData; readonly bool[]? nativeIntegersAttributeData;
readonly TypeSystemOptions options; readonly TypeSystemOptions options;
readonly string[] tupleElementNames; readonly string[] tupleElementNames;
readonly Nullability defaultNullability; readonly Nullability defaultNullability;
readonly Nullability[] nullableAttributeData; readonly Nullability[]? nullableAttributeData;
int dynamicTypeIndex = 0; int dynamicTypeIndex = 0;
int tupleTypeIndex = 0; int tupleTypeIndex = 0;
int nullabilityTypeIndex = 0; int nullabilityTypeIndex = 0;
@ -187,9 +187,9 @@ namespace ICSharpCode.Decompiler.TypeSystem
private ApplyAttributeTypeVisitor(ICompilation compilation, private ApplyAttributeTypeVisitor(ICompilation compilation,
bool hasDynamicAttribute, bool[] dynamicAttributeData, bool hasDynamicAttribute, bool[] dynamicAttributeData,
bool hasNativeIntegersAttribute, bool[] nativeIntegersAttributeData, bool hasNativeIntegersAttribute, bool[]? nativeIntegersAttributeData,
TypeSystemOptions options, string[] tupleElementNames, TypeSystemOptions options, string[] tupleElementNames,
Nullability defaultNullability, Nullability[] nullableAttributeData) Nullability defaultNullability, Nullability[]? nullableAttributeData)
{ {
this.compilation = compilation ?? throw new ArgumentNullException(nameof(compilation)); this.compilation = compilation ?? throw new ArgumentNullException(nameof(compilation));
this.hasDynamicAttribute = hasDynamicAttribute; this.hasDynamicAttribute = hasDynamicAttribute;

2
ICSharpCode.Decompiler/TypeSystem/FullTypeName.cs

@ -52,7 +52,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
} }
readonly TopLevelTypeName topLevelType; readonly TopLevelTypeName topLevelType;
readonly NestedTypeName[] nestedTypes; readonly NestedTypeName[]? nestedTypes;
FullTypeName(TopLevelTypeName topLevelTypeName, NestedTypeName[] nestedTypes) FullTypeName(TopLevelTypeName topLevelTypeName, NestedTypeName[] nestedTypes)
{ {

6
ICSharpCode.Decompiler/TypeSystem/Implementation/GetMembersHelper.cs

@ -41,7 +41,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
return GetNestedTypes(type, null, filter, options); return GetNestedTypes(type, null, filter, options);
} }
public static IEnumerable<IType> GetNestedTypes(IType type, IReadOnlyList<IType> nestedTypeArguments, Predicate<ITypeDefinition> filter, GetMemberOptions options) public static IEnumerable<IType> GetNestedTypes(IType type, IReadOnlyList<IType>? nestedTypeArguments, Predicate<ITypeDefinition> filter, GetMemberOptions options)
{ {
if ((options & GetMemberOptions.IgnoreInheritedMembers) == GetMemberOptions.IgnoreInheritedMembers) if ((options & GetMemberOptions.IgnoreInheritedMembers) == GetMemberOptions.IgnoreInheritedMembers)
{ {
@ -53,9 +53,9 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
} }
} }
static IEnumerable<IType> GetNestedTypesImpl(IType outerType, IReadOnlyList<IType> nestedTypeArguments, Predicate<ITypeDefinition> filter, GetMemberOptions options) static IEnumerable<IType> GetNestedTypesImpl(IType outerType, IReadOnlyList<IType>? nestedTypeArguments, Predicate<ITypeDefinition>? filter, GetMemberOptions options)
{ {
ITypeDefinition outerTypeDef = outerType.GetDefinition(); ITypeDefinition? outerTypeDef = outerType.GetDefinition();
if (outerTypeDef == null) if (outerTypeDef == null)
yield break; yield break;

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

@ -34,7 +34,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
public string FullName { get; } public string FullName { get; }
public string Name { get; } public string Name { get; }
public MetadataNamespace(MetadataModule module, INamespace parent, string fullName, NamespaceDefinition ns) public MetadataNamespace(MetadataModule module, INamespace? parent, string fullName, NamespaceDefinition ns)
{ {
Debug.Assert(module != null); Debug.Assert(module != null);
Debug.Assert(fullName != null); Debug.Assert(fullName != null);

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

@ -38,7 +38,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation
/// <param name="namespaceName">Namespace name, if known. Can be null if unknown.</param> /// <param name="namespaceName">Namespace name, if known. Can be null if unknown.</param>
/// <param name="name">Name of the type, must not be null.</param> /// <param name="name">Name of the type, must not be null.</param>
/// <param name="typeParameterCount">Type parameter count, zero if unknown.</param> /// <param name="typeParameterCount">Type parameter count, zero if unknown.</param>
public UnknownType(string namespaceName, string name, int typeParameterCount = 0, bool? isReferenceType = null) public UnknownType(string? namespaceName, string name, int typeParameterCount = 0, bool? isReferenceType = null)
{ {
if (name == null) if (name == null)
throw new ArgumentNullException(nameof(name)); throw new ArgumentNullException(nameof(name));

14
ICSharpCode.Decompiler/TypeSystem/TupleType.cs

@ -53,10 +53,10 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// <summary> /// <summary>
/// Gets the names of the tuple elements. /// Gets the names of the tuple elements.
/// </summary> /// </summary>
public ImmutableArray<string> ElementNames { get; } public ImmutableArray<string?> ElementNames { get; }
public TupleType(ICompilation compilation, ImmutableArray<IType> elementTypes, public TupleType(ICompilation compilation, ImmutableArray<IType> elementTypes,
ImmutableArray<string> elementNames = default(ImmutableArray<string>), ImmutableArray<string?> elementNames = default(ImmutableArray<string?>),
IModule? valueTupleAssembly = null) IModule? valueTupleAssembly = null)
{ {
this.Compilation = compilation; this.Compilation = compilation;
@ -64,7 +64,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
this.ElementTypes = elementTypes; this.ElementTypes = elementTypes;
if (elementNames.IsDefault) if (elementNames.IsDefault)
{ {
this.ElementNames = Enumerable.Repeat<string>(null, elementTypes.Length).ToImmutableArray(); this.ElementNames = Enumerable.Repeat<string?>(null, elementTypes.Length).ToImmutableArray();
} }
else else
{ {
@ -73,7 +73,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
} }
} }
static ParameterizedType CreateUnderlyingType(ICompilation compilation, ImmutableArray<IType> elementTypes, IModule valueTupleAssembly) static ParameterizedType CreateUnderlyingType(ICompilation compilation, ImmutableArray<IType> elementTypes, IModule? valueTupleAssembly)
{ {
int remainder = (elementTypes.Length - 1) % (RestPosition - 1) + 1; int remainder = (elementTypes.Length - 1) % (RestPosition - 1) + 1;
Debug.Assert(remainder >= 1 && remainder < RestPosition); Debug.Assert(remainder >= 1 && remainder < RestPosition);
@ -92,7 +92,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
return type; return type;
} }
private static IType FindValueTupleType(ICompilation compilation, IModule valueTupleAssembly, int tpc) private static IType FindValueTupleType(ICompilation compilation, IModule? valueTupleAssembly, int tpc)
{ {
var typeName = new TopLevelTypeName("System", "ValueTuple", tpc); var typeName = new TopLevelTypeName("System", "ValueTuple", tpc);
if (valueTupleAssembly != null) if (valueTupleAssembly != null)
@ -236,7 +236,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
unchecked unchecked
{ {
int hash = UnderlyingType.GetHashCode(); int hash = UnderlyingType.GetHashCode();
foreach (string name in ElementNames) foreach (string? name in ElementNames)
{ {
hash *= 31; hash *= 31;
hash += name != null ? name.GetHashCode() : 0; hash += name != null ? name.GetHashCode() : 0;
@ -387,7 +387,7 @@ namespace ICSharpCode.Decompiler.TypeSystem
/// </summary> /// </summary>
public ImmutableArray<string> ElementNames { get; } public ImmutableArray<string> ElementNames { get; }
public IModuleReference ValueTupleAssembly { get; } public IModuleReference? ValueTupleAssembly { get; }
public TupleTypeReference(ImmutableArray<ITypeReference> elementTypes) public TupleTypeReference(ImmutableArray<ITypeReference> elementTypes)
{ {

14
ICSharpCode.Decompiler/Util/ResXResourceWriter.cs

@ -45,12 +45,12 @@ namespace ICSharpCode.Decompiler.Util
#endif #endif
class ResXResourceWriter : IDisposable class ResXResourceWriter : IDisposable
{ {
private string filename; private string? filename;
private Stream stream; private Stream? stream;
private TextWriter textwriter; private TextWriter? textwriter;
private XmlTextWriter writer; private XmlTextWriter? writer;
private bool written; private bool written;
private string base_path; private string? base_path;
public static readonly string BinSerializedObjectMimeType = "application/x-microsoft.net.object.binary.base64"; public static readonly string BinSerializedObjectMimeType = "application/x-microsoft.net.object.binary.base64";
public static readonly string ByteArraySerializedObjectMimeType = "application/x-microsoft.net.object.bytearray.base64"; public static readonly string ByteArraySerializedObjectMimeType = "application/x-microsoft.net.object.bytearray.base64";
@ -131,7 +131,7 @@ namespace ICSharpCode.Decompiler.Util
writer.WriteString(base64); writer.WriteString(base64);
} }
void WriteBytes(string name, string type, byte[] value, int offset, int length, string comment) void WriteBytes(string name, string? type, byte[] value, int offset, int length, string comment)
{ {
writer.WriteStartElement("data"); writer.WriteStartElement("data");
writer.WriteAttributeString("name", name); writer.WriteAttributeString("name", name);
@ -165,7 +165,7 @@ namespace ICSharpCode.Decompiler.Util
writer.WriteEndElement(); writer.WriteEndElement();
} }
void WriteString(string name, string value, string type, string comment) void WriteString(string name, string value, string? type, string comment)
{ {
writer.WriteStartElement("data"); writer.WriteStartElement("data");
writer.WriteAttributeString("name", name); writer.WriteAttributeString("name", name);

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

Loading…
Cancel
Save