Skip to content

ConfigContext: Remove default value for Bind(T defaultValue) parameter#79

Merged
XuuXiaolan merged 1 commit intoTeamXiaolan:mainfrom
ratijas:work/ratijas/defaultValue-default
Feb 5, 2026
Merged

ConfigContext: Remove default value for Bind(T defaultValue) parameter#79
XuuXiaolan merged 1 commit intoTeamXiaolan:mainfrom
ratijas:work/ratijas/defaultValue-default

Conversation

@ratijas
Copy link
Contributor

@ratijas ratijas commented Feb 5, 2026

According to Microsoft documentation, this is a source break at worst, NOT a binary break.

Pros:

  • It is never used without an actual value for the defaultValue argument.
  • Not providing any defaultValue never made much sense.

Cons:

  • It is part of public API.

https://learn.microsoft.com/en-us/dotnet/core/compatibility/library-change-rules

❌ DISALLOWED: Changing the default value of a property, field, or parameter

Changing or removing a parameter default value is not a binary break.
Removing a parameter default value is a source break, and changing a
parameter default value could result in a behavioral break after
recompilation.

According to Microsoft documentation, this is a source break at worst,
NOT a binary break.

Pros:
- It is never used without an actual value for the defaultValue argument.
- Not providing any defaultValue never made much sense.

Cons:
- It is part of public API.

https://learn.microsoft.com/en-us/dotnet/core/compatibility/library-change-rules

> ❌ DISALLOWED: Changing the default value of a property, field, or parameter
>
> Changing or removing a parameter default value is not a binary break.
> Removing a parameter default value is a source break, and changing a
> parameter default value could result in a behavioral break after
> recompilation.
@XuuXiaolan
Copy link
Collaborator

what's the difference between a source break and a binary break? wont people who have accessed this function have to recompile?

@ratijas
Copy link
Contributor Author

ratijas commented Feb 5, 2026

Binary break == dependent libs won't load, everything's on fire. Very bad.

Source break == you might be unable to recompile dependent code without changes. Like, here you would need to pass an explicit value for the third argument if you didn't do so before. So basically, projects might need to modify their code in order to bump their dependencies during development.

The reason is it only a source break, is that = default argument is substituted at compile time, so projects compiled against an old (existing) version of DawnLib already have those default evaluated and hard-coded into their dll.

@XuuXiaolan
Copy link
Collaborator

so if somebody had already filled in a defaultValue, they're good?

@ratijas
Copy link
Contributor Author

ratijas commented Feb 5, 2026

so if somebody had already filled in a defaultValue, they're good?

yeah, just like 55 places in DawnLib.Dusk itself, they won't need to change anything.

@XuuXiaolan XuuXiaolan merged commit 76326cb into TeamXiaolan:main Feb 5, 2026
1 check passed
@ratijas ratijas deleted the work/ratijas/defaultValue-default branch February 5, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants