koenbeuk / EntityFrameworkCore.Projectables

Project over properties and functions in your linq queries
MIT License
260 stars 17 forks source link

Source generator stopped generating #73

Closed honzapatCZ closed 10 months ago

honzapatCZ commented 1 year ago

Hello After some time the generator stopped generating any output(the runtime cannot resolve the generated function and nothing is shown in obj/generated). But despite the usual errors of source generators I don't see any errors in the console. What would be the proper place to start looking?

honzapatCZ commented 1 year ago

Ohh finally found the error InvalidCastException se zprávou Objekt typu Microsoft.CodeAnalysis.CSharp.Syntax.QualifiedNameSyntax nelze přetypovat na typ Microsoft.CodeAnalysis.CSharp.Syntax.SimpleNameSyntax Now to find why it happens.

honzapatCZ commented 1 year ago

Aaaand found it. Apparently just adding partial namespace already counts as Qualified.

koenbeuk commented 1 year ago

@honzapatCZ Sounds like the source generator crashed on your provided code, this is a bug in this library. Can you share the code that was causing the source generator to fail?

honzapatCZ commented 1 year ago
public class AddressData
{
        .....sth

        [Projectable]
        public bool IsEEA => Country != null && NejAccountingAPI.Models.CountryExtensions.IsEEA(Country.Value);
}
public static class Ext{

        [Projectable]
        public static bool IsEEA(this Country country) => country switch
        {
            Country.AT => true,
            Country.BE => true,
            Country.BG => true,
            Country.HR => true,
            Country.CY => true,
            Country.CZ => true,
            Country.DK => true,
            Country.EE => true,
            Country.FI => true,
            Country.FR => true,
            Country.DE => true,
            Country.GR => true,
            Country.HU => true,
            Country.IE => true,
            Country.IT => true,
            Country.LV => true,
            Country.LT => true,
            Country.LU => true,
            Country.MT => true,
            Country.NL => true,
            Country.PL => true,
            Country.PT => true,
            Country.RO => true,
            Country.SK => true,
            Country.SI => true,
            Country.ES => true,
            Country.SE => true,
            Country.GB => true,
            _ => false
        };
}

The NejAccountingAPI.Models.CountryExtensions.IsEEA itself had an error of using switch in it, but that was not shown as it errored in the AddressData. In the end I removed both Projectables, so I wont be able to use them in queries, but it hopefully doesnt matter.

honzapatCZ commented 1 year ago

And I just found a new Source Generator error InvalidOperationException - Expected at least one conditional expression on the stack this time it's telling me even less xc. Well let's get hunting.

EDIT: Found it, this time Supplier?.Address?.Country != Customer?.Address?.Country was the culprit, tho I'd expect a better error in such case

koenbeuk commented 1 year ago

This seems like a regression, I'll look into it