diff --git a/src/EntityFrameworkCore.Projectables.Generator/DeclarationSyntaxRewriter.cs b/src/EntityFrameworkCore.Projectables.Generator/DeclarationSyntaxRewriter.cs index e63bf5c..51094f1 100644 --- a/src/EntityFrameworkCore.Projectables.Generator/DeclarationSyntaxRewriter.cs +++ b/src/EntityFrameworkCore.Projectables.Generator/DeclarationSyntaxRewriter.cs @@ -28,7 +28,7 @@ namespace EntityFrameworkCore.Projectables.Generator visitedNode = visitedParameterSyntax.WithModifiers(node.Modifiers.RemoveAt(thisKeywordIndex)); } - // Strip the parans keyword of any parameter + // Strip the params keyword of any parameter var paramsKeywordIndex = ((ParameterSyntax)visitedNode).Modifiers.IndexOf(SyntaxKind.ParamsKeyword); if (paramsKeywordIndex != -1) { @@ -73,6 +73,19 @@ namespace EntityFrameworkCore.Projectables.Generator return base.VisitIdentifierName(node); } + public override SyntaxNode? VisitGenericName(GenericNameSyntax node) + { + var typeInfo = _semanticModel.GetTypeInfo(node); + if (typeInfo.Type is not null) + { + return SyntaxFactory.ParseTypeName( + typeInfo.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + ).WithTriviaFrom(node); + } + + return base.VisitGenericName(node); + } + public override SyntaxNode? VisitQualifiedName(QualifiedNameSyntax node) { var typeInfo = _semanticModel.GetTypeInfo(node); diff --git a/src/EntityFrameworkCore.Projectables.Generator/EntityFrameworkCore.Projectables.Generator.csproj b/src/EntityFrameworkCore.Projectables.Generator/EntityFrameworkCore.Projectables.Generator.csproj index 80111b0..fd91bc6 100644 --- a/src/EntityFrameworkCore.Projectables.Generator/EntityFrameworkCore.Projectables.Generator.csproj +++ b/src/EntityFrameworkCore.Projectables.Generator/EntityFrameworkCore.Projectables.Generator.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.0 $(NoWarn);NU5128 false diff --git a/src/EntityFrameworkCore.Projectables.Generator/ProjectableDescriptor.cs b/src/EntityFrameworkCore.Projectables.Generator/ProjectableDescriptor.cs index 4142a2f..b5344f8 100644 --- a/src/EntityFrameworkCore.Projectables.Generator/ProjectableDescriptor.cs +++ b/src/EntityFrameworkCore.Projectables.Generator/ProjectableDescriptor.cs @@ -11,8 +11,6 @@ namespace EntityFrameworkCore.Projectables.Generator { public class ProjectableDescriptor { - public IEnumerable? UsingDirectives { get; set; } - public string? ClassNamespace { get; set; } public IEnumerable? NestedInClassNames { get; set; } @@ -23,6 +21,10 @@ namespace EntityFrameworkCore.Projectables.Generator public string? ClassName { get; set; } + public TypeParameterListSyntax? ClassTypeParameterList { get; set; } + + public SyntaxList? ClassConstraintClauses { get; set; } + public string? MemberName { get; set; } public string? ReturnTypeName { get; set; } @@ -31,8 +33,8 @@ namespace EntityFrameworkCore.Projectables.Generator public TypeParameterListSyntax? TypeParameterList { get; set; } - public IEnumerable? ConstraintClauses { get; set; } + public SyntaxList? ConstraintClauses { get; set; } - public SyntaxNode? Body { get; set; } + public ExpressionSyntax? ExpressionBody { get; set; } } } diff --git a/src/EntityFrameworkCore.Projectables.Generator/ProjectableInterpreter.cs b/src/EntityFrameworkCore.Projectables.Generator/ProjectableInterpreter.cs index 7418124..bcf315e 100644 --- a/src/EntityFrameworkCore.Projectables.Generator/ProjectableInterpreter.cs +++ b/src/EntityFrameworkCore.Projectables.Generator/ProjectableInterpreter.cs @@ -123,23 +123,52 @@ namespace EntityFrameworkCore.Projectables.Generator ClassNamespace = memberSymbol.ContainingType.ContainingNamespace.IsGlobalNamespace ? null : memberSymbol.ContainingType.ContainingNamespace.ToDisplayString(), MemberName = memberSymbol.Name, NestedInClassNames = GetNestedInClassPath(memberSymbol.ContainingType), - ParametersList = SyntaxFactory.ParameterList(), - TypeParameterList = SyntaxFactory.TypeParameterList() + ParametersList = SyntaxFactory.ParameterList() }; + if (memberSymbol.ContainingType is INamedTypeSymbol { IsGenericType: true } containingNamedType) + { + descriptor.ClassTypeParameterList = SyntaxFactory.TypeParameterList(); + + foreach (var additionalClassTypeParameter in containingNamedType.TypeParameters) + { + descriptor.ClassTypeParameterList = descriptor.ClassTypeParameterList.AddParameters( + SyntaxFactory.TypeParameter(additionalClassTypeParameter.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)) + ); + + if (!additionalClassTypeParameter.ConstraintTypes.IsDefaultOrEmpty) + { + descriptor.ClassConstraintClauses ??= SyntaxFactory.List(); + + descriptor.ClassConstraintClauses = descriptor.ClassConstraintClauses.Value.Add( + SyntaxFactory.TypeParameterConstraintClause( + SyntaxFactory.IdentifierName(additionalClassTypeParameter.Name), + SyntaxFactory.SeparatedList( + additionalClassTypeParameter + .ConstraintTypes + .Select(c => SyntaxFactory.TypeConstraint( + SyntaxFactory.IdentifierName(c.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)) + )) + ) + ) + ); + } + + // todo: add additional type constraints + } + } + if (!member.Modifiers.Any(SyntaxKind.StaticKeyword)) { descriptor.ParametersList = descriptor.ParametersList.AddParameters( SyntaxFactory.Parameter( - SyntaxFactory.Identifier("@this") - ).WithType( - SyntaxFactory.ParseTypeName( - memberSymbol.ContainingType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) - ) - .WithTrailingTrivia( - SyntaxFactory.SyntaxTrivia(SyntaxKind.WhitespaceTrivia, " ") - ) + SyntaxFactory.Identifier("@this") + ) + .WithType( + SyntaxFactory.ParseTypeName( + memberSymbol.ContainingType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) ) + ) ); } @@ -169,7 +198,7 @@ namespace EntityFrameworkCore.Projectables.Generator var returnType = declarationSyntaxRewriter.Visit(methodDeclarationSyntax.ReturnType); descriptor.ReturnTypeName = returnType.ToString(); - descriptor.Body = expressionSyntaxRewriter.Visit(methodDeclarationSyntax.ExpressionBody.Expression); + descriptor.ExpressionBody = (ExpressionSyntax)expressionSyntaxRewriter.Visit(methodDeclarationSyntax.ExpressionBody.Expression); foreach (var additionalParameter in ((ParameterListSyntax)declarationSyntaxRewriter.Visit(methodDeclarationSyntax.ParameterList)).Parameters) { descriptor.ParametersList = descriptor.ParametersList.AddParameters(additionalParameter); @@ -177,6 +206,7 @@ namespace EntityFrameworkCore.Projectables.Generator if (methodDeclarationSyntax.TypeParameterList is not null) { + descriptor.TypeParameterList = SyntaxFactory.TypeParameterList(); foreach (var additionalTypeParameter in ((TypeParameterListSyntax)declarationSyntaxRewriter.Visit(methodDeclarationSyntax.TypeParameterList)).Parameters) { descriptor.TypeParameterList = descriptor.TypeParameterList.AddParameters(additionalTypeParameter); @@ -185,8 +215,11 @@ namespace EntityFrameworkCore.Projectables.Generator if (methodDeclarationSyntax.ConstraintClauses.Any()) { - descriptor.ConstraintClauses = methodDeclarationSyntax.ConstraintClauses - .Select(x => (TypeParameterConstraintClauseSyntax)declarationSyntaxRewriter.Visit(x)); + descriptor.ConstraintClauses = SyntaxFactory.List( + methodDeclarationSyntax + .ConstraintClauses + .Select(x => (TypeParameterConstraintClauseSyntax)declarationSyntaxRewriter.Visit(x)) + ); } } else if (memberBody is PropertyDeclarationSyntax propertyDeclarationSyntax) @@ -201,20 +234,13 @@ namespace EntityFrameworkCore.Projectables.Generator var returnType = declarationSyntaxRewriter.Visit(propertyDeclarationSyntax.Type); descriptor.ReturnTypeName = returnType.ToString(); - descriptor.Body = expressionSyntaxRewriter.Visit(propertyDeclarationSyntax.ExpressionBody.Expression); + descriptor.ExpressionBody = (ExpressionSyntax)expressionSyntaxRewriter.Visit(propertyDeclarationSyntax.ExpressionBody.Expression); } else { return null; } - descriptor.UsingDirectives = - member.SyntaxTree - .GetRoot() - .DescendantNodes() - .OfType() - .Select(x => x.ToString()); - return descriptor; } } diff --git a/src/EntityFrameworkCore.Projectables.Generator/ProjectionExpressionGenerator.cs b/src/EntityFrameworkCore.Projectables.Generator/ProjectionExpressionGenerator.cs index d164807..c965e95 100644 --- a/src/EntityFrameworkCore.Projectables.Generator/ProjectionExpressionGenerator.cs +++ b/src/EntityFrameworkCore.Projectables.Generator/ProjectionExpressionGenerator.cs @@ -8,9 +8,11 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; using System.Linq; +using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading; using System.Threading.Tasks; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace EntityFrameworkCore.Projectables.Generator { @@ -19,6 +21,22 @@ namespace EntityFrameworkCore.Projectables.Generator { private const string ProjectablesAttributeName = "EntityFrameworkCore.Projectables.ProjectableAttribute"; + static readonly AttributeSyntax _editorBrowsableAttribute = + Attribute( + ParseName("global::System.ComponentModel.EditorBrowsable"), + AttributeArgumentList( + SingletonSeparatedList( + AttributeArgument( + MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + IdentifierName("global::System.ComponentModel.EditorBrowsableState"), + IdentifierName("Never") + ) + ) + ) + ) + ); + public void Initialize(IncrementalGeneratorInitializationContext context) { // Do a simple filter for members @@ -91,76 +109,84 @@ namespace EntityFrameworkCore.Projectables.Generator throw new InvalidOperationException("Expected a memberName here"); } - resultBuilder.Clear(); - - resultBuilder.AppendLine("// "); - - if (projectable.UsingDirectives is not null) - { - foreach (var usingDirective in projectable.UsingDirectives.Distinct()) - { - resultBuilder.AppendLine(usingDirective); - } - } - - if (projectable.TargetClassNamespace is not null) - { - var targetClassUsingDirective = $"using {projectable.TargetClassNamespace};"; - - if (!projectable.UsingDirectives.Contains(targetClassUsingDirective)) - { - resultBuilder.AppendLine(targetClassUsingDirective); - } - } - - if (projectable.ClassNamespace is not null && projectable.ClassNamespace != projectable.TargetClassNamespace) - { - var classUsingDirective = $"using {projectable.ClassNamespace};"; - - if (!projectable.UsingDirectives.Contains(classUsingDirective)) - { - resultBuilder.AppendLine(classUsingDirective); - } - } - var generatedClassName = ProjectionExpressionClassNameGenerator.GenerateName(projectable.ClassNamespace, projectable.NestedInClassNames, projectable.MemberName); + var generatedFileName = projectable.ClassTypeParameterList is not null ? $"{generatedClassName}-{projectable.ClassTypeParameterList.ChildNodes().Count()}.g.cs" : $"{generatedClassName}.g.cs"; - var lambdaTypeArguments = SyntaxFactory.TypeArgumentList( - SyntaxFactory.SeparatedList( - projectable.ParametersList?.Parameters.Where(p => p.Type is not null).Select(p => p.Type!) + var classSyntax = ClassDeclaration(generatedClassName) + .WithModifiers(TokenList(Token(SyntaxKind.StaticKeyword))) + .WithTypeParameterList(projectable.ClassTypeParameterList) + .WithConstraintClauses(projectable.ClassConstraintClauses ?? List()) + .AddAttributeLists( + AttributeList() + .AddAttributes(_editorBrowsableAttribute) ) - ); + .AddMembers( + MethodDeclaration( + GenericName( + Identifier("global::System.Linq.Expressions.Expression"), + TypeArgumentList( + SingletonSeparatedList( + (TypeSyntax)GenericName( + Identifier("global::System.Func"), + GetLambdaTypeArgumentListSyntax(projectable) + ) + ) + ) + ), + "Expression" + ) + .WithModifiers(TokenList(Token(SyntaxKind.StaticKeyword))) + .WithTypeParameterList(projectable.TypeParameterList) + .WithConstraintClauses(projectable.ConstraintClauses ?? List()) + .WithBody( + Block( + ReturnStatement( + ParenthesizedLambdaExpression( + projectable.ParametersList ?? ParameterList(), + null, + projectable.ExpressionBody + ) + ) + ) + ) + ); - resultBuilder.Append($@" -namespace EntityFrameworkCore.Projectables.Generated #nullable disable -{{ - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class {generatedClassName} - {{ - public static System.Linq.Expressions.Expression> Expression{(projectable.TypeParameterList?.Parameters.Any() == true ? projectable.TypeParameterList.ToString() : string.Empty)}()"); - if (projectable.ConstraintClauses is not null) + var compilationUnit = CompilationUnit() + .AddMembers( + NamespaceDeclaration( + ParseName("EntityFrameworkCore.Projectables.Generated") + ).AddMembers(classSyntax) + ) + .WithLeadingTrivia( + TriviaList( + Comment("// "), + Trivia(NullableDirectiveTrivia(Token(SyntaxKind.DisableKeyword), true)) + ) + ); + + + context.AddSource(generatedFileName, SourceText.From(compilationUnit.NormalizeWhitespace().ToFullString(), Encoding.UTF8)); + + + static TypeArgumentListSyntax GetLambdaTypeArgumentListSyntax(ProjectableDescriptor projectable) { - foreach (var constraintClause in projectable.ConstraintClauses) + var lambdaTypeArguments = TypeArgumentList( + SeparatedList( + // TODO: Document where clause + projectable.ParametersList?.Parameters.Where(p => p.Type is not null).Select(p => p.Type!) + ) + ); + + if (projectable.ReturnTypeName is not null) { - resultBuilder.Append($@" - {constraintClause}"); + lambdaTypeArguments = lambdaTypeArguments.AddArguments(ParseTypeName(projectable.ReturnTypeName)); } + + return lambdaTypeArguments; } - - resultBuilder.Append($@" - {{ - return {projectable.ParametersList} => - {projectable.Body}; - }} - }} -}}"); - - - context.AddSource($"{generatedClassName}.g.cs", SourceText.From(resultBuilder.ToString(), Encoding.UTF8)); } } - } } diff --git a/src/EntityFrameworkCore.Projectables/EntityFrameworkCore.Projectables.csproj b/src/EntityFrameworkCore.Projectables/EntityFrameworkCore.Projectables.csproj index 8eb9dfb..079b595 100644 --- a/src/EntityFrameworkCore.Projectables/EntityFrameworkCore.Projectables.csproj +++ b/src/EntityFrameworkCore.Projectables/EntityFrameworkCore.Projectables.csproj @@ -1,7 +1,7 @@  - $(TargetFrameworkVersion) + net6.0 README.md diff --git a/src/EntityFrameworkCore.Projectables/Extensions/TypeExtensions.cs b/src/EntityFrameworkCore.Projectables/Extensions/TypeExtensions.cs index c9e1bef..dd4c6ba 100644 --- a/src/EntityFrameworkCore.Projectables/Extensions/TypeExtensions.cs +++ b/src/EntityFrameworkCore.Projectables/Extensions/TypeExtensions.cs @@ -12,6 +12,19 @@ namespace EntityFrameworkCore.Projectables.Extensions { public static class TypeExtensions { + public static string GetSimplifiedTypeName(this Type type) + { + var name = type.Name; + + var backtickIndex = name.IndexOf("`"); + if (backtickIndex != -1) + { + name = name.Substring(0, backtickIndex); + } + + return name; + } + public static IEnumerable GetNestedTypePath(this Type type) { if (type.IsNested && type.DeclaringType is not null) diff --git a/src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionClassNameGenerator.cs b/src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionClassNameGenerator.cs index b09d091..1c63e77 100644 --- a/src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionClassNameGenerator.cs +++ b/src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionClassNameGenerator.cs @@ -29,16 +29,40 @@ namespace EntityFrameworkCore.Projectables.Services { stringBuilder.Append(namespaceName?.Replace('.', '_')); stringBuilder.Append('_'); + var arity = 0; + if (nestedInClassNames is not null) { + foreach (var className in nestedInClassNames) { - stringBuilder.Append(className); + var arityCharacterIndex = className.IndexOf('`'); + if (arityCharacterIndex is -1) + { + stringBuilder.Append(className); + } + else + { +#if NETSTANDARD2_0 + arity += int.Parse(className.Substring(arityCharacterIndex + 1)); +#else + arity += int.Parse(className.AsSpan().Slice(arityCharacterIndex + 1)); +#endif + stringBuilder.Append(className, 0, arityCharacterIndex); + } + stringBuilder.Append('_'); } + } stringBuilder.Append(memberName); + if (arity > 0) + { + stringBuilder.Append('`'); + stringBuilder.Append(arity); + } + return stringBuilder.ToString(); } } diff --git a/src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionResolver.cs b/src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionResolver.cs index 7cd974f..f913049 100644 --- a/src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionResolver.cs +++ b/src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionResolver.cs @@ -7,6 +7,7 @@ using System.Reflection; using System.Text; using System.Threading.Tasks; using EntityFrameworkCore.Projectables.Extensions; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal; namespace EntityFrameworkCore.Projectables.Services { @@ -14,39 +15,39 @@ namespace EntityFrameworkCore.Projectables.Services { public LambdaExpression FindGeneratedExpression(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); + var projectableAttribute = projectableMemberInfo.GetCustomAttribute() + ?? throw new InvalidOperationException("Expected member to have a Projectable attribute. None found"); - var genericArguments = projectableMemberInfo switch { - MethodInfo methodInfo => methodInfo.GetGenericArguments(), - _ => null - }; + var expression = GetExpressionFromGeneratedType(projectableMemberInfo); - var expressionFactoryMethod = declaringType.Assembly.GetType(generatedContainingTypeName) - ?.GetMethods() - ?.FirstOrDefault(); - - if (expressionFactoryMethod is not null) + if (expression is null && projectableAttribute.UseMemberBody is not null) { - if (genericArguments is { Length: > 0 }) - { - expressionFactoryMethod = expressionFactoryMethod.MakeGenericMethod(genericArguments); - } - - return expressionFactoryMethod.Invoke(null, null) as LambdaExpression ?? throw new InvalidOperationException("Expected lambda"); + expression = GetExpressionFromMemberBody(projectableMemberInfo, projectableAttribute.UseMemberBody); } - var useMemberBody = projectableMemberInfo.GetCustomAttribute()?.UseMemberBody; - - if (useMemberBody is not null) + if (expression is null) { - var exprProperty = declaringType.GetProperty(useMemberBody, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); + var declaringType = projectableMemberInfo.DeclaringType ?? throw new InvalidOperationException("Expected a valid type here"); + var fullName = string.Join(".", Enumerable.Empty() + .Concat(new[] { declaringType.Namespace }) + .Concat(declaringType.GetNestedTypePath().Select(x => x.Name)) + .Concat(new[] { projectableMemberInfo.Name })); + + throw new InvalidOperationException($"Unable to resolve generated expression for {fullName}."); + } + + return expression; + + static LambdaExpression? GetExpressionFromMemberBody(MemberInfo projectableMemberInfo, string memberName) + { + var declaringType = projectableMemberInfo.DeclaringType ?? throw new InvalidOperationException("Expected a valid type here"); + var exprProperty = declaringType.GetProperty(memberName, BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); var lambda = exprProperty?.GetValue(null) as LambdaExpression; if (lambda is not null) { if (projectableMemberInfo is PropertyInfo property && - lambda.Parameters.Count == 1 && + lambda.Parameters.Count == 1 && lambda.Parameters[0].Type == declaringType && lambda.ReturnType == property.PropertyType) { return lambda; @@ -59,18 +60,44 @@ namespace EntityFrameworkCore.Projectables.Services return lambda; } } + + return null; } - var fullName = string.Join(".", Enumerable.Empty() - .Concat(new[] { declaringType.Namespace }) - .Concat(declaringType.GetNestedTypePath().Select(x => x.Name)) - .Concat(new[] { projectableMemberInfo.Name })); + 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); - throw new InvalidOperationException($"Unable to resolve generated expression for {fullName}.") { - Data = { - ["GeneratedContainingTypeName"] = generatedContainingTypeName + var expressionFactoryType = declaringType.Assembly.GetType(generatedContainingTypeName); + + if (expressionFactoryType is not null) + { + if (expressionFactoryType.IsGenericTypeDefinition) + { + expressionFactoryType = expressionFactoryType.MakeGenericType(declaringType.GenericTypeArguments); + } + + var expressionFactoryMethod = expressionFactoryType.GetMethod("Expression", BindingFlags.Static | BindingFlags.NonPublic); + + var methodGenericArguments = projectableMemberInfo switch { + MethodInfo methodInfo => methodInfo.GetGenericArguments(), + _ => null + }; + + if (expressionFactoryMethod is not null) + { + if (methodGenericArguments is { Length: > 0 }) + { + expressionFactoryMethod = expressionFactoryMethod.MakeGenericMethod(methodGenericArguments); + } + + return expressionFactoryMethod.Invoke(null, null) as LambdaExpression ?? throw new InvalidOperationException("Expected lambda"); + } } - }; + + return null; + } } } } diff --git a/tests/EntityFrameworkCore.Projectables.FunctionalTests/Generics/GenericEntityTests.HasMatchingStringKeyConversion_GetsTranslated.verified.txt b/tests/EntityFrameworkCore.Projectables.FunctionalTests/Generics/GenericEntityTests.HasMatchingStringKeyConversion_GetsTranslated.verified.txt new file mode 100644 index 0000000..74f5b05 --- /dev/null +++ b/tests/EntityFrameworkCore.Projectables.FunctionalTests/Generics/GenericEntityTests.HasMatchingStringKeyConversion_GetsTranslated.verified.txt @@ -0,0 +1,5 @@ +DECLARE @__key_0 nvarchar(4000) = N'x'; + +SELECT [c].[Id] +FROM [ConcreteEntity] AS [c] +WHERE CONVERT(varchar(11), [c].[Id]) = @__key_0 \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.FunctionalTests/Generics/GenericEntityTests.cs b/tests/EntityFrameworkCore.Projectables.FunctionalTests/Generics/GenericEntityTests.cs new file mode 100644 index 0000000..4bb7d54 --- /dev/null +++ b/tests/EntityFrameworkCore.Projectables.FunctionalTests/Generics/GenericEntityTests.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using EntityFrameworkCore.Projectables.FunctionalTests.Helpers; +using Microsoft.EntityFrameworkCore; +using VerifyXunit; +using Xunit; + +namespace EntityFrameworkCore.Projectables.FunctionalTests.Generics +{ + [UsesVerify] + public class GenericEntityTests + { + public abstract class BaseEntity + where TSelf : BaseEntity + { + public TKey Id { get; set; } = default!; + + [Projectable(NullConditionalRewriteSupport = NullConditionalRewriteSupport.Ignore)] + public bool HasMatchingStringKeyConversion(string key) + => Id?.ToString() == key; + } + + public class ConcreteEntity : BaseEntity + { + + } + + [Fact] + public Task HasMatchingStringKeyConversion_GetsTranslated() + { + using var context = new SampleDbContext(); + var key = "x"; + var query = context.Set() + .Where(x => x.HasMatchingStringKeyConversion(key)) + .Select(x => x.Id); + + return Verifier.Verify(query.ToQueryString()); + } + } +} diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ArgumentlessProjectableComputedMethod.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ArgumentlessProjectableComputedMethod.verified.txt index d4796e8..2c506a5 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ArgumentlessProjectableComputedMethod.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ArgumentlessProjectableComputedMethod.verified.txt @@ -1,18 +1,13 @@ // -using System; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_Foo + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_Foo { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.C @this) => - 0; + return (global::Foo.C @this) => 0; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMemberExplicitReference.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMemberExplicitReference.verified.txt index 9d9d92e..3a11839 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMemberExplicitReference.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMemberExplicitReference.verified.txt @@ -1,17 +1,13 @@ // -using EntityFrameworkCore.Projectables; -using Projectables.Repro; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Projectables_Repro_Derived_Bar + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Projectables_Repro_Derived_Bar { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Projectables.Repro.Derived @this) => - @this.Foo; + return (global::Projectables.Repro.Derived @this) => @this.Foo; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMemberImplicitReference.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMemberImplicitReference.verified.txt index 9d9d92e..3a11839 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMemberImplicitReference.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMemberImplicitReference.verified.txt @@ -1,17 +1,13 @@ // -using EntityFrameworkCore.Projectables; -using Projectables.Repro; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Projectables_Repro_Derived_Bar + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Projectables_Repro_Derived_Bar { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Projectables.Repro.Derived @this) => - @this.Foo; + return (global::Projectables.Repro.Derived @this) => @this.Foo; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMethodExplicitReference.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMethodExplicitReference.verified.txt index 319279a..529232e 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMethodExplicitReference.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMethodExplicitReference.verified.txt @@ -1,17 +1,13 @@ // -using EntityFrameworkCore.Projectables; -using Projectables.Repro; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Projectables_Repro_Derived_Bar + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Projectables_Repro_Derived_Bar { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Projectables.Repro.Derived @this) => - @this.Foo(); + return (global::Projectables.Repro.Derived @this) => @this.Foo(); } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMethorImplicitReference.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMethorImplicitReference.verified.txt index 319279a..529232e 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMethorImplicitReference.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMethorImplicitReference.verified.txt @@ -1,17 +1,13 @@ // -using EntityFrameworkCore.Projectables; -using Projectables.Repro; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Projectables_Repro_Derived_Bar + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Projectables_Repro_Derived_Bar { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Projectables.Repro.Derived @this) => - @this.Foo(); + return (global::Projectables.Repro.Derived @this) => @this.Foo(); } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Cast.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Cast.verified.txt index d4a4cda..9987c22 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Cast.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Cast.verified.txt @@ -1,17 +1,13 @@ // -using EntityFrameworkCore.Projectables; -using Projectables.Repro; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Projectables_Repro_SomeExtensions_AsSomeResult + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Projectables_Repro_SomeExtensions_AsSomeResult { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Projectables.Repro.SomeEntity e) => - ((global::Projectables.Repro.SuperEntity)e).Superpower; + return (global::Projectables.Repro.SomeEntity e) => ((global::Projectables.Repro.SuperEntity)e).Superpower; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember.verified.txt index dbe54e2..643183d 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember.verified.txt @@ -1,20 +1,13 @@ // -using System; -using System.Linq; -using System.Collections.Generic; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_Foo_IdWithBar + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_Foo_IdWithBar { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.Foo @this) => - @this.Id + global::Foo.Foo.Bar; + return (global::Foo.Foo @this) => @this.Id + global::Foo.Foo.Bar; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember2.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember2.verified.txt index a482d95..abe057b 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember2.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember2.verified.txt @@ -1,20 +1,13 @@ // -using System; -using System.Linq; -using System.Collections.Generic; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_Foo_IdWithBar + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_Foo_IdWithBar { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.Foo @this) => - @this.Id + global::Foo.Constants.Bar; + return (global::Foo.Foo @this) => @this.Id + global::Foo.Constants.Bar; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember3.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember3.verified.txt index dbe54e2..643183d 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember3.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember3.verified.txt @@ -1,20 +1,13 @@ // -using System; -using System.Linq; -using System.Collections.Generic; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_Foo_IdWithBar + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_Foo_IdWithBar { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.Foo @this) => - @this.Id + global::Foo.Foo.Bar; + return (global::Foo.Foo @this) => @this.Id + global::Foo.Foo.Bar; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DeclarationTypeNamesAreGettingFullyQualified.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DeclarationTypeNamesAreGettingFullyQualified.verified.txt index 5152f37..103c17e 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DeclarationTypeNamesAreGettingFullyQualified.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DeclarationTypeNamesAreGettingFullyQualified.verified.txt @@ -1,20 +1,13 @@ // -using System; -using System.Linq; -using System.Collections.Generic; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_EntityExtensions_Entity_Something + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_EntityExtensions_Entity_Something { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.EntityExtensions.Entity entity) => - entity; + return (global::Foo.EntityExtensions.Entity entity) => entity; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DefaultValuesGetRemoved.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DefaultValuesGetRemoved.verified.txt index fa976cd..c2eb349 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DefaultValuesGetRemoved.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DefaultValuesGetRemoved.verified.txt @@ -1,16 +1,13 @@ // -using EntityFrameworkCore.Projectables; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class _Foo_Calculate + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class _Foo_Calculate { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo @this,int i ) => - i; + return (global::Foo @this, int i) => i; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.EnumAccessor.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.EnumAccessor.verified.txt index b9bbd40..0fe19c3 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.EnumAccessor.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.EnumAccessor.verified.txt @@ -1,16 +1,13 @@ // -using EntityFrameworkCore.Projectables; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class _SomeExtensions_Test + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class _SomeExtensions_Test { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::SomeFlag f) => - f == global::SomeFlag.Foo; + return (global::SomeFlag f) => f == global::SomeFlag.Foo; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.FooOrBar.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.FooOrBar.verified.txt index ff52360..1109474 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.FooOrBar.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.FooOrBar.verified.txt @@ -1,18 +1,13 @@ // -using EntityFrameworkCore.Projectables; -using System.Collections.Generic; -using Projectables.Repro; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Projectables_Repro_SomeEntity_FooOrBar + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Projectables_Repro_SomeEntity_FooOrBar { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Projectables.Repro.SomeEntity @this) => - @this.Foo != null ? @this.Foo : @this.Bar; + return (global::Projectables.Repro.SomeEntity @this) => @this.Foo != null ? @this.Foo : @this.Bar; } } } \ No newline at end of file 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 381f780..368090c 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericMethods_AreRewritten.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericMethods_AreRewritten.verified.txt @@ -1,21 +1,14 @@ // -using System; -using System.Linq; -using System.Collections.Generic; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_EntityExtensions_EnforceString + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_EntityExtensions_EnforceString { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() where T : unmanaged { - return (T value) => - value.ToString(); + return (T value) => value.ToString(); } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericNullableReferenceTypesAreBeingEliminated.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericNullableReferenceTypesAreBeingEliminated.verified.txt index fe2999c..a0062d8 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericNullableReferenceTypesAreBeingEliminated.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericNullableReferenceTypesAreBeingEliminated.verified.txt @@ -1,20 +1,13 @@ // -using System; -using System.Collections.Generic; -using System.Linq; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_NextFoo + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_NextFoo { - public static System.Linq.Expressions.Expression ,List, List>> Expression() + static global::System.Linq.Expressions.Expression, global::System.Collections.Generic.List, global::System.Collections.Generic.List>> Expression() { - return (List input,List nullablePrimitiveArgument) => - input; + return (global::System.Collections.Generic.List input, global::System.Collections.Generic.List nullablePrimitiveArgument) => input; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericTypes.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericTypes.verified.txt new file mode 100644 index 0000000..ed731e3 --- /dev/null +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericTypes.verified.txt @@ -0,0 +1,13 @@ +// +#nullable disable +namespace EntityFrameworkCore.Projectables.Generated +{ + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class _EntiyBase_GetId + { + static global::System.Linq.Expressions.Expression> Expression() + { + return () => default; + } + } +} \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericTypesWithConstraints.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericTypesWithConstraints.verified.txt new file mode 100644 index 0000000..801601b --- /dev/null +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericTypesWithConstraints.verified.txt @@ -0,0 +1,14 @@ +// +#nullable disable +namespace EntityFrameworkCore.Projectables.Generated +{ + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class _EntityBase_GetId + where TId : global::System.ICloneable + { + static global::System.Linq.Expressions.Expression> Expression() + { + return () => default; + } + } +} \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.InheritedMembers.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.InheritedMembers.verified.txt index c0b8f6c..1da8b27 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.InheritedMembers.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.InheritedMembers.verified.txt @@ -1,20 +1,13 @@ // -using System; -using System.Linq; -using System.Collections.Generic; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_Bar_ProjectedId + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_Bar_ProjectedId { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.Bar @this) => - @this.Id; + return (global::Foo.Bar @this) => @this.Id; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.IsOperator.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.IsOperator.verified.txt index f14433e..e4cd0d0 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.IsOperator.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.IsOperator.verified.txt @@ -1,19 +1,13 @@ // -using System; -using System.Linq; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_A_IsB + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_A_IsB { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.A @this) => - @this is global::Foo.B; + return (global::Foo.A @this) => @this is global::Foo.B; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MinimalProjectableComputedProperty.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MinimalProjectableComputedProperty.verified.txt index 2e3d5b1..456dab8 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MinimalProjectableComputedProperty.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MinimalProjectableComputedProperty.verified.txt @@ -1,18 +1,13 @@ // -using System; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_Foo + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_Foo { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.C @this) => - @this.Bar; + return (global::Foo.C @this) => @this.Bar; } } } \ 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 d3a55ca..170f712 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MixPrimaryConstructorAndProperties.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MixPrimaryConstructorAndProperties.verified.txt @@ -1,22 +1,14 @@ // -using System; -using System.Linq; -using System.Collections.Generic; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_EntityExtensions_Entity_Something + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_EntityExtensions_Entity_Something { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.EntityExtensions.Entity entity) => - new Entity(entity.Id) { - FullName = entity.FullName - }; + return (global::Foo.EntityExtensions.Entity entity) => new Entity(entity.Id) + {FullName = entity.FullName}; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MoreComplexProjectableComputedProperty.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MoreComplexProjectableComputedProperty.verified.txt index 999b6f2..21b55fa 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MoreComplexProjectableComputedProperty.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MoreComplexProjectableComputedProperty.verified.txt @@ -1,18 +1,13 @@ // -using System; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_Foo + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_Foo { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.C @this) => - @this.Bar + @this.Bar + @this.Bar; + return (global::Foo.C @this) => @this.Bar + @this.Bar + @this.Bar; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NavigationProperties.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NavigationProperties.verified.txt index ecd4e51..ea9bbab 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NavigationProperties.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NavigationProperties.verified.txt @@ -1,18 +1,13 @@ // -using EntityFrameworkCore.Projectables; -using System.Collections.Generic; -using Projectables.Repro; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Projectables_Repro_SomeEntity_RootChildren + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Projectables_Repro_SomeEntity_RootChildren { - public static System.Linq.Expressions.Expression>> Expression() + static global::System.Linq.Expressions.Expression>> Expression() { - return (global::Projectables.Repro.SomeEntity @this) => - @this.Parent != null ? @this.Parent.RootChildren : @this.Children; + return (global::Projectables.Repro.SomeEntity @this) => @this.Parent != null ? @this.Parent.RootChildren : @this.Children; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullConditionalNullCoalesceTypeConversion.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullConditionalNullCoalesceTypeConversion.verified.txt index f4b5dcf..d719a34 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullConditionalNullCoalesceTypeConversion.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullConditionalNullCoalesceTypeConversion.verified.txt @@ -1,16 +1,13 @@ // -using EntityFrameworkCore.Projectables; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class _Foo_SomeNumber + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class _Foo_SomeNumber { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo fancyClass) => - fancyClass != null ? (fancyClass.FancyNumber ) : (int?)null ?? 3; + return (global::Foo fancyClass) => fancyClass != null ? (fancyClass.FancyNumber) : ( int ? )null ?? 3; } } } \ No newline at end of file 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 4cb386e..245fda4 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 @@ -1,20 +1,13 @@ // -using System; -using System.Linq; -using System.Collections.Generic; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_EntityExtensions_GetFirstRelatedIgnoreNulls + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_EntityExtensions_GetFirstRelatedIgnoreNulls { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.EntityExtensions.Entity entity) => - entity.RelatedEntities[0]; + return (global::Foo.EntityExtensions.Entity entity) => entity.RelatedEntities[0]; } } } \ No newline at end of file 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 4535132..a1079fc 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 @@ -1,20 +1,13 @@ // -using System; -using System.Linq; -using System.Collections.Generic; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_EntityExtensions_GetFirstRelatedIgnoreNulls + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_EntityExtensions_GetFirstRelatedIgnoreNulls { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.EntityExtensions.Entity entity) => - entity != null ? (entity.RelatedEntities != null ? (entity.RelatedEntities[0]) : (global::Foo.EntityExtensions.Entity)null) : (global::Foo.EntityExtensions.Entity)null; + return (global::Foo.EntityExtensions.Entity entity) => entity != null ? (entity.RelatedEntities != null ? (entity.RelatedEntities[0]) : (global::Foo.EntityExtensions.Entity)null) : (global::Foo.EntityExtensions.Entity)null; } } } \ No newline at end of file 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 8bc473d..6d638b9 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 @@ -1,19 +1,13 @@ // -using System; -using System.Linq; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_GetFirst + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_GetFirst { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (string input) => - input[0].ToString(); + return (string input) => input[0].ToString(); } } } \ No newline at end of file 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 a661dac..e144480 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 @@ -1,19 +1,13 @@ // -using System; -using System.Linq; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_GetFirst + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_GetFirst { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (string input) => - input != null ? (input[0].ToString()) : (string)null; + return (string input) => input != null ? (input[0].ToString()) : ( string )null; } } } \ No newline at end of file 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 130a6a5..bf36da3 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 @@ -1,19 +1,13 @@ // -using System; -using System.Linq; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_GetLength + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_GetLength { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (string input) => - input.Length; + return (string input) => input.Length; } } } \ No newline at end of file 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 e3d5466..56d0a78 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 @@ -1,19 +1,13 @@ // -using System; -using System.Linq; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_GetLength + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_GetLength { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (string input) => - input != null ? (input.Length) : (int?)null; + return (string input) => input != null ? (input.Length) : ( int ? )null; } } } \ No newline at end of file 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 40a4027..009576e 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 @@ -1,20 +1,13 @@ // -using System; -using System.Linq; -using System.Collections.Generic; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_EntityExtensions_GetFirstName + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_EntityExtensions_GetFirstName { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.EntityExtensions.Entity entity) => - entity.FullName != null ? (entity.FullName.Substring(entity.FullName != null ? (entity.FullName.IndexOf(' ') ) : (int?)null ?? 0)) : (string)null; + return (global::Foo.EntityExtensions.Entity entity) => entity.FullName != null ? (entity.FullName.Substring(entity.FullName != null ? (entity.FullName.IndexOf(' ')) : ( int ? )null ?? 0)) : ( string )null; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypeCastOperatorGetsEliminated.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypeCastOperatorGetsEliminated.verified.txt index 5a288c8..223a00d 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypeCastOperatorGetsEliminated.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypeCastOperatorGetsEliminated.verified.txt @@ -1,20 +1,13 @@ // -using System; -using System.Collections.Generic; -using System.Linq; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_NullableReferenceType + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_NullableReferenceType { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (object input) => - (string)input; + return (object input) => (string)input; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypesAreBeingEliminated.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypesAreBeingEliminated.verified.txt index ee85c4f..aca6e43 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypesAreBeingEliminated.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypesAreBeingEliminated.verified.txt @@ -1,19 +1,13 @@ // -using System; -using System.Linq; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_NextFoo + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_NextFoo { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (object unusedArgument,int? nullablePrimitiveArgument) => - null; + return (object unusedArgument, int? nullablePrimitiveArgument) => null; } } } \ No newline at end of file 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 f23d6dd..fbf5589 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 @@ -1,19 +1,13 @@ // -using System; -using System.Linq; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_GetFirst + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_GetFirst { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (string input) => - input[0]; + return (string input) => input[0]; } } } \ No newline at end of file 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 5a3c009..8e1b353 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 @@ -1,19 +1,13 @@ // -using System; -using System.Linq; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_GetFirst + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_GetFirst { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (string input) => - input != null ? (input[0]) : (char?)null; + return (string input) => input != null ? (input[0]) : ( char ? )null; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableValueCastOperatorsPersist.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableValueCastOperatorsPersist.verified.txt index 4ec93ed..1ecf514 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableValueCastOperatorsPersist.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableValueCastOperatorsPersist.verified.txt @@ -1,20 +1,13 @@ // -using System; -using System.Collections.Generic; -using System.Linq; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_NullableValueType + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_NullableValueType { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (object input) => - (int?)input; + return (object input) => (int? )input; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ParamsArray.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ParamsArray.verified.txt deleted file mode 100644 index ab0e7f6..0000000 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ParamsArray.verified.txt +++ /dev/null @@ -1,16 +0,0 @@ -// -using EntityFrameworkCore.Projectables; - -namespace EntityFrameworkCore.Projectables.Generated -#nullable disable -{ - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class _Foo_First - { - public static System.Linq.Expressions.Expression> Expression() - { - return (global::Foo @this, int[] numbers) => - numbers[0]; - } - } -} \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ParamsModifiedGetsRemoved.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ParamsModifiedGetsRemoved.verified.txt index 9fdc1e3..7efd579 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ParamsModifiedGetsRemoved.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ParamsModifiedGetsRemoved.verified.txt @@ -1,16 +1,13 @@ // -using EntityFrameworkCore.Projectables; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class _Foo_First + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class _Foo_First { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo @this,int[] all) => - all[0]; + return (global::Foo @this, int[] all) => all[0]; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithMultipleArguments.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithMultipleArguments.verified.txt index bf2802e..17a7c5b 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithMultipleArguments.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithMultipleArguments.verified.txt @@ -1,18 +1,13 @@ // -using System; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_Foo + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_Foo { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.C @this,int a,string b,object d) => - a; + return (global::Foo.C @this, int a, string b, object d) => a; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithSingleArgument.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithSingleArgument.verified.txt index 5e3cdcf..3ab4443 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithSingleArgument.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithSingleArgument.verified.txt @@ -1,18 +1,13 @@ // -using System; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_Foo + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_Foo { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.C @this,int i) => - i; + return (global::Foo.C @this, int i) => i; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedPropertyMethod.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedPropertyMethod.verified.txt index 7d5afbe..de9db08 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedPropertyMethod.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedPropertyMethod.verified.txt @@ -1,18 +1,13 @@ // -using System; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_Foo + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_Foo { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.C @this) => - @this.Bar(); + return (global::Foo.C @this) => @this.Bar(); } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedPropertyUsingThis.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedPropertyUsingThis.verified.txt index 2e3d5b1..456dab8 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedPropertyUsingThis.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedPropertyUsingThis.verified.txt @@ -1,18 +1,13 @@ // -using System; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_Foo + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_Foo { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.C @this) => - @this.Bar; + return (global::Foo.C @this) => @this.Bar; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod.verified.txt index 0d3df46..96cf34b 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod.verified.txt @@ -1,19 +1,13 @@ // -using System; -using System.Linq; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_Foo + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_Foo { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.D d) => - 1; + return (global::Foo.D d) => 1; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod2.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod2.verified.txt index 3804b1c..20e79e4 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod2.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod2.verified.txt @@ -1,19 +1,13 @@ // -using System; -using System.Linq; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_Foo + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_Foo { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (int i) => - i; + return (int i) => i; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod3.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod3.verified.txt index 99b9d81..8247b1c 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod3.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod3.verified.txt @@ -1,19 +1,13 @@ // -using System; -using System.Linq; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_Foo1 + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_Foo1 { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (int i) => - i; + return (int i) => i; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod4.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod4.verified.txt index d35810e..924c9ce 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod4.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod4.verified.txt @@ -1,19 +1,13 @@ // -using System; -using System.Linq; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_Foo1 + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_Foo1 { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (object i) => - global::Foo.C.Foo1(i); + return (object i) => global::Foo.C.Foo1(i); } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectablePropertyToNavigationalProperty.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectablePropertyToNavigationalProperty.verified.txt index 38cc092..2ff648b 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectablePropertyToNavigationalProperty.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectablePropertyToNavigationalProperty.verified.txt @@ -1,19 +1,13 @@ // -using System; -using System.Linq; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_Foo + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_Foo { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.C @this) => - global::System.Linq.Enumerable.First(@this.Dees); + return (global::Foo.C @this) => global::System.Linq.Enumerable.First(@this.Dees); } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.RelationalProperty.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.RelationalProperty.verified.txt index bf74582..d387ce7 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.RelationalProperty.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.RelationalProperty.verified.txt @@ -1,20 +1,13 @@ // -using System; -using System.Linq; -using System.Collections.Generic; -using EntityFrameworkCore.Projectables; -using Foos; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foos_Bar_FooId + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foos_Bar_FooId { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foos.Bar @this) => - @this.Foo.Id; + return (global::Foos.Bar @this) => @this.Foo.Id; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.RequiredNamespace.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.RequiredNamespace.verified.txt index 7dcf9de..9f69ddf 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.RequiredNamespace.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.RequiredNamespace.verified.txt @@ -1,17 +1,13 @@ // -using EntityFrameworkCore.Projectables; -using One.Two; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class One_Two_Bar_Method + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class One_Two_Bar_Method { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::One.Two.Bar @this) => - global::One.IntExtensions.AddOne(1); + return (global::One.Two.Bar @this) => global::One.IntExtensions.AddOne(1); } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableComputedInNestedClassProperty.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableComputedInNestedClassProperty.verified.txt index 940c262..e524a2b 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableComputedInNestedClassProperty.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableComputedInNestedClassProperty.verified.txt @@ -1,18 +1,13 @@ // -using System; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_D_Foo + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_D_Foo { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.C.D @this) => - @this.Bar + 1; + return (global::Foo.C.D @this) => @this.Bar + 1; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableComputedProperty.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableComputedProperty.verified.txt index f950755..f2bcdcc 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableComputedProperty.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableComputedProperty.verified.txt @@ -1,18 +1,13 @@ // -using System; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_Foo + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_Foo { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.C @this) => - @this.Bar + 1; + return (global::Foo.C @this) => @this.Bar + 1; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableMethod.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableMethod.verified.txt index 6509e94..a87a611 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableMethod.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableMethod.verified.txt @@ -1,18 +1,13 @@ // -using System; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_Foo + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_Foo { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.C @this) => - 1; + return (global::Foo.C @this) => 1; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableProperty.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableProperty.verified.txt index 6509e94..a87a611 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableProperty.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableProperty.verified.txt @@ -1,18 +1,13 @@ // -using System; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_Foo + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_Foo { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.C @this) => - 1; + return (global::Foo.C @this) => 1; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMembers.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMembers.verified.txt index dbe54e2..643183d 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMembers.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMembers.verified.txt @@ -1,20 +1,13 @@ // -using System; -using System.Linq; -using System.Collections.Generic; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_Foo_IdWithBar + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_Foo_IdWithBar { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.Foo @this) => - @this.Id + global::Foo.Foo.Bar; + return (global::Foo.Foo @this) => @this.Id + global::Foo.Foo.Bar; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMembers2.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMembers2.verified.txt index a482d95..abe057b 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMembers2.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMembers2.verified.txt @@ -1,20 +1,13 @@ // -using System; -using System.Linq; -using System.Collections.Generic; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_Foo_IdWithBar + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_Foo_IdWithBar { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.Foo @this) => - @this.Id + global::Foo.Constants.Bar; + return (global::Foo.Foo @this) => @this.Id + global::Foo.Constants.Bar; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMethodWithNoParameters.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMethodWithNoParameters.verified.txt index 39397f7..a57960f 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMethodWithNoParameters.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMethodWithNoParameters.verified.txt @@ -1,19 +1,13 @@ // -using System; -using System.Linq; -using System.Collections.Generic; -using EntityFrameworkCore.Projectables; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class _Foo_Zero + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class _Foo_Zero { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return () => - 0; + return () => 0; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMethodWithParameters.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMethodWithParameters.verified.txt index 31a8bed..ba05aef 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMethodWithParameters.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMethodWithParameters.verified.txt @@ -1,19 +1,13 @@ // -using System; -using System.Linq; -using System.Collections.Generic; -using EntityFrameworkCore.Projectables; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class _Foo_Zero + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class _Foo_Zero { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (int x) => - 0; + return (int x) => 0; } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.TypesInBodyGetsFullyQualified.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.TypesInBodyGetsFullyQualified.verified.txt index 4f96732..7e0e17a 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.TypesInBodyGetsFullyQualified.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.TypesInBodyGetsFullyQualified.verified.txt @@ -1,19 +1,13 @@ // -using System; -using System.Linq; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated #nullable disable +namespace EntityFrameworkCore.Projectables.Generated { - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] - public static class Foo_C_Foo + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_C_Foo { - public static System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.C @this) => - global::System.Linq.Enumerable.Count(global::System.Linq.Enumerable.OfType(@this.Dees)); + return (global::Foo.C @this) => global::System.Linq.Enumerable.Count(global::System.Linq.Enumerable.OfType(@this.Dees)); } } } \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.cs b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.cs index e75ec62..ea06a89 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.cs +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.cs @@ -1,5 +1,8 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using System; +using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; @@ -537,6 +540,7 @@ namespace Foo { return Verifier.Verify(result.GeneratedTrees[0].ToString()); } + [Fact] public Task GenericNullableReferenceTypesAreBeingEliminated() { @@ -1566,6 +1570,52 @@ class Foo { return Verifier.Verify(result.GeneratedTrees[0].ToString()); } + [Fact] + public Task GenericTypes() + { + // issue: https://github.com/koenbeuk/EntityFrameworkCore.Projectables/issues/48 + + var compilation = CreateCompilation(@" +using EntityFrameworkCore.Projectables; + +class EntiyBase { + [Projectable] + public static TId GetId() => default; +} +"); + + var result = RunGenerator(compilation); + + Assert.Empty(result.Diagnostics); + Assert.Single(result.GeneratedTrees); + + return Verifier.Verify(result.GeneratedTrees[0].ToString()); + } + + [Fact] + public Task GenericTypesWithConstraints() + { + // issue: https://github.com/koenbeuk/EntityFrameworkCore.Projectables/issues/48 + + var compilation = CreateCompilation(@" +using System; +using EntityFrameworkCore.Projectables; + +class EntityBase where TId : ICloneable, new() { + [Projectable] + public static TId GetId() => default; +} +"); + + var result = RunGenerator(compilation); + + Assert.Empty(result.Diagnostics); + Assert.Single(result.GeneratedTrees); + + return Verifier.Verify(result.GeneratedTrees[0].ToString()); + } + + #region Helpers Compilation CreateCompilation(string source, bool expectedToCompile = true) diff --git a/tests/EntityFrameworkCore.Projectables.Tests/Services/ProjectionExpressionClassNameGeneratorTests.cs b/tests/EntityFrameworkCore.Projectables.Tests/Services/ProjectionExpressionClassNameGeneratorTests.cs index 8501795..5eb59b5 100644 --- a/tests/EntityFrameworkCore.Projectables.Tests/Services/ProjectionExpressionClassNameGeneratorTests.cs +++ b/tests/EntityFrameworkCore.Projectables.Tests/Services/ProjectionExpressionClassNameGeneratorTests.cs @@ -14,6 +14,8 @@ namespace EntityFrameworkCore.Projectables.Tests.Services [InlineData("ns", new string[] { "a" }, "m", "ns_a_m")] [InlineData("ns", new string[] { "a", "b" }, "m", "ns_a_b_m")] [InlineData(null, new string[] { "a" }, "m", "_a_m")] + [InlineData("ns", new string[] { "a`1" }, "m", "ns_a_m`1" )] + [InlineData("ns", new string[] { "a`1", "b`1" }, "m", "ns_a_b_m`2")] public void GenerateName(string? namespaceName, string[] nestedTypeNames, string memberName, string expected) { var result = ProjectionExpressionClassNameGenerator.GenerateName(namespaceName, nestedTypeNames, memberName);