jitbit / MapDataReader

Super fast mapping DataReader to strongly typed object, Using AOT source generator.
MIT License
57 stars 10 forks source link

Generation is broken when all class names are not unique #5

Open ronnieoverby opened 5 months ago

ronnieoverby commented 5 months ago

I use a code generator to generate classes to represent my sql schema.

The generator generates code like this:

namespace dbo // schema name
{
    partial class Customers // table name
    {
           partial class RowData
           {
               // property for each column
           }

    } 

    partial class Orders// table name
    {
           partial class RowData
           {
               // property for each column
           }

    } 
}

In another file I put your attribute on my RowData types:

    [GenerateDataReaderMapper]
    public partial class RowData;

But since I have multiple types with the same name, your generator fails to do anything.

ShawnTheBeachy commented 4 months ago

Same issue here. Would be great to be able to specify either a namespace or a custom extension method name. Preferably both.

Namespace

[GenerateDataReaderMapper(NameSpace = "MyProject.Customers")]
public sealed class Customer;
[GenerateDataReaderMapper(NameSpace = "MyProject.Orders")]
public sealed class Customer;

Method name

[GenerateDataReaderMapper(MethodName = "ToCustomer")]
public sealed class Customer;

...

reader.ToCustomer();
[GenerateDataReaderMapper(MethodName = "ToOrderCustomer")]
public sealed class Customer;

...

reader.ToOrderCustomer();