Browse Source

Merge branch 'master' of https://github.com/icsharpcode/ILSpy into issue1848

pull/1850/head
Siegfried Pammer 6 years ago
parent
commit
5b3c2f300a
  1. 9
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/UnsafeCode.cs
  2. 23
      ICSharpCode.Decompiler/CSharp/Transforms/PatternStatementTransform.cs
  3. 20
      ICSharpCode.Decompiler/DecompilerSettings.cs
  4. 9
      ILSpy/Properties/Resources.Designer.cs
  5. 3
      ILSpy/Properties/Resources.resx
  6. 2
      ILSpy/TreeNodes/AssemblyTreeNode.cs

9
ICSharpCode.Decompiler.Tests/TestCases/Pretty/UnsafeCode.cs

@ -354,6 +354,15 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -354,6 +354,15 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
return ptr->ToString();
}
#if CS73
public unsafe void PinSpan(Span<int> span)
{
fixed (int* ptr = span) {
UsePointer(ptr);
}
}
#endif
public unsafe string StackAlloc(int count)
{
char* ptr = stackalloc char[count];

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

@ -1036,5 +1036,28 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -1036,5 +1036,28 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
return base.VisitBinaryOperatorExpression(expr);
}
#endregion
#region C# 7.3 pattern based fixed
static readonly Expression addressOfPinnableReference = new UnaryOperatorExpression {
Operator = UnaryOperatorType.AddressOf,
Expression = new InvocationExpression {
Target = new MemberReferenceExpression(new AnyNode("target"), "GetPinnableReference"),
Arguments = { }
}
};
public override AstNode VisitFixedStatement(FixedStatement fixedStatement)
{
if (context.Settings.PatternBasedFixedStatement) {
foreach (var v in fixedStatement.Variables) {
var m = addressOfPinnableReference.Match(v.Initializer);
if (m.Success) {
v.Initializer = m.Get<Expression>("target").Single().Detach();
}
}
}
return base.VisitFixedStatement(fixedStatement);
}
#endregion
}
}

20
ICSharpCode.Decompiler/DecompilerSettings.cs

@ -104,6 +104,7 @@ namespace ICSharpCode.Decompiler @@ -104,6 +104,7 @@ namespace ICSharpCode.Decompiler
introduceUnmanagedConstraint = false;
stackAllocInitializers = false;
tupleComparisons = false;
patternBasedFixedStatement = false;
}
if (languageVersion < CSharp.LanguageVersion.CSharp8_0) {
nullableReferenceTypes = false;
@ -117,7 +118,7 @@ namespace ICSharpCode.Decompiler @@ -117,7 +118,7 @@ namespace ICSharpCode.Decompiler
{
if (nullableReferenceTypes || readOnlyMethods || asyncEnumerator || asyncUsingAndForEachStatement)
return CSharp.LanguageVersion.CSharp8_0;
if (introduceUnmanagedConstraint || tupleComparisons || stackAllocInitializers)
if (introduceUnmanagedConstraint || tupleComparisons || stackAllocInitializers || patternBasedFixedStatement)
return CSharp.LanguageVersion.CSharp7_3;
if (introduceRefModifiersOnStructs || introduceReadonlyAndInModifiers || nonTrailingNamedArguments || refExtensionMethods)
return CSharp.LanguageVersion.CSharp7_2;
@ -926,6 +927,23 @@ namespace ICSharpCode.Decompiler @@ -926,6 +927,23 @@ namespace ICSharpCode.Decompiler
}
}
bool patternBasedFixedStatement = true;
/// <summary>
/// Gets/Sets whether C# 7.3 pattern based fixed statement should be used.
/// </summary>
[Category("C# 7.3 / VS 2017.7")]
[Description("DecompilerSettings.UsePatternBasedFixedStatement")]
public bool PatternBasedFixedStatement {
get { return patternBasedFixedStatement; }
set {
if (patternBasedFixedStatement != value) {
patternBasedFixedStatement = value;
OnPropertyChanged();
}
}
}
bool tupleTypes = true;
/// <summary>

9
ILSpy/Properties/Resources.Designer.cs generated

@ -1026,6 +1026,15 @@ namespace ICSharpCode.ILSpy.Properties { @@ -1026,6 +1026,15 @@ namespace ICSharpCode.ILSpy.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Use pattern-based fixed statement.
/// </summary>
public static string DecompilerSettings_UsePatternBasedFixedStatement {
get {
return ResourceManager.GetString("DecompilerSettings.UsePatternBasedFixedStatement", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Use stackalloc initializer syntax.
/// </summary>

3
ILSpy/Properties/Resources.resx

@ -790,6 +790,9 @@ Are you sure you want to continue?</value> @@ -790,6 +790,9 @@ Are you sure you want to continue?</value>
<data name="_Window" xml:space="preserve">
<value>_Window</value>
</data>
<data name="DecompilerSettings.UsePatternBasedFixedStatement" xml:space="preserve">
<value>Use pattern-based fixed statement</value>
</data>
<data name="DecompilerSettings.DoWhileStatement" xml:space="preserve">
<value>Transform to do-while, if possible.</value>
</data>

2
ILSpy/TreeNodes/AssemblyTreeNode.cs

@ -126,8 +126,6 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -126,8 +126,6 @@ namespace ICSharpCode.ILSpy.TreeNodes
RaisePropertyChanged("Tooltip");
if (moduleTask.IsFaulted) {
RaisePropertyChanged("ShowExpander"); // cannot expand assemblies with load error
// observe the exception so that the Task's finalizer doesn't re-throw it
try { moduleTask.Wait(); } catch (AggregateException) { }
} else {
RaisePropertyChanged("Text"); // shortname might have changed
}

Loading…
Cancel
Save