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

Generated code doesn't handle default values for enums #24

Open
GrantByrn3 opened this issue Jan 21, 2024 · 0 comments
Open

Generated code doesn't handle default values for enums #24

GrantByrn3 opened this issue Jan 21, 2024 · 0 comments

Comments

@GrantByrn3
Copy link

We have our own custom set of log events that we keep track of in a database. The severity is stored with a custom LogLevel enum:

public enum LogLevel
{
    Trace = 0,
    Debug = 1,
    Information = 2,
    Warning = 3,
    Error = 4,
    Critical = 5,
    None = 6
}

For the DAL class, we have a method that has this format:
public async Task<IEnumerable<LogMessage>> GetLogsForObject(string objectType, long objectId, LogLevel minLogLevel = LogLevel.Information)

It generates the following interface:

public partial interface ILogMessageRepository
    {
        System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<TSWCloud.Domain.Logging.LogMessage>> GetLogsForObject(string objectType, long objectId, TSWCloud.Domain.Logging.LogLevel minLogLevel = 2);
    }

When compiling, this gives the error:
A value of type 'int' cannot be used as a default parameter because there is no standard conversions to type LogLevel

Instead, it should generate the following interface:

public interface ILogMessageRepository
{
    Task<IEnumerable<LogMessage>> GetLogsForObject(string objectType, long objectId,
        LogLevel minLogLevel = LogLevel.Information);
}
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

1 participant