[Breaking change]: ConstructorBuilder and MethodBuilder now generate method parameters that when reflected on have ParameterInfo.HasDefaultValue=false #36725
Labels
binary incompatible
Existing binaries may encounter a breaking change in behavior.
breaking-change
Indicates a .NET Core breaking change
doc-idea
Indicates issues that are suggestions for new topics [org][type][category]
Pri1
High priority, do before Pri2 and Pri3
📌 seQUESTered
Identifies that an issue has been imported into Quest.
Description
System.Reflection.Emit.ConstructorBuilder
andSystem.Reflection.Emit.MethodBuilder
generate IL for the parameters where theHasDefaultValue
of the parameters returnstrue
which is not correct.Version
.NET 8 Preview 5
Previous behavior
System.Reflection.Emit.ConstructorBuilder
andMethodBuilder
generate IL for the parameters where theHasDefaultValue
of the parameters istrue
.New behavior
System.Reflection.Emit.ConstructorBuilder
andMethodBuilder
generate IL for the parameters where theHasDefaultValue
of the parameters isfalse
, as expected.Type of breaking change
Reason for change
The previous behavior was incorrect, as no default parameter values were specified when the method or constructor was defined.
Recommended action
If
System.Reflection.Emit.TypeBuilder.DefineConstructor()
orSystem.Reflection.Emit.TypeBuilder.DefineMethod()
are used, ensure that consumers of the generated types' methods do not rely on theParameterInfo.HasDefaultValue
property beingtrue
.Feature area
Core .NET libraries
Affected APIs
System.Reflection.ParameterInfo.HasDefaultValue
Associated WorkItem - 153928
The text was updated successfully, but these errors were encountered: