diff --git a/src/EntityFrameworkCore.Projectables.Generator/ProjectableDescriptor.cs b/src/EntityFrameworkCore.Projectables.Generator/ProjectableDescriptor.cs index f428a76..291cb5b 100644 --- a/src/EntityFrameworkCore.Projectables.Generator/ProjectableDescriptor.cs +++ b/src/EntityFrameworkCore.Projectables.Generator/ProjectableDescriptor.cs @@ -33,6 +33,8 @@ public class ProjectableDescriptor public ParameterListSyntax? ParametersList { get; set; } + public IEnumerable? ParameterTypeNames { get; set; } + public TypeParameterListSyntax? TypeParameterList { get; set; } public SyntaxList? ConstraintClauses { get; set; } diff --git a/src/EntityFrameworkCore.Projectables.Generator/ProjectableInterpreter.cs b/src/EntityFrameworkCore.Projectables.Generator/ProjectableInterpreter.cs index 339b46b..0f21519 100644 --- a/src/EntityFrameworkCore.Projectables.Generator/ProjectableInterpreter.cs +++ b/src/EntityFrameworkCore.Projectables.Generator/ProjectableInterpreter.cs @@ -118,6 +118,8 @@ x is IPropertySymbol xProperty && var expressionSyntaxRewriter = new ExpressionSyntaxRewriter(memberSymbol.ContainingType, nullConditionalRewriteSupport, semanticModel, context); var declarationSyntaxRewriter = new DeclarationSyntaxRewriter(semanticModel); + var methodSymbol = memberSymbol as IMethodSymbol; + var descriptor = new ProjectableDescriptor { UsingDirectives = member.SyntaxTree.GetRoot().DescendantNodes().OfType(), @@ -128,6 +130,14 @@ x is IPropertySymbol xProperty && ParametersList = SyntaxFactory.ParameterList() }; + // Collect parameter type names for method overload disambiguation + if (methodSymbol is not null) + { + descriptor.ParameterTypeNames = methodSymbol.Parameters + .Select(p => p.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)) + .ToList(); + } + if (memberSymbol.ContainingType is INamedTypeSymbol { IsGenericType: true } containingNamedType) { descriptor.ClassTypeParameterList = SyntaxFactory.TypeParameterList(); @@ -196,8 +206,6 @@ x is IPropertySymbol xProperty && ); } - var methodSymbol = memberSymbol as IMethodSymbol; - if (methodSymbol is { IsExtensionMethod: true }) { var targetTypeSymbol = methodSymbol.Parameters.First().Type; diff --git a/src/EntityFrameworkCore.Projectables.Generator/ProjectionExpressionGenerator.cs b/src/EntityFrameworkCore.Projectables.Generator/ProjectionExpressionGenerator.cs index 6f177bc..abc89bd 100644 --- a/src/EntityFrameworkCore.Projectables.Generator/ProjectionExpressionGenerator.cs +++ b/src/EntityFrameworkCore.Projectables.Generator/ProjectionExpressionGenerator.cs @@ -63,7 +63,7 @@ static void Execute(MemberDeclarationSyntax member, Compilation compilation, Sou throw new InvalidOperationException("Expected a memberName here"); } - var generatedClassName = ProjectionExpressionClassNameGenerator.GenerateName(projectable.ClassNamespace, projectable.NestedInClassNames, projectable.MemberName); + var generatedClassName = ProjectionExpressionClassNameGenerator.GenerateName(projectable.ClassNamespace, projectable.NestedInClassNames, projectable.MemberName, projectable.ParameterTypeNames); var generatedFileName = projectable.ClassTypeParameterList is not null ? $"{generatedClassName}-{projectable.ClassTypeParameterList.ChildNodes().Count()}.g.cs" : $"{generatedClassName}.g.cs"; var classSyntax = ClassDeclaration(generatedClassName) diff --git a/src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionClassNameGenerator.cs b/src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionClassNameGenerator.cs index 1c63e77..181b135 100644 --- a/src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionClassNameGenerator.cs +++ b/src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionClassNameGenerator.cs @@ -11,21 +11,31 @@ public static class ProjectionExpressionClassNameGenerator public const string Namespace = "EntityFrameworkCore.Projectables.Generated"; public static string GenerateName(string? namespaceName, IEnumerable? nestedInClassNames, string memberName) + { + return GenerateName(namespaceName, nestedInClassNames, memberName, null); + } + + public static string GenerateName(string? namespaceName, IEnumerable? nestedInClassNames, string memberName, IEnumerable? parameterTypeNames) { var stringBuilder = new StringBuilder(); - return GenerateNameImpl(stringBuilder, namespaceName, nestedInClassNames, memberName); + return GenerateNameImpl(stringBuilder, namespaceName, nestedInClassNames, memberName, parameterTypeNames); } public static string GenerateFullName(string? namespaceName, IEnumerable? nestedInClassNames, string memberName) + { + return GenerateFullName(namespaceName, nestedInClassNames, memberName, null); + } + + public static string GenerateFullName(string? namespaceName, IEnumerable? nestedInClassNames, string memberName, IEnumerable? parameterTypeNames) { var stringBuilder = new StringBuilder(Namespace); stringBuilder.Append('.'); - return GenerateNameImpl(stringBuilder, namespaceName, nestedInClassNames, memberName); + return GenerateNameImpl(stringBuilder, namespaceName, nestedInClassNames, memberName, parameterTypeNames); } - static string GenerateNameImpl(StringBuilder stringBuilder, string? namespaceName, IEnumerable? nestedInClassNames, string memberName) + static string GenerateNameImpl(StringBuilder stringBuilder, string? namespaceName, IEnumerable? nestedInClassNames, string memberName, IEnumerable? parameterTypeNames) { stringBuilder.Append(namespaceName?.Replace('.', '_')); stringBuilder.Append('_'); @@ -57,6 +67,35 @@ static string GenerateNameImpl(StringBuilder stringBuilder, string? namespaceNam } stringBuilder.Append(memberName); + // Add parameter types to make method overloads unique + if (parameterTypeNames is not null) + { + var parameterIndex = 0; + foreach (var parameterTypeName in parameterTypeNames) + { + stringBuilder.Append("_P"); + stringBuilder.Append(parameterIndex); + stringBuilder.Append('_'); + // Replace characters that are not valid in type names with underscores + var sanitizedTypeName = parameterTypeName + .Replace("global::", "") // Remove global:: prefix + .Replace('.', '_') + .Replace('<', '_') + .Replace('>', '_') + .Replace(',', '_') + .Replace(' ', '_') + .Replace('[', '_') + .Replace(']', '_') + .Replace('`', '_') + .Replace(':', '_') // Additional safety for any remaining colons + .Replace('?', '_'); // Handle nullable reference types + stringBuilder.Append(sanitizedTypeName); + parameterIndex++; + } + } + + // Add generic arity at the very end (after parameter types) + // This matches how the CLR names generic types if (arity > 0) { stringBuilder.Append('`'); diff --git a/src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionResolver.cs b/src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionResolver.cs index b9062dd..55cb469 100644 --- a/src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionResolver.cs +++ b/src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionResolver.cs @@ -62,7 +62,33 @@ public LambdaExpression FindGeneratedExpression(MemberInfo projectableMemberInfo static LambdaExpression? GetExpressionFromGeneratedType(MemberInfo projectableMemberInfo) { var declaringType = projectableMemberInfo.DeclaringType ?? throw new InvalidOperationException("Expected a valid type here"); - var generatedContainingTypeName = ProjectionExpressionClassNameGenerator.GenerateFullName(declaringType.Namespace, declaringType.GetNestedTypePath().Select(x => x.Name), projectableMemberInfo.Name); + + // Keep track of the original declaring type's generic arguments for later use + var originalDeclaringType = declaringType; + + // For generic types, use the generic type definition to match the generated name + // which is based on the open generic type + if (declaringType.IsGenericType && !declaringType.IsGenericTypeDefinition) + { + declaringType = declaringType.GetGenericTypeDefinition(); + } + + // Get parameter types for method overload disambiguation + // Use the same format as Roslyn's SymbolDisplayFormat.FullyQualifiedFormat + // which uses C# keywords for primitive types (int, string, etc.) + string[]? parameterTypeNames = null; + if (projectableMemberInfo is MethodInfo method) + { + // For generic methods, use the generic definition to get parameter types + // This ensures type parameters like TEntity are used instead of concrete types + var methodToInspect = method.IsGenericMethod ? method.GetGenericMethodDefinition() : method; + + parameterTypeNames = methodToInspect.GetParameters() + .Select(p => GetFullTypeName(p.ParameterType)) + .ToArray(); + } + + var generatedContainingTypeName = ProjectionExpressionClassNameGenerator.GenerateFullName(declaringType.Namespace, declaringType.GetNestedTypePath().Select(x => x.Name), projectableMemberInfo.Name, parameterTypeNames); var expressionFactoryType = declaringType.Assembly.GetType(generatedContainingTypeName); @@ -70,7 +96,7 @@ public LambdaExpression FindGeneratedExpression(MemberInfo projectableMemberInfo { if (expressionFactoryType.IsGenericTypeDefinition) { - expressionFactoryType = expressionFactoryType.MakeGenericType(declaringType.GenericTypeArguments); + expressionFactoryType = expressionFactoryType.MakeGenericType(originalDeclaringType.GenericTypeArguments); } var expressionFactoryMethod = expressionFactoryType.GetMethod("Expression", BindingFlags.Static | BindingFlags.NonPublic); @@ -93,6 +119,92 @@ public LambdaExpression FindGeneratedExpression(MemberInfo projectableMemberInfo return null; } + + static string GetFullTypeName(Type type) + { + // Handle generic type parameters (e.g., T, TEntity) + if (type.IsGenericParameter) + { + return type.Name; + } + + // Handle array types + if (type.IsArray) + { + var elementType = type.GetElementType(); + if (elementType == null) + { + // Fallback for edge cases where GetElementType() might return null + return type.Name; + } + + var rank = type.GetArrayRank(); + var elementTypeName = GetFullTypeName(elementType); + + if (rank == 1) + { + return $"{elementTypeName}[]"; + } + else + { + var commas = new string(',', rank - 1); + return $"{elementTypeName}[{commas}]"; + } + } + + // Map primitive types to their C# keyword equivalents to match Roslyn's output + var typeKeyword = GetCSharpKeyword(type); + if (typeKeyword != null) + { + return typeKeyword; + } + + // For generic types, construct the full name matching Roslyn's format + if (type.IsGenericType) + { + var genericTypeDef = type.GetGenericTypeDefinition(); + var genericArgs = type.GetGenericArguments(); + var baseName = genericTypeDef.FullName ?? genericTypeDef.Name; + + // Remove the `n suffix (e.g., `1, `2) + var backtickIndex = baseName.IndexOf('`'); + if (backtickIndex > 0) + { + baseName = baseName.Substring(0, backtickIndex); + } + + var args = string.Join(", ", genericArgs.Select(GetFullTypeName)); + return $"{baseName}<{args}>"; + } + + if (type.FullName != null) + { + // Replace + with . for nested types to match Roslyn's format + return type.FullName.Replace('+', '.'); + } + + return type.Name; + } + + static string? GetCSharpKeyword(Type type) + { + if (type == typeof(bool)) return "bool"; + if (type == typeof(byte)) return "byte"; + if (type == typeof(sbyte)) return "sbyte"; + if (type == typeof(char)) return "char"; + if (type == typeof(decimal)) return "decimal"; + if (type == typeof(double)) return "double"; + if (type == typeof(float)) return "float"; + if (type == typeof(int)) return "int"; + if (type == typeof(uint)) return "uint"; + if (type == typeof(long)) return "long"; + if (type == typeof(ulong)) return "ulong"; + if (type == typeof(short)) return "short"; + if (type == typeof(ushort)) return "ushort"; + if (type == typeof(object)) return "object"; + if (type == typeof(string)) return "string"; + return null; + } } } } diff --git a/tests/EntityFrameworkCore.Projectables.FunctionalTests/MethodOverloadsTests.MethodOverload_WithIntParameter.verified.txt b/tests/EntityFrameworkCore.Projectables.FunctionalTests/MethodOverloadsTests.MethodOverload_WithIntParameter.verified.txt new file mode 100644 index 0000000..e5e6812 --- /dev/null +++ b/tests/EntityFrameworkCore.Projectables.FunctionalTests/MethodOverloadsTests.MethodOverload_WithIntParameter.verified.txt @@ -0,0 +1,2 @@ +SELECT [e].[Id], [e].[Id] + 10 AS [Result] +FROM [Entity] AS [e] \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.FunctionalTests/MethodOverloadsTests.MethodOverload_WithStringParameter.verified.txt b/tests/EntityFrameworkCore.Projectables.FunctionalTests/MethodOverloadsTests.MethodOverload_WithStringParameter.verified.txt new file mode 100644 index 0000000..d9749ce --- /dev/null +++ b/tests/EntityFrameworkCore.Projectables.FunctionalTests/MethodOverloadsTests.MethodOverload_WithStringParameter.verified.txt @@ -0,0 +1,2 @@ +SELECT [e].[Id], CAST(LEN(N'Hello_' + [e].[Name]) AS int) AS [Result] +FROM [Entity] AS [e] \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.FunctionalTests/MethodOverloadsTests.cs b/tests/EntityFrameworkCore.Projectables.FunctionalTests/MethodOverloadsTests.cs new file mode 100644 index 0000000..dbe24c4 --- /dev/null +++ b/tests/EntityFrameworkCore.Projectables.FunctionalTests/MethodOverloadsTests.cs @@ -0,0 +1,48 @@ +using System.Linq; +using System.Threading.Tasks; +using EntityFrameworkCore.Projectables; +using EntityFrameworkCore.Projectables.FunctionalTests.Helpers; +using Microsoft.EntityFrameworkCore; +using VerifyXunit; +using Xunit; + +namespace EntityFrameworkCore.Projectables.FunctionalTests +{ + [UsesVerify] + public class MethodOverloadsTests + { + public record Entity + { + public int Id { get; set; } + public string Name { get; set; } = ""; + + [Projectable] + public int Calculate(int x) => Id + x; + + [Projectable] + public int Calculate(string prefix) => (prefix + Name).Length; + } + + [Fact] + public Task MethodOverload_WithIntParameter() + { + using var dbContext = new SampleDbContext(); + + var query = dbContext.Set() + .Select(e => new { e.Id, Result = e.Calculate(10) }); + + return Verifier.Verify(query.ToQueryString()); + } + + [Fact] + public Task MethodOverload_WithStringParameter() + { + using var dbContext = new SampleDbContext(); + + var query = dbContext.Set() + .Select(e => new { e.Id, Result = e.Calculate("Hello_") }); + + return Verifier.Verify(query.ToQueryString()); + } + } +} diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BooleanSimpleTernary_WithRewriteSupport_IsBeingRewritten.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BooleanSimpleTernary_WithRewriteSupport_IsBeingRewritten.verified.txt index 2e61855..8fb3344 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BooleanSimpleTernary_WithRewriteSupport_IsBeingRewritten.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BooleanSimpleTernary_WithRewriteSupport_IsBeingRewritten.verified.txt @@ -8,7 +8,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Test + static class Foo_C_Test_P0_object { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Cast.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Cast.verified.txt index 0035477..cf931bf 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Cast.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Cast.verified.txt @@ -6,7 +6,7 @@ using Projectables.Repro; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Projectables_Repro_SomeExtensions_AsSomeResult + static class Projectables_Repro_SomeExtensions_AsSomeResult_P0_Projectables_Repro_SomeEntity { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DeclarationTypeNamesAreGettingFullyQualified.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DeclarationTypeNamesAreGettingFullyQualified.verified.txt index dd9cb44..cec10d1 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DeclarationTypeNamesAreGettingFullyQualified.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DeclarationTypeNamesAreGettingFullyQualified.verified.txt @@ -9,7 +9,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_EntityExtensions_Entity_Something + static class Foo_EntityExtensions_Entity_Something_P0_Foo_EntityExtensions_Entity { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DefaultValuesGetRemoved.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DefaultValuesGetRemoved.verified.txt index 0cb3392..b0c3e64 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DefaultValuesGetRemoved.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DefaultValuesGetRemoved.verified.txt @@ -5,7 +5,7 @@ using EntityFrameworkCore.Projectables; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _Foo_Calculate + static class _Foo_Calculate_P0_int { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.EnumAccessor.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.EnumAccessor.verified.txt index ce25012..d108871 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.EnumAccessor.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.EnumAccessor.verified.txt @@ -5,7 +5,7 @@ using EntityFrameworkCore.Projectables; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _SomeExtensions_Test + static class _SomeExtensions_Test_P0_SomeFlag { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericMethods_AreRewritten.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericMethods_AreRewritten.verified.txt index 5468c2a..973cde3 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericMethods_AreRewritten.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericMethods_AreRewritten.verified.txt @@ -9,7 +9,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_EntityExtensions_EnforceString + static class Foo_EntityExtensions_EnforceString_P0_T { static global::System.Linq.Expressions.Expression> Expression() where T : unmanaged diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericNullableReferenceTypesAreBeingEliminated.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericNullableReferenceTypesAreBeingEliminated.verified.txt index 847f758..0993caa 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericNullableReferenceTypesAreBeingEliminated.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericNullableReferenceTypesAreBeingEliminated.verified.txt @@ -9,7 +9,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_NextFoo + static class Foo_C_NextFoo_P0_System_Collections_Generic_List_object__P1_System_Collections_Generic_List_int__ { static global::System.Linq.Expressions.Expression, global::System.Collections.Generic.List, global::System.Collections.Generic.List>> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MethodOverloads_WithDifferentParameterCounts.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MethodOverloads_WithDifferentParameterCounts.verified.txt new file mode 100644 index 0000000..f383978 --- /dev/null +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MethodOverloads_WithDifferentParameterCounts.verified.txt @@ -0,0 +1,37 @@ +[ +// +#nullable disable +using System; +using EntityFrameworkCore.Projectables; +using Foo; + +namespace EntityFrameworkCore.Projectables.Generated +{ + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_Method_P0_int + { + static global::System.Linq.Expressions.Expression> Expression() + { + return (global::Foo.C @this, int x) => x; + } + } +} + +// +#nullable disable +using System; +using EntityFrameworkCore.Projectables; +using Foo; + +namespace EntityFrameworkCore.Projectables.Generated +{ + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_Method_P0_int_P1_int + { + static global::System.Linq.Expressions.Expression> Expression() + { + return (global::Foo.C @this, int x, int y) => x + y; + } + } +} +] \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MethodOverloads_WithDifferentParameterTypes.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MethodOverloads_WithDifferentParameterTypes.verified.txt new file mode 100644 index 0000000..3113734 --- /dev/null +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MethodOverloads_WithDifferentParameterTypes.verified.txt @@ -0,0 +1,37 @@ +[ +// +#nullable disable +using System; +using EntityFrameworkCore.Projectables; +using Foo; + +namespace EntityFrameworkCore.Projectables.Generated +{ + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_Method_P0_int + { + static global::System.Linq.Expressions.Expression> Expression() + { + return (global::Foo.C @this, int x) => x; + } + } +} + +// +#nullable disable +using System; +using EntityFrameworkCore.Projectables; +using Foo; + +namespace EntityFrameworkCore.Projectables.Generated +{ + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_Method_P0_string + { + static global::System.Linq.Expressions.Expression> Expression() + { + return (global::Foo.C @this, string s) => s.Length; + } + } +} +] \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MixPrimaryConstructorAndProperties.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MixPrimaryConstructorAndProperties.verified.txt index bb4a054..84bf825 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MixPrimaryConstructorAndProperties.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MixPrimaryConstructorAndProperties.verified.txt @@ -9,7 +9,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_EntityExtensions_Entity_Something + static class Foo_EntityExtensions_Entity_Something_P0_Foo_EntityExtensions_Entity { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullConditionalNullCoalesceTypeConversion.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullConditionalNullCoalesceTypeConversion.verified.txt index 90ab28c..f366397 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullConditionalNullCoalesceTypeConversion.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullConditionalNullCoalesceTypeConversion.verified.txt @@ -5,7 +5,7 @@ using EntityFrameworkCore.Projectables; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _Foo_SomeNumber + static class _Foo_SomeNumber_P0_Foo { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableElementAndMemberBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableElementAndMemberBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt index 3d8995b..0153a0f 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableElementAndMemberBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableElementAndMemberBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt @@ -9,7 +9,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_EntityExtensions_GetFirstRelatedIgnoreNulls + static class Foo_EntityExtensions_GetFirstRelatedIgnoreNulls_P0_Foo_EntityExtensions_Entity { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableElementAndMemberBinding_WithRewriteSupport_IsBeingRewritten.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableElementAndMemberBinding_WithRewriteSupport_IsBeingRewritten.verified.txt index 7c950f2..010f995 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableElementAndMemberBinding_WithRewriteSupport_IsBeingRewritten.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableElementAndMemberBinding_WithRewriteSupport_IsBeingRewritten.verified.txt @@ -9,7 +9,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_EntityExtensions_GetFirstRelatedIgnoreNulls + static class Foo_EntityExtensions_GetFirstRelatedIgnoreNulls_P0_Foo_EntityExtensions_Entity { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableElementBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableElementBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt index 0420fa1..aff9e8b 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableElementBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableElementBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt @@ -8,7 +8,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_GetFirst + static class Foo_C_GetFirst_P0_string { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableElementBinding_WithRewriteSupport_IsBeingRewritten.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableElementBinding_WithRewriteSupport_IsBeingRewritten.verified.txt index 76ccb92..c881b5d 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableElementBinding_WithRewriteSupport_IsBeingRewritten.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableElementBinding_WithRewriteSupport_IsBeingRewritten.verified.txt @@ -8,7 +8,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_GetFirst + static class Foo_C_GetFirst_P0_string { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableMemberBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableMemberBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt index b8ce72b..97ef48d 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableMemberBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableMemberBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt @@ -8,7 +8,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_GetLength + static class Foo_C_GetLength_P0_string { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableMemberBinding_WithRewriteSupport_IsBeingRewritten.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableMemberBinding_WithRewriteSupport_IsBeingRewritten.verified.txt index 402a7e3..4b30f5d 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableMemberBinding_WithRewriteSupport_IsBeingRewritten.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableMemberBinding_WithRewriteSupport_IsBeingRewritten.verified.txt @@ -8,7 +8,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_GetLength + static class Foo_C_GetLength_P0_string { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableParameters_WithRewriteSupport_IsBeingRewritten.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableParameters_WithRewriteSupport_IsBeingRewritten.verified.txt index 19c08b4..fc9af02 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableParameters_WithRewriteSupport_IsBeingRewritten.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableParameters_WithRewriteSupport_IsBeingRewritten.verified.txt @@ -9,7 +9,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_EntityExtensions_GetFirstName + static class Foo_EntityExtensions_GetFirstName_P0_Foo_EntityExtensions_Entity { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypeCastOperatorGetsEliminated.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypeCastOperatorGetsEliminated.verified.txt index aa6fd95..48f6a5f 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypeCastOperatorGetsEliminated.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypeCastOperatorGetsEliminated.verified.txt @@ -9,7 +9,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_NullableReferenceType + static class Foo_C_NullableReferenceType_P0_object { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypesAreBeingEliminated.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypesAreBeingEliminated.verified.txt index 88826b1..f880d94 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypesAreBeingEliminated.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypesAreBeingEliminated.verified.txt @@ -8,7 +8,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_NextFoo + static class Foo_C_NextFoo_P0_object_P1_int_ { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableSimpleElementBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableSimpleElementBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt index 827dcb3..fe0230a 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableSimpleElementBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableSimpleElementBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt @@ -8,7 +8,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_GetFirst + static class Foo_C_GetFirst_P0_string { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableSimpleElementBinding_WithRewriteSupport_IsBeingRewritten.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableSimpleElementBinding_WithRewriteSupport_IsBeingRewritten.verified.txt index a6732e1..d34d367 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableSimpleElementBinding_WithRewriteSupport_IsBeingRewritten.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableSimpleElementBinding_WithRewriteSupport_IsBeingRewritten.verified.txt @@ -8,7 +8,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_GetFirst + static class Foo_C_GetFirst_P0_string { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableValueCastOperatorsPersist.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableValueCastOperatorsPersist.verified.txt index 3f93eac..8cfc5e5 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableValueCastOperatorsPersist.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableValueCastOperatorsPersist.verified.txt @@ -9,7 +9,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_NullableValueType + static class Foo_C_NullableValueType_P0_object { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ParamsModifiedGetsRemoved.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ParamsModifiedGetsRemoved.verified.txt index 3f5152f..4231778 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ParamsModifiedGetsRemoved.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ParamsModifiedGetsRemoved.verified.txt @@ -5,7 +5,7 @@ using EntityFrameworkCore.Projectables; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _Foo_First + static class _Foo_First_P0_int__ { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithMultipleArguments.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithMultipleArguments.verified.txt index e6f1903..6a50a32 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithMultipleArguments.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithMultipleArguments.verified.txt @@ -7,7 +7,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static class Foo_C_Foo_P0_int_P1_string_P2_object { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithSingleArgument.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithSingleArgument.verified.txt index 38b5559..864fb95 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithSingleArgument.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithSingleArgument.verified.txt @@ -7,7 +7,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static class Foo_C_Foo_P0_int { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod.verified.txt index e62ff27..8e8012f 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod.verified.txt @@ -8,7 +8,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static class Foo_C_Foo_P0_Foo_D { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod2.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod2.verified.txt index 4211a85..b17f73b 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod2.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod2.verified.txt @@ -8,7 +8,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static class Foo_C_Foo_P0_int { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod3.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod3.verified.txt index 0bd0865..bf3ca9c 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod3.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod3.verified.txt @@ -8,7 +8,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo1 + static class Foo_C_Foo1_P0_int { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod4.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod4.verified.txt index 636c199..03de978 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod4.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod4.verified.txt @@ -8,7 +8,7 @@ using Foo; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo1 + static class Foo_C_Foo1_P0_object { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMethodWithParameters.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMethodWithParameters.verified.txt index 6bfafc8..f5a9570 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMethodWithParameters.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMethodWithParameters.verified.txt @@ -8,7 +8,7 @@ using EntityFrameworkCore.Projectables; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _Foo_Zero + static class _Foo_Zero_P0_int { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SwitchExpressionWithConstantPattern.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SwitchExpressionWithConstantPattern.verified.txt index 00c6d5e..e906cc7 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SwitchExpressionWithConstantPattern.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SwitchExpressionWithConstantPattern.verified.txt @@ -5,7 +5,7 @@ using EntityFrameworkCore.Projectables; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _Foo_SomeNumber + static class _Foo_SomeNumber_P0_int { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SwitchExpressionWithTypePattern.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SwitchExpressionWithTypePattern.verified.txt index dcb1ec1..c9efd3c 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SwitchExpressionWithTypePattern.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SwitchExpressionWithTypePattern.verified.txt @@ -5,7 +5,7 @@ using EntityFrameworkCore.Projectables; namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _ItemMapper_ToData + static class _ItemMapper_ToData_P0_Item { static global::System.Linq.Expressions.Expression> Expression() { diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.cs b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.cs index 2a74263..5267db2 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.cs +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.cs @@ -1902,6 +1902,66 @@ public Task GenericTypesWithConstraints() return Verifier.Verify(result.GeneratedTrees[0].ToString()); } + [Fact] + public Task MethodOverloads_WithDifferentParameterTypes() + { + var compilation = CreateCompilation(@" +using System; +using EntityFrameworkCore.Projectables; +namespace Foo { + class C { + [Projectable] + public int Method(int x) => x; + + [Projectable] + public int Method(string s) => s.Length; + } +} +"); + + var result = RunGenerator(compilation); + + Assert.Empty(result.Diagnostics); + Assert.Equal(2, result.GeneratedTrees.Length); + + // Verify both overloads are generated with distinct names + var generatedFiles = result.GeneratedTrees.Select(t => t.FilePath).ToList(); + Assert.Contains(generatedFiles, f => f.Contains("Method_P0_int")); + Assert.Contains(generatedFiles, f => f.Contains("Method_P0_string")); + + return Verifier.Verify(result.GeneratedTrees.Select(t => t.ToString())); + } + + [Fact] + public Task MethodOverloads_WithDifferentParameterCounts() + { + var compilation = CreateCompilation(@" +using System; +using EntityFrameworkCore.Projectables; +namespace Foo { + class C { + [Projectable] + public int Method(int x) => x; + + [Projectable] + public int Method(int x, int y) => x + y; + } +} +"); + + var result = RunGenerator(compilation); + + Assert.Empty(result.Diagnostics); + Assert.Equal(2, result.GeneratedTrees.Length); + + // Verify both overloads are generated with distinct names + var generatedFiles = result.GeneratedTrees.Select(t => t.FilePath).ToList(); + Assert.Contains(generatedFiles, f => f.Contains("Method_P0_int.g.cs")); + Assert.Contains(generatedFiles, f => f.Contains("Method_P0_int_P1_int.g.cs")); + + return Verifier.Verify(result.GeneratedTrees.Select(t => t.ToString())); + } + #region Helpers Compilation CreateCompilation(string source, bool expectedToCompile = true)