Skip to content

Commit ea600ed

Browse files
committed
fix and refactor test cases
1 parent 5d7206a commit ea600ed

File tree

2 files changed

+33
-45
lines changed

2 files changed

+33
-45
lines changed

tests/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/Generator.Attributes.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,7 @@ public void M<
233233

234234
#nullable enable annotations
235235
[MemberDeclarationTestCase(
236-
#if SYSTEM_REFLECTION_NULLABILITYINFOCONTEXT
237-
"public void GenericMethodParameter_NullableEnableContext<[Nullable(2)] T>(T? p)",
238-
#else
239236
"public void GenericMethodParameter_NullableEnableContext<[Nullable(2)] T>(T p)",
240-
#endif
241237
AttributeWithNamespace = false,
242238
TypeWithNamespace = false,
243239
MethodBody = MethodBodyOption.None

tests/Smdn.Reflection.ReverseGenerating/Smdn.Reflection.ReverseGenerating/Generator.MemberDeclaration.cs

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,16 +1051,13 @@ public override void M(int t1, int t2) { }
10511051

10521052
public class Constraints1 {
10531053
#nullable enable annotations
1054-
#if SYSTEM_REFLECTION_NULLABILITYINFO
1055-
[MemberDeclarationTestCase("public T? M0_NullableEnableContext<T>(T? x) {}")]
1056-
#else
10571054
[MemberDeclarationTestCase("public T M0_NullableEnableContext<T>(T x) {}")]
1058-
#endif
10591055
public T M0_NullableEnableContext<T>(T x) => throw new NotImplementedException();
1060-
#nullable restore
10611056
#nullable disable annotations
1062-
[MemberDeclarationTestCase("public T M0_NullableDisableContext<T>(T x) {}")] public T M0_NullableDisableContext<T>(T x) => throw new NotImplementedException();
1057+
[MemberDeclarationTestCase("public T M0_NullableDisableContext<T>(T x) {}")]
1058+
public T M0_NullableDisableContext<T>(T x) => throw new NotImplementedException();
10631059
#nullable restore
1060+
10641061
[MemberDeclarationTestCase("public T M1<T>(T x) where T : new() {}")] public T M1<T>(T x) where T : new() => throw new NotImplementedException();
10651062
[MemberDeclarationTestCase("public T M2_0<T>(T x) where T : struct {}")] public T M2_0<T>(T x) where T : struct => throw new NotImplementedException();
10661063
[MemberDeclarationTestCase("public T M2_1<T>(T x) where T : struct, System.IDisposable {}")] public T M2_1<T>(T x) where T : struct, IDisposable => throw new NotImplementedException();
@@ -1081,47 +1078,42 @@ public class CBase { }
10811078
[MemberDeclarationTestCase("public T M12<T>(T x) where T : System.Delegate {}")] public T M12<T>(T x) where T : System.Delegate => throw new NotImplementedException();
10821079
[MemberDeclarationTestCase("public T M13<T>(T x) where T : System.MulticastDelegate {}")] public T M13<T>(T x) where T : System.MulticastDelegate => throw new NotImplementedException();
10831080

1084-
#nullable enable annotations
1085-
#if SYSTEM_REFLECTION_NULLABILITYINFO
1086-
[MemberDeclarationTestCase("public void M14_0_NullableEnableContext<T0, T1>(T0 t0, T1? t1) where T0 : notnull {}")]
1087-
#else
1088-
[MemberDeclarationTestCase("public void M14_0_NullableEnableContext<T0, T1>(T0 t0, T1 t1) where T0 : notnull {}")]
1089-
#endif
1090-
public void M14_0_NullableEnableContext<T0, T1>(T0 t0, T1 t1) where T0 : notnull => throw new NotImplementedException();
1091-
1092-
#if SYSTEM_REFLECTION_NULLABILITYINFO
1093-
[MemberDeclarationTestCase("public T0 M14_1_NullableEnableContext<T0, T1>(T0 t0, T1? t1) where T0 : notnull {}")]
1094-
#else
1095-
[MemberDeclarationTestCase("public T0 M14_1_NullableEnableContext<T0, T1>(T0 t0, T1 t1) where T0 : notnull {}")]
1096-
#endif
1097-
public T0 M14_1_NullableEnableContext<T0, T1>(T0 t0, T1 t1) where T0 : notnull => throw new NotImplementedException();
1098-
1099-
#if SYSTEM_REFLECTION_NULLABILITYINFO
1100-
[MemberDeclarationTestCase("public T1? M14_2_NullableEnableContext<T0, T1>(T0 t0, T1? t1) where T0 : notnull {}")]
1101-
#else
1102-
[MemberDeclarationTestCase("public T1 M14_2_NullableEnableContext<T0, T1>(T0 t0, T1 t1) where T0 : notnull {}")]
1103-
#endif
1104-
public T1 M14_2_NullableEnableContext<T0, T1>(T0 t0, T1 t1) where T0 : notnull => throw new NotImplementedException();
1081+
[MemberDeclarationTestCase("public T M15_0<T>(T x) where T : unmanaged {}")] public T M15_0<T>(T x) where T : unmanaged => throw new NotImplementedException();
1082+
[MemberDeclarationTestCase("public T M15_1<T>(T x) where T : unmanaged, System.IDisposable {}")] public T M15_1<T>(T x) where T : unmanaged, IDisposable => throw new NotImplementedException();
1083+
}
11051084

1106-
[MemberDeclarationTestCase("public void M14_3_NullableEnableContext<T>(T t) where T : notnull, System.IDisposable {}")]
1107-
public void M14_3_NullableEnableContext<T>(T t) where T : notnull, IDisposable => throw new NotImplementedException();
1108-
#nullable restore
1085+
public class ConstraintsNotNull {
1086+
#nullable enable annotations
1087+
[MemberDeclarationTestCase($"public void {nameof(NotNull_NullableEnableContext)}<TNotNull, T>(TNotNull pNotNull, T p) where TNotNull : notnull {{}}")]
1088+
public void NotNull_NullableEnableContext<TNotNull, T>(TNotNull pNotNull, T p) where TNotNull : notnull => throw new NotImplementedException();
11091089
#nullable disable annotations
1110-
[MemberDeclarationTestCase("public void M14_0_NullableDisableContext<T0, T1>(T0 t0, T1 t1) where T0 : notnull {}")]
1111-
public void M14_0_NullableDisableContext<T0, T1>(T0 t0, T1 t1) where T0 : notnull => throw new NotImplementedException();
1112-
1113-
[MemberDeclarationTestCase("public T0 M14_1_NullableDisableContext<T0, T1>(T0 t0, T1 t1) where T0 : notnull {}")]
1114-
public T0 M14_1_NullableDisableContext<T0, T1>(T0 t0, T1 t1) where T0 : notnull => throw new NotImplementedException();
1090+
[MemberDeclarationTestCase($"public void {nameof(NotNull_NullableDisableContext)}<TNotNull, T>(TNotNull pNotNull, T p) where TNotNull : notnull {{}}")]
1091+
public void NotNull_NullableDisableContext<TNotNull, T>(TNotNull pNotNull, T p) where TNotNull : notnull => throw new NotImplementedException();
1092+
#nullable restore
11151093

1116-
[MemberDeclarationTestCase("public T1 M14_2_NullableDisableContext<T0, T1>(T0 t0, T1 t1) where T0 : notnull {}")]
1117-
public T1 M14_2_NullableDisableContext<T0, T1>(T0 t0, T1 t1) where T0 : notnull => throw new NotImplementedException();
1094+
#nullable enable annotations
1095+
[MemberDeclarationTestCase($"public TNotNull {nameof(NotNull_ReturnParameter_NullableEnableContext)}<TNotNull, T>(TNotNull pNotNull, T p) where TNotNull : notnull {{}}")]
1096+
public TNotNull NotNull_ReturnParameter_NullableEnableContext<TNotNull, T>(TNotNull pNotNull, T p) where TNotNull : notnull => throw new NotImplementedException();
1097+
#nullable disable annotations
1098+
[MemberDeclarationTestCase($"public TNotNull {nameof(NotNull_ReturnParameter_NullableDisableContext)}<TNotNull, T>(TNotNull pNotNull, T p) where TNotNull : notnull {{}}")]
1099+
public TNotNull NotNull_ReturnParameter_NullableDisableContext<TNotNull, T>(TNotNull pNotNull, T p) where TNotNull : notnull => throw new NotImplementedException();
1100+
#nullable restore
11181101

1119-
[MemberDeclarationTestCase("public void M14_3_NullableDisableContext<T>(T t) where T : notnull, System.IDisposable {}")]
1120-
public void M14_3_NullableDisableContext<T>(T t) where T : notnull, IDisposable => throw new NotImplementedException();
1102+
#nullable enable annotations
1103+
[MemberDeclarationTestCase($"public T {nameof(NotNull_OnlyParameter_NullableEnableContext)}<TNotNull, T>(TNotNull pNotNull, T p) where TNotNull : notnull {{}}")]
1104+
public T NotNull_OnlyParameter_NullableEnableContext<TNotNull, T>(TNotNull pNotNull, T p) where TNotNull : notnull => throw new NotImplementedException();
1105+
#nullable disable annotations
1106+
[MemberDeclarationTestCase($"public T {nameof(NotNull_OnlyParameter_NullableDisableContext)}<TNotNull, T>(TNotNull pNotNull, T p) where TNotNull : notnull {{}}")]
1107+
public T NotNull_OnlyParameter_NullableDisableContext<TNotNull, T>(TNotNull pNotNull, T p) where TNotNull : notnull => throw new NotImplementedException();
11211108
#nullable restore
11221109

1123-
[MemberDeclarationTestCase("public T M15_0<T>(T x) where T : unmanaged {}")] public T M15_0<T>(T x) where T : unmanaged => throw new NotImplementedException();
1124-
[MemberDeclarationTestCase("public T M15_1<T>(T x) where T : unmanaged, System.IDisposable {}")] public T M15_1<T>(T x) where T : unmanaged, IDisposable => throw new NotImplementedException();
1110+
#nullable enable annotations
1111+
[MemberDeclarationTestCase($"public TNotNullDisposable {nameof(NotNullAndTypeConstraint_NullableEnableContext)}<TNotNullDisposable>(TNotNullDisposable p) where TNotNullDisposable : notnull, System.IDisposable {{}}")]
1112+
public TNotNullDisposable NotNullAndTypeConstraint_NullableEnableContext<TNotNullDisposable>(TNotNullDisposable p) where TNotNullDisposable : notnull, IDisposable => throw new NotImplementedException();
1113+
#nullable disable annotations
1114+
[MemberDeclarationTestCase($"public TNotNullDisposable {nameof(NotNullAndTypeConstraint_NullableDisableContext)}<TNotNullDisposable>(TNotNullDisposable p) where TNotNullDisposable : notnull, System.IDisposable {{}}")]
1115+
public TNotNullDisposable NotNullAndTypeConstraint_NullableDisableContext<TNotNullDisposable>(TNotNullDisposable p) where TNotNullDisposable : notnull, IDisposable => throw new NotImplementedException();
1116+
#nullable restore
11251117
}
11261118

11271119
public class ConstraintsNotNullWithNullableMetadata {

0 commit comments

Comments
 (0)