question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[API Compat] add rule to make sure that parameter default value don't change

See original GitHub issue

Currently, 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:open
  • Created 8 months ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
KalleOlaviNiemitalocommented, Feb 2, 2023

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.

0reactions
ericstjcommented, Jun 9, 2023

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 🤔

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found