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

Method with a default enum Parameter wich type is byte does not compile #67

Closed
mtren opened this issue Jan 24, 2025 · 2 comments
Closed

Comments

@mtren
Copy link

mtren commented Jan 24, 2025

Here is a example:

public enum EnumWithByteType : byte { A = 1, B = 2, C = 3 };

[AutomaticInterface.GenerateAutomaticInterface]
internal class MyApi : IMyApi
{
public void MethodWithDefaultParameter(EnumWithByteType a = EnumWithByteType.B) { }
}

leads to

[global::System.CodeDom.Compiler.GeneratedCode("AutomaticInterface", "")]
public partial interface IMyApi
{
///
void MethodWithDefaultParameter(global::ADD.Shared.Api.EventLogs.EnumWithByteType a = 2);

}

@simonmckenzie
Copy link
Contributor

simonmckenzie commented Jan 24, 2025

I had a (very) brief look at this @ChristianSauer, and I think the most recent merge actually makes this worse - for the case above, it generates something like this:

global::ADD.Shared.Api.EventLogs.EnumWithByteType a = B

I may even need to roll back the recent change where method generation is delegated to Roslyn, as I'm not sure the symbol generation has any more configuration options to make the default enum parameter render correctly.

Anyway, it's probably not good to release the current master. I will have a deeper look on Wednesday.

Edit

It does turn out that you can't reliably generate parameter signatures using ToDisplayString, so I'll revert some of the changes from the last PR and implement default enum parameter values through custom code. See the closure comments on #66 for details.

@ChristianSauer
Copy link
Collaborator

Should be fixed with #70

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

No branches or pull requests

3 participants