Skip to content

Commit 59f90aa

Browse files
authored
Add back StructWithPublicDefaultConstructor test (#65616)
1 parent a55d530 commit 59f90aa

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src/ActivatorUtilitiesTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ public void TypeActivatorWorksWithCtorWithOptionalArgs_WithStructDefaults(Create
117117
Assert.Null(anotherClass.ColorNull);
118118
Assert.Equal(12, anotherClass.Integer);
119119
Assert.Null(anotherClass.IntegerNull);
120-
// re-enable once https://github.com/dotnet/csharplang/issues/99 is implemented
121-
// see https://github.com/dotnet/runtime/issues/49069
122-
// Assert.Equal(ExpectStructWithPublicDefaultConstructorInvoked, anotherClass.StructWithConstructor.ConstructorInvoked);
120+
Assert.Equal(ExpectStructWithPublicDefaultConstructorInvoked, anotherClass.StructWithConstructor.ConstructorInvoked);
123121
}
124122

125123
[Theory]

src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src/Fakes/ClassWithOptionalArgsCtorWithStructs.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ public class ClassWithOptionalArgsCtorWithStructs
1313
public int? Integer { get; }
1414
public int? IntegerNull { get; }
1515

16-
// re-enable once https://github.com/dotnet/csharplang/issues/99 is implemented
17-
// see https://github.com/dotnet/runtime/issues/49069
18-
//public StructWithPublicDefaultConstructor StructWithConstructor { get; }
16+
public StructWithPublicDefaultConstructor StructWithConstructor { get; }
1917

2018
#pragma warning disable SA1129
2119
public ClassWithOptionalArgsCtorWithStructs(
@@ -32,18 +30,28 @@ public ClassWithOptionalArgsCtorWithStructs(
3230
ConsoleColor? color = ConsoleColor.DarkGreen,
3331
ConsoleColor? colorNull = null,
3432
int? integer = 12,
35-
int? integerNull = null
36-
//StructWithPublicDefaultConstructor structWithConstructor = default
33+
int? integerNull = null,
34+
StructWithPublicDefaultConstructor structWithConstructor = default
3735
)
3836
#pragma warning restore SA1129
3937
{
4038
Color = color;
4139
ColorNull = colorNull;
4240
Integer = integer;
4341
IntegerNull = integerNull;
44-
//StructWithConstructor = structWithConstructor;
42+
StructWithConstructor = structWithConstructor;
4543
}
4644

4745
public struct CustomStruct { }
46+
47+
public struct StructWithPublicDefaultConstructor
48+
{
49+
public bool ConstructorInvoked { get; private set; }
50+
51+
public StructWithPublicDefaultConstructor()
52+
{
53+
ConstructorInvoked = true;
54+
}
55+
}
4856
}
4957
}

0 commit comments

Comments
 (0)