|
|
|
@ -1,126 +1,231 @@
@@ -1,126 +1,231 @@
|
|
|
|
|
using System; |
|
|
|
|
using System.Runtime.InteropServices; |
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty |
|
|
|
|
{ |
|
|
|
|
public record Base(string A); |
|
|
|
|
|
|
|
|
|
public record CopyCtor(string A) |
|
|
|
|
internal class RecordClasses |
|
|
|
|
{ |
|
|
|
|
protected CopyCtor(CopyCtor _) |
|
|
|
|
public record Base(string A); |
|
|
|
|
|
|
|
|
|
public record CopyCtor(string A) |
|
|
|
|
{ |
|
|
|
|
protected CopyCtor(CopyCtor _) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public record Derived(int B) : Base(B.ToString()); |
|
|
|
|
public record Derived(int B) : Base(B.ToString()); |
|
|
|
|
|
|
|
|
|
public record Empty; |
|
|
|
|
public record Empty; |
|
|
|
|
|
|
|
|
|
public record Fields |
|
|
|
|
{ |
|
|
|
|
public int A; |
|
|
|
|
public double B = 1.0; |
|
|
|
|
public object C; |
|
|
|
|
public dynamic D; |
|
|
|
|
public string S = "abc"; |
|
|
|
|
} |
|
|
|
|
public record Fields |
|
|
|
|
{ |
|
|
|
|
public int A; |
|
|
|
|
public double B = 1.0; |
|
|
|
|
public object C; |
|
|
|
|
public dynamic D; |
|
|
|
|
public string S = "abc"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public record Interface(int B) : IRecord; |
|
|
|
|
public record Interface(int B) : IRecord; |
|
|
|
|
|
|
|
|
|
public interface IRecord |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
public interface IRecord |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public record Pair<A, B> |
|
|
|
|
{ |
|
|
|
|
public A First { get; init; } |
|
|
|
|
public B Second { get; init; } |
|
|
|
|
} |
|
|
|
|
public record Pair<A, B> |
|
|
|
|
{ |
|
|
|
|
public A First { get; init; } |
|
|
|
|
public B Second { get; init; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public record PairWithPrimaryCtor<A, B>(A First, B Second); |
|
|
|
|
public record PairWithPrimaryCtor<A, B>(A First, B Second); |
|
|
|
|
|
|
|
|
|
public record PrimaryCtor(int A, string B); |
|
|
|
|
public record PrimaryCtorWithAttribute([RecordTest("param")] [property: RecordTest("property")][field: RecordTest("field")] int a); |
|
|
|
|
public record PrimaryCtorWithField(int A, string B) |
|
|
|
|
{ |
|
|
|
|
public double C = 1.0; |
|
|
|
|
public string D = A + B; |
|
|
|
|
} |
|
|
|
|
public record PrimaryCtorWithInParameter(in int A, in string B); |
|
|
|
|
public record PrimaryCtorWithProperty(int A, string B) |
|
|
|
|
{ |
|
|
|
|
public double C { get; init; } = 1.0; |
|
|
|
|
public string D { get; } = A + B; |
|
|
|
|
} |
|
|
|
|
public record PrimaryCtor(int A, string B); |
|
|
|
|
public record PrimaryCtorWithAttribute([RecordTest("param")] [property: RecordTest("property")][field: RecordTest("field")] int a); |
|
|
|
|
public record PrimaryCtorWithField(int A, string B) |
|
|
|
|
{ |
|
|
|
|
public double C = 1.0; |
|
|
|
|
public string D = A + B; |
|
|
|
|
} |
|
|
|
|
public record PrimaryCtorWithInParameter(in int A, in string B); |
|
|
|
|
public record PrimaryCtorWithProperty(int A, string B) |
|
|
|
|
{ |
|
|
|
|
public double C { get; init; } = 1.0; |
|
|
|
|
public string D { get; } = A + B; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public record Properties |
|
|
|
|
{ |
|
|
|
|
public int A { get; set; } |
|
|
|
|
public int B { get; } |
|
|
|
|
public int C => 43; |
|
|
|
|
public object O { get; set; } |
|
|
|
|
public string S { get; set; } |
|
|
|
|
public dynamic D { get; set; } |
|
|
|
|
public record Properties |
|
|
|
|
{ |
|
|
|
|
public int A { get; set; } |
|
|
|
|
public int B { get; } |
|
|
|
|
public int C => 43; |
|
|
|
|
public object O { get; set; } |
|
|
|
|
public string S { get; set; } |
|
|
|
|
public dynamic D { get; set; } |
|
|
|
|
|
|
|
|
|
public Properties() |
|
|
|
|
{ |
|
|
|
|
B = 42; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Properties() |
|
|
|
|
[AttributeUsage(AttributeTargets.All)] |
|
|
|
|
public class RecordTestAttribute : Attribute |
|
|
|
|
{ |
|
|
|
|
B = 42; |
|
|
|
|
public RecordTestAttribute(string name) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[AttributeUsage(AttributeTargets.All)] |
|
|
|
|
public class RecordTestAttribute : Attribute |
|
|
|
|
{ |
|
|
|
|
public RecordTestAttribute(string name) |
|
|
|
|
public sealed record Sealed(string A); |
|
|
|
|
|
|
|
|
|
public sealed record SealedDerived(int B) : Base(B.ToString()); |
|
|
|
|
|
|
|
|
|
public class WithExpressionTests |
|
|
|
|
{ |
|
|
|
|
public Fields Test(Fields input) |
|
|
|
|
{ |
|
|
|
|
return input with { |
|
|
|
|
A = 42, |
|
|
|
|
B = 3.141, |
|
|
|
|
C = input |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
public Fields Test2(Fields input) |
|
|
|
|
{ |
|
|
|
|
return input with { |
|
|
|
|
A = 42, |
|
|
|
|
B = 3.141, |
|
|
|
|
C = input with { |
|
|
|
|
A = 43 |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public sealed record Sealed(string A); |
|
|
|
|
public abstract record WithNestedRecords |
|
|
|
|
{ |
|
|
|
|
public record A : WithNestedRecords |
|
|
|
|
{ |
|
|
|
|
public override string AbstractProp => "A"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public record B : WithNestedRecords |
|
|
|
|
{ |
|
|
|
|
public override string AbstractProp => "B"; |
|
|
|
|
|
|
|
|
|
public int? Value { get; set; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public sealed record SealedDerived(int B) : Base(B.ToString()); |
|
|
|
|
public record DerivedGeneric<T> : Pair<T, T?> where T : struct |
|
|
|
|
{ |
|
|
|
|
public bool Flag; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public class WithExpressionTests |
|
|
|
|
public abstract string AbstractProp { get; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
internal class RecordStructs |
|
|
|
|
{ |
|
|
|
|
public Fields Test(Fields input) |
|
|
|
|
public record struct Base(string A); |
|
|
|
|
|
|
|
|
|
public record CopyCtor(string A) |
|
|
|
|
{ |
|
|
|
|
protected CopyCtor(CopyCtor _) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Size = 1)] |
|
|
|
|
public record struct Empty; |
|
|
|
|
|
|
|
|
|
public record struct Fields |
|
|
|
|
{ |
|
|
|
|
return input with { |
|
|
|
|
A = 42, |
|
|
|
|
B = 3.141, |
|
|
|
|
C = input |
|
|
|
|
}; |
|
|
|
|
public int A; |
|
|
|
|
public double B; |
|
|
|
|
public object C; |
|
|
|
|
public dynamic D; |
|
|
|
|
public string S; |
|
|
|
|
} |
|
|
|
|
public Fields Test2(Fields input) |
|
|
|
|
|
|
|
|
|
public record struct Interface(int B) : IRecord; |
|
|
|
|
|
|
|
|
|
public interface IRecord |
|
|
|
|
{ |
|
|
|
|
return input with { |
|
|
|
|
A = 42, |
|
|
|
|
B = 3.141, |
|
|
|
|
C = input with { |
|
|
|
|
A = 43 |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public abstract record WithNestedRecords |
|
|
|
|
{ |
|
|
|
|
public record A : WithNestedRecords |
|
|
|
|
public record struct Pair<A, B> |
|
|
|
|
{ |
|
|
|
|
public override string AbstractProp => "A"; |
|
|
|
|
public A First { get; init; } |
|
|
|
|
public B Second { get; init; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public record B : WithNestedRecords |
|
|
|
|
public record struct PairWithPrimaryCtor<A, B>(A First, B Second); |
|
|
|
|
|
|
|
|
|
public record struct PrimaryCtor(int A, string B); |
|
|
|
|
public record struct PrimaryCtorWithAttribute([RecordTest("param")] [property: RecordTest("property")][field: RecordTest("field")] int a); |
|
|
|
|
public record struct PrimaryCtorWithField(int A, string B) |
|
|
|
|
{ |
|
|
|
|
public override string AbstractProp => "B"; |
|
|
|
|
public double C = 1.0; |
|
|
|
|
public string D = A + B; |
|
|
|
|
} |
|
|
|
|
public record struct PrimaryCtorWithInParameter(in int A, in string B); |
|
|
|
|
public record struct PrimaryCtorWithProperty(int A, string B) |
|
|
|
|
{ |
|
|
|
|
public double C { get; init; } = 1.0; |
|
|
|
|
public string D { get; } = A + B; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public int? Value { get; set; } |
|
|
|
|
public record struct Properties |
|
|
|
|
{ |
|
|
|
|
public int A { get; set; } |
|
|
|
|
public int B { get; } |
|
|
|
|
public int C => 43; |
|
|
|
|
public object O { get; set; } |
|
|
|
|
public string S { get; set; } |
|
|
|
|
public dynamic D { get; set; } |
|
|
|
|
|
|
|
|
|
public Properties() |
|
|
|
|
{ |
|
|
|
|
A = 41; |
|
|
|
|
B = 42; |
|
|
|
|
O = null; |
|
|
|
|
S = "Hello"; |
|
|
|
|
D = null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public record DerivedGeneric<T> : Pair<T, T?> where T : struct |
|
|
|
|
[AttributeUsage(AttributeTargets.All)] |
|
|
|
|
public class RecordTestAttribute : Attribute |
|
|
|
|
{ |
|
|
|
|
public bool Flag; |
|
|
|
|
public RecordTestAttribute(string name) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public abstract string AbstractProp { get; } |
|
|
|
|
public class WithExpressionTests |
|
|
|
|
{ |
|
|
|
|
public Fields Test(Fields input) |
|
|
|
|
{ |
|
|
|
|
return input with { |
|
|
|
|
A = 42, |
|
|
|
|
B = 3.141, |
|
|
|
|
C = input |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
public Fields Test2(Fields input) |
|
|
|
|
{ |
|
|
|
|
return input with { |
|
|
|
|
A = 42, |
|
|
|
|
B = 3.141, |
|
|
|
|
C = input with { |
|
|
|
|
A = 43 |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
namespace System.Runtime.CompilerServices |
|
|
|
|