Skip to content

DAP037 error when return type is an enum #228

Open

Description

@FayyazulHassan

Describe the bug

A DAP037 error is reported when the return type is a single enum value (it is not reported if the enum is a field or if it is part of a tuple)

Where are you seeing this?

Using packages:

<PackageReference Include="Dapper.AOT" Version="1.1.0" />
<PackageReference Include="System.Data.SQLite" Version="2.0.3" />
<PackageReference Include="SQLite" version="3.53.4" />
<PackageReference Include="Dapper" Version="2.1.86" />

To Reproduce

using System;
using System.Data.SQLite;
using Dapper;

[module: DapperAot]

var connection = new SQLiteConnection("Data Source=:memory:");

using var conn = connection.OpenAndReturn();

#pragma warning disable DAP037 // must disable the error to run
var results = conn.Query<Enum>("select * from (VALUES (1), ('c'));");
#pragma warning enable DAP037

// should print out:
// b
// c
foreach (var item in results)
{
    Console.WriteLine($"{item}");
}

enum Enum
{
    a,
    b,
    c
}

Expected behavior
No error should be reported

Additional context
As shown in the example, disabling the error let's the query run anyways with the expected enum values returned
This also works with normal Dapper just fine.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions