[API Compat] add rule to make sure that parameter default value don't change
See original GitHub issueCurrently, the ApiCompat does not detect the change of default value for parameters.
void Execute(int i)
== void Execute(int i = 0)
== void Execute(int i = 2)
Issue Analytics
- State:
- Created 8 months ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
c# - Web API model validation and default values
I am always of the impression that using the ModelState validation with a simple return of BadRequest is completely useless to your API...
Read more >Can we make adding a parameter with a default value ...
We want to handle the case where someone adds a parameter to the right-side of a parameter list, with a default value. This...
Read more >Required contexts with default values should not fail the ...
Write tests to ensure that context definitions with a non-NULL default value will never fail a requirements check. User interface changes. n/a ...
Read more >Named and Optional Arguments - C# Programming Guide
Named and optional arguments enable you to omit the argument for an optional parameter if you don't want to change the parameter's default ......
Read more >CA1021: Avoid out parameters (code analysis) - .NET
Cause. A public or protected method in a public type has an out parameter. By default, this rule only looks at externally visible...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Make sure that the rule also works with
void M(decimal d = 1.999m)
, which is encoded using DecimalConstantAttribute rather than the Constant table. Maybe the Roslyn API handles this automatically, but it’s still worth testing.I’d put this is the same boat as parameter name changes. These are also not binary breaking but are “source breaking” and potentially functionally breaking.
In that case it’s an optional rule that can be enabled. https://github.com/dotnet/sdk/blob/80896301a295a97fbafbe06838bc62c83ac70767/src/ApiCompat/Microsoft.DotNet.ApiCompat.Tool/Program.cs#L73-L77
Perhaps we might consider a more extensible mechanism for describing optional rules or even a rule level system 🤔