Skip to content

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

Description

@GrantByrn3

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);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions