Browse Source

Branch the VBAnonymousTypes fixture for legacy vbc codegen

The legacy .NET Framework vbc lowers anonymous types differently from
Roslyn: ToString builds its result with a StringBuilder instead of one
String.Format call, no DebuggerBrowsable/DebuggerHidden attributes are
emitted even in debug builds, and in optimized builds the DebuggerDisplay
attribute precedes CompilerGenerated in metadata order. The None/Optimize
test configurations only run on machines where that compiler is
installed, which is why the fixture did not cover them yet.

Assisted-by: Claude:claude-fable-5:Claude Code
pull/3964/head
Christoph Wille 1 month ago committed by Siegfried Pammer
parent
commit
faee2e29e0
  1. 25
      ICSharpCode.Decompiler.Tests/TestCases/VBPretty/VBAnonymousTypes.cs

25
ICSharpCode.Decompiler.Tests/TestCases/VBPretty/VBAnonymousTypes.cs

@ -3,22 +3,30 @@ using System.Collections.Generic; @@ -3,22 +3,30 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
#if LEGACY_VBC
using System.Text;
#endif
using Microsoft.VisualBasic.CompilerServices;
// A VB anonymous type. Its properties are settable and only those declared 'Key'
// take part in Equals and GetHashCode, so it cannot be written as a C# anonymous
// type and is declared here instead.
#if LEGACY_VBC && OPT
[DebuggerDisplay("Value={Value}, Name={Name}")]
[CompilerGenerated]
#else
[CompilerGenerated]
[DebuggerDisplay("Value={Value}, Name={Name}")]
#endif
internal sealed class VB_AnonymousType_0<T0, T1>
{
#if !OPT
#if !OPT && !LEGACY_VBC
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
#endif
private T0 _Value;
#if !OPT
#if !OPT && !LEGACY_VBC
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
#endif
private T1 _Name;
@ -41,7 +49,7 @@ internal sealed class VB_AnonymousType_0<T0, T1> @@ -41,7 +49,7 @@ internal sealed class VB_AnonymousType_0<T0, T1>
}
}
#if !OPT
#if !OPT && !LEGACY_VBC
[DebuggerHidden]
#endif
public VB_AnonymousType_0(T0 Value, T1 Name)
@ -50,12 +58,21 @@ internal sealed class VB_AnonymousType_0<T0, T1> @@ -50,12 +58,21 @@ internal sealed class VB_AnonymousType_0<T0, T1>
_Name = Name;
}
#if !OPT
#if !OPT && !LEGACY_VBC
[DebuggerHidden]
#endif
public override string ToString()
{
#if LEGACY_VBC
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("{ ");
stringBuilder.AppendFormat("{0} = {1}, ", "Value", _Value);
stringBuilder.AppendFormat("{0} = {1} ", "Name", _Name);
stringBuilder.Append("}");
return stringBuilder.ToString();
#else
return string.Format(null, "{{ Value = {0}, Name = {1} }}", new object[2] { _Value, _Name });
#endif
}
}
[StandardModule]

Loading…
Cancel
Save