Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Breaking change]: ConstructorBuilder and MethodBuilder now generate method parameters that when reflected on have ParameterInfo.HasDefaultValue=false #36725

Closed
1 of 3 tasks
steveharter opened this issue Aug 16, 2023 · 0 comments · Fixed by #36787
Assignees
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.

Comments

@steveharter
Copy link
Member

steveharter commented Aug 16, 2023

Description

System.Reflection.Emit.ConstructorBuilder and System.Reflection.Emit.MethodBuilder generate IL for the parameters where the HasDefaultValue of the parameters returns true which is not correct.

Version

.NET 8 Preview 5

Previous behavior

System.Reflection.Emit.ConstructorBuilder and MethodBuilder generate IL for the parameters where the HasDefaultValue of the parameters is true.

New behavior

System.Reflection.Emit.ConstructorBuilder and MethodBuilder generate IL for the parameters where the HasDefaultValue of the parameters is false, as expected.

Type of breaking change

  • Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code may require source changes to compile successfully.
  • Behavioral change: Existing binaries may behave differently at run time.

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() or System.Reflection.Emit.TypeBuilder.DefineMethod() are used, ensure that consumers of the generated types' methods do not rely on the ParameterInfo.HasDefaultValue property being true.

Feature area

Core .NET libraries

Affected APIs

System.Reflection.ParameterInfo.HasDefaultValue


Associated WorkItem - 153928

@steveharter steveharter added doc-idea Indicates issues that are suggestions for new topics [org][type][category] breaking-change Indicates a .NET Core breaking change Pri1 High priority, do before Pri2 and Pri3 labels Aug 16, 2023
@dotnet-bot dotnet-bot added ⌚ Not Triaged Not triaged binary incompatible Existing binaries may encounter a breaking change in behavior. labels Aug 16, 2023
@steveharter steveharter changed the title [Breaking change]: ConstructorBuilder and MethodBuilder no longer generate IL for methods that have HasDefaultValue=true for parameters [Breaking change]: ConstructorBuilder and MethodBuilder now generate method parameters that when reflected on have ParameterInfo.HasDefaultValue=false Aug 16, 2023
@gewarren gewarren removed the ⌚ Not Triaged Not triaged label Aug 21, 2023
@gewarren gewarren moved this from 🔖 Ready to 👀 In review in dotnet/docs August 2023 sprint Aug 22, 2023
@ghost ghost added the in-pr This issue will be closed (fixed) by an active pull request. label Aug 22, 2023
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in dotnet/docs August 2023 sprint Aug 28, 2023
@ghost ghost removed the in-pr This issue will be closed (fixed) by an active pull request. label Aug 28, 2023
@gewarren gewarren added the 🗺️ reQUEST Triggers an issue to be imported into Quest. label Aug 29, 2023
@github-actions github-actions bot added 📌 seQUESTered Identifies that an issue has been imported into Quest. and removed 🗺️ reQUEST Triggers an issue to be imported into Quest. labels Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants