diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/ReplaceMethodCallsWithOperators.cs b/ICSharpCode.Decompiler/CSharp/Transforms/ReplaceMethodCallsWithOperators.cs index cf9970232f..36624535b5 100644 --- a/ICSharpCode.Decompiler/CSharp/Transforms/ReplaceMethodCallsWithOperators.cs +++ b/ICSharpCode.Decompiler/CSharp/Transforms/ReplaceMethodCallsWithOperators.cs @@ -274,7 +274,8 @@ bool CheckArgumentsForStringConcat(Expression[] arguments) } foreach (var arg in arguments) { - if (arg.GetResolveResult() is InvocationResolveResult rr && IsStringConcat(rr.Member)) + var rr = arg.GetResolveResult(); + if (rr is InvocationResolveResult irr && IsStringConcat(irr.Member)) { // Roslyn + mcs also flatten nested string.Concat() invocations within a operator+ use, // which causes it to use the incorrect evaluation order despite the code using an @@ -282,6 +283,11 @@ bool CheckArgumentsForStringConcat(Expression[] arguments) // This problem is avoided if the outer call remains string.Concat() as well. return false; } + if (rr.Type.IsByRefLike) + { + // ref structs cannot be converted to object for use with + + return false; + } } // One of the first two arguments must be string, otherwise the + operator