forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for parameterless ctor dotnet#45119
Calling `ActivatorUtilities.CreateInstance` without additional arguments should prefer parameterless constructor as there are no guarantees that parameters, for which arguments were not supplied, can be resolved from the ServiceProvider.
- Loading branch information
1 parent
90e0dfd
commit d186769
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...xtensions.DependencyInjection.Specification.Tests/src/Fakes/ClassWithParameterlessCtor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Microsoft.Extensions.DependencyInjection.Specification.Fakes | ||
{ | ||
public class ClassWithParameterlessCtor | ||
{ | ||
public ClassWithParameterlessCtor(IFakeService dependency) | ||
{ | ||
CtorUsed = "IFakeService"; | ||
} | ||
|
||
public ClassWithParameterlessCtor() | ||
{ | ||
CtorUsed = "Parameterless"; | ||
} | ||
|
||
public string CtorUsed { get; set; } | ||
} | ||
} |