From b4da49fc6ffa1f859531c031a457bfbf9a91f862 Mon Sep 17 00:00:00 2001 From: Koen Date: Wed, 8 Feb 2023 01:58:28 +0000 Subject: [PATCH 1/6] Support for declaring projectables on generic classes --- .../DeclarationSyntaxRewriter.cs | 15 +- ...rameworkCore.Projectables.Generator.csproj | 2 +- .../ProjectableDescriptor.cs | 10 +- .../ProjectableInterpreter.cs | 68 ++++++--- .../ProjectionExpressionGenerator.cs | 144 +++++++++++------- .../EntityFrameworkCore.Projectables.csproj | 2 +- .../Extensions/TypeExtensions.cs | 13 ++ .../ProjectionExpressionClassNameGenerator.cs | 26 +++- .../Services/ProjectionExpressionResolver.cs | 79 ++++++---- ...gKeyConversion_GetsTranslated.verified.txt | 5 + .../Generics/GenericEntityTests.cs | 43 ++++++ ...lessProjectableComputedMethod.verified.txt | 15 +- ...s.BaseMemberExplicitReference.verified.txt | 14 +- ...s.BaseMemberImplicitReference.verified.txt | 14 +- ...s.BaseMethodExplicitReference.verified.txt | 14 +- ...s.BaseMethorImplicitReference.verified.txt | 14 +- ...ExpressionGeneratorTests.Cast.verified.txt | 14 +- ...ionGeneratorTests.ConstMember.verified.txt | 17 +-- ...onGeneratorTests.ConstMember2.verified.txt | 17 +-- ...onGeneratorTests.ConstMember3.verified.txt | 17 +-- ...NamesAreGettingFullyQualified.verified.txt | 17 +-- ...Tests.DefaultValuesGetRemoved.verified.txt | 13 +- ...onGeneratorTests.EnumAccessor.verified.txt | 13 +- ...essionGeneratorTests.FooOrBar.verified.txt | 15 +- ...s.GenericMethods_AreRewritten.verified.txt | 17 +-- ...erenceTypesAreBeingEliminated.verified.txt | 17 +-- ...onGeneratorTests.GenericTypes.verified.txt | 13 ++ ...s.GenericTypesWithConstraints.verified.txt | 14 ++ ...neratorTests.InheritedMembers.verified.txt | 17 +-- ...sionGeneratorTests.IsOperator.verified.txt | 16 +- ...alProjectableComputedProperty.verified.txt | 15 +- ...imaryConstructorAndProperties.verified.txt | 20 +-- ...exProjectableComputedProperty.verified.txt | 15 +- ...torTests.NavigationProperties.verified.txt | 15 +- ...nalNullCoalesceTypeConversion.verified.txt | 13 +- ...gnoreSupport_IsBeingRewritten.verified.txt | 17 +-- ...writeSupport_IsBeingRewritten.verified.txt | 17 +-- ...gnoreSupport_IsBeingRewritten.verified.txt | 16 +- ...writeSupport_IsBeingRewritten.verified.txt | 16 +- ...gnoreSupport_IsBeingRewritten.verified.txt | 16 +- ...writeSupport_IsBeingRewritten.verified.txt | 16 +- ...writeSupport_IsBeingRewritten.verified.txt | 17 +-- ...ypeCastOperatorGetsEliminated.verified.txt | 17 +-- ...erenceTypesAreBeingEliminated.verified.txt | 16 +- ...gnoreSupport_IsBeingRewritten.verified.txt | 16 +- ...writeSupport_IsBeingRewritten.verified.txt | 16 +- ...ableValueCastOperatorsPersist.verified.txt | 17 +-- ...ionGeneratorTests.ParamsArray.verified.txt | 16 -- ...sts.ParamsModifiedGetsRemoved.verified.txt | 13 +- ...edMethodWithMultipleArguments.verified.txt | 15 +- ...putedMethodWithSingleArgument.verified.txt | 15 +- ...ectableComputedPropertyMethod.verified.txt | 15 +- ...ableComputedPropertyUsingThis.verified.txt | 15 +- ...ts.ProjectableExtensionMethod.verified.txt | 16 +- ...s.ProjectableExtensionMethod2.verified.txt | 16 +- ...s.ProjectableExtensionMethod3.verified.txt | 16 +- ...s.ProjectableExtensionMethod4.verified.txt | 16 +- ...ropertyToNavigationalProperty.verified.txt | 16 +- ...ratorTests.RelationalProperty.verified.txt | 17 +-- ...eratorTests.RequiredNamespace.verified.txt | 14 +- ...ComputedInNestedClassProperty.verified.txt | 15 +- ...leProjectableComputedProperty.verified.txt | 15 +- ...Tests.SimpleProjectableMethod.verified.txt | 15 +- ...sts.SimpleProjectableProperty.verified.txt | 15 +- ...nGeneratorTests.StaticMembers.verified.txt | 17 +-- ...GeneratorTests.StaticMembers2.verified.txt | 17 +-- ....StaticMethodWithNoParameters.verified.txt | 16 +- ...ts.StaticMethodWithParameters.verified.txt | 16 +- ...TypesInBodyGetsFullyQualified.verified.txt | 16 +- .../ProjectionExpressionGeneratorTests.cs | 50 ++++++ ...ectionExpressionClassNameGeneratorTests.cs | 2 + 71 files changed, 647 insertions(+), 717 deletions(-) create mode 100644 tests/EntityFrameworkCore.Projectables.FunctionalTests/Generics/GenericEntityTests.HasMatchingStringKeyConversion_GetsTranslated.verified.txt create mode 100644 tests/EntityFrameworkCore.Projectables.FunctionalTests/Generics/GenericEntityTests.cs create mode 100644 tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericTypes.verified.txt create mode 100644 tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericTypesWithConstraints.verified.txt delete mode 100644 tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ParamsArray.verified.txt 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..603e0da 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,37 @@ 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 = projectableAttribute switch { + { UseMemberBody: not null } => GetExpressionFromMemberBody(projectableMemberInfo, projectableAttribute.UseMemberBody), + _ => GetExpressionFromGeneratedType(projectableMemberInfo) }; - var expressionFactoryMethod = declaringType.Assembly.GetType(generatedContainingTypeName) - ?.GetMethods() - ?.FirstOrDefault(); - - if (expressionFactoryMethod is not null) + if (expression is null) { - if (genericArguments is { Length: > 0 }) - { - expressionFactoryMethod = expressionFactoryMethod.MakeGenericMethod(genericArguments); - } + 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 })); - return expressionFactoryMethod.Invoke(null, null) as LambdaExpression ?? throw new InvalidOperationException("Expected lambda"); + throw new InvalidOperationException($"Unable to resolve generated expression for {fullName}."); } - var useMemberBody = projectableMemberInfo.GetCustomAttribute()?.UseMemberBody; + return expression; - if (useMemberBody is not null) + static LambdaExpression? GetExpressionFromMemberBody(MemberInfo projectableMemberInfo, string memberName) { - var exprProperty = declaringType.GetProperty(useMemberBody, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); + 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 +58,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); From 682aa4f30eb3791de02f35ca2017a18971b9b8e5 Mon Sep 17 00:00:00 2001 From: Koen Date: Wed, 8 Feb 2023 02:07:17 +0000 Subject: [PATCH 2/6] Fixed broken tests --- .../Services/ProjectionExpressionResolver.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionResolver.cs b/src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionResolver.cs index 603e0da..f913049 100644 --- a/src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionResolver.cs +++ b/src/EntityFrameworkCore.Projectables/Services/ProjectionExpressionResolver.cs @@ -18,10 +18,12 @@ namespace EntityFrameworkCore.Projectables.Services var projectableAttribute = projectableMemberInfo.GetCustomAttribute() ?? throw new InvalidOperationException("Expected member to have a Projectable attribute. None found"); - var expression = projectableAttribute switch { - { UseMemberBody: not null } => GetExpressionFromMemberBody(projectableMemberInfo, projectableAttribute.UseMemberBody), - _ => GetExpressionFromGeneratedType(projectableMemberInfo) - }; + var expression = GetExpressionFromGeneratedType(projectableMemberInfo); + + if (expression is null && projectableAttribute.UseMemberBody is not null) + { + expression = GetExpressionFromMemberBody(projectableMemberInfo, projectableAttribute.UseMemberBody); + } if (expression is null) { From 220fe4f58bce594c28a3d334c3f969c0a6425739 Mon Sep 17 00:00:00 2001 From: Koen Date: Thu, 9 Mar 2023 19:15:50 +0000 Subject: [PATCH 3/6] Simplified type resolution --- .../ExpressionSyntaxRewriter.cs | 11 +++-------- ...ts.MixPrimaryConstructorAndProperties.verified.txt | 2 +- .../ProjectionExpressionGeneratorTests.cs | 1 - 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/EntityFrameworkCore.Projectables.Generator/ExpressionSyntaxRewriter.cs b/src/EntityFrameworkCore.Projectables.Generator/ExpressionSyntaxRewriter.cs index 0c53cc2..f5215c6 100644 --- a/src/EntityFrameworkCore.Projectables.Generator/ExpressionSyntaxRewriter.cs +++ b/src/EntityFrameworkCore.Projectables.Generator/ExpressionSyntaxRewriter.cs @@ -214,14 +214,9 @@ namespace EntityFrameworkCore.Projectables.Generator // if this node refers to a named type which is not yet fully qualified, we want to fully qualify it if (symbol.Kind is SymbolKind.NamedType && node.Parent?.Kind() is not SyntaxKind.QualifiedName) { - var typeInfo = _semanticModel.GetTypeInfo(node); - - if (typeInfo.Type is not null) - { - return SyntaxFactory.ParseTypeName( - typeInfo.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) - ).WithLeadingTrivia(node.GetLeadingTrivia()); - } + return SyntaxFactory.ParseTypeName( + symbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + ).WithLeadingTrivia(node.GetLeadingTrivia()); } } diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MixPrimaryConstructorAndProperties.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MixPrimaryConstructorAndProperties.verified.txt index 170f712..9c6adb3 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MixPrimaryConstructorAndProperties.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MixPrimaryConstructorAndProperties.verified.txt @@ -7,7 +7,7 @@ namespace EntityFrameworkCore.Projectables.Generated { static global::System.Linq.Expressions.Expression> Expression() { - return (global::Foo.EntityExtensions.Entity entity) => new Entity(entity.Id) + return (global::Foo.EntityExtensions.Entity entity) => new global::Foo.EntityExtensions.Entity(entity.Id) {FullName = entity.FullName}; } } diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.cs b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.cs index ea06a89..36981f2 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.cs +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.cs @@ -1615,7 +1615,6 @@ class EntityBase where TId : ICloneable, new() { return Verifier.Verify(result.GeneratedTrees[0].ToString()); } - #region Helpers Compilation CreateCompilation(string source, bool expectedToCompile = true) From 2295e29125218f36c3975017ef67a48d805295a7 Mon Sep 17 00:00:00 2001 From: Koen Date: Thu, 16 Mar 2023 00:23:06 +0000 Subject: [PATCH 4/6] Don't throw on private and protected properties --- .../Extensions/TypeExtensions.cs | 2 +- ...vateProjectables.Issue63Repro.verified.txt | 2 ++ .../PrivateProjectables.cs | 34 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 tests/EntityFrameworkCore.Projectables.FunctionalTests/PrivateProjectables.Issue63Repro.verified.txt create mode 100644 tests/EntityFrameworkCore.Projectables.FunctionalTests/PrivateProjectables.cs diff --git a/src/EntityFrameworkCore.Projectables/Extensions/TypeExtensions.cs b/src/EntityFrameworkCore.Projectables/Extensions/TypeExtensions.cs index dd4c6ba..266fb03 100644 --- a/src/EntityFrameworkCore.Projectables/Extensions/TypeExtensions.cs +++ b/src/EntityFrameworkCore.Projectables/Extensions/TypeExtensions.cs @@ -89,7 +89,7 @@ namespace EntityFrameworkCore.Projectables.Extensions public static PropertyInfo GetOverridingProperty(this Type derivedType, PropertyInfo propertyInfo) { - var accessor = propertyInfo.GetAccessors()[0]; + var accessor = propertyInfo.GetAccessors(true)[0]; if (!derivedType.CanHaveOverridingMethod(accessor)) { diff --git a/tests/EntityFrameworkCore.Projectables.FunctionalTests/PrivateProjectables.Issue63Repro.verified.txt b/tests/EntityFrameworkCore.Projectables.FunctionalTests/PrivateProjectables.Issue63Repro.verified.txt new file mode 100644 index 0000000..6a9e2b9 --- /dev/null +++ b/tests/EntityFrameworkCore.Projectables.FunctionalTests/PrivateProjectables.Issue63Repro.verified.txt @@ -0,0 +1,2 @@ +SELECT [e].[Id] +FROM [Entity] AS [e] \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.FunctionalTests/PrivateProjectables.cs b/tests/EntityFrameworkCore.Projectables.FunctionalTests/PrivateProjectables.cs new file mode 100644 index 0000000..bd34ed3 --- /dev/null +++ b/tests/EntityFrameworkCore.Projectables.FunctionalTests/PrivateProjectables.cs @@ -0,0 +1,34 @@ +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 +{ + [UsesVerify] + public class PrivateProjectables + { + public record Entity + { + public int Id { get; set; } + } + + bool IsAdmin => true; + + [Fact] + public Task Issue63Repro() + { + using var dbContext = new SampleDbContext(); + + var query = dbContext.Set() + .Where(product => IsAdmin || product.Id == 1); + + return Verifier.Verify(query.ToQueryString()); + } + } +} From 5dcc5a23f72783cab57dfd9a7df04ec9d76773b4 Mon Sep 17 00:00:00 2001 From: Koen Date: Wed, 19 Apr 2023 19:51:09 +0100 Subject: [PATCH 5/6] Import using directives to help resolve extension methods --- .../ProjectableDescriptor.cs | 2 + .../ProjectableInterpreter.cs | 2 + .../ProjectionExpressionGenerator.cs | 18 +++++- ...lessProjectableComputedMethod.verified.txt | 4 ++ ...s.BaseMemberExplicitReference.verified.txt | 3 + ...s.BaseMemberImplicitReference.verified.txt | 3 + ...s.BaseMethodExplicitReference.verified.txt | 3 + ...s.BaseMethorImplicitReference.verified.txt | 3 + ...ExpressionGeneratorTests.Cast.verified.txt | 3 + ...ionGeneratorTests.ConstMember.verified.txt | 6 ++ ...onGeneratorTests.ConstMember2.verified.txt | 6 ++ ...onGeneratorTests.ConstMember3.verified.txt | 6 ++ ...NamesAreGettingFullyQualified.verified.txt | 6 ++ ...Tests.DefaultValuesGetRemoved.verified.txt | 2 + ...onGeneratorTests.EnumAccessor.verified.txt | 2 + ...essionGeneratorTests.FooOrBar.verified.txt | 4 ++ ...s.GenericMethods_AreRewritten.verified.txt | 6 ++ ...erenceTypesAreBeingEliminated.verified.txt | 6 ++ ...onGeneratorTests.GenericTypes.verified.txt | 2 + ...s.GenericTypesWithConstraints.verified.txt | 3 + ...neratorTests.InheritedMembers.verified.txt | 6 ++ ...sionGeneratorTests.IsOperator.verified.txt | 5 ++ ...ressionGeneratorTests.Issue65.verified.txt | 16 ++++++ ...essionGeneratorTests.Issue652.verified.txt | 17 ++++++ ...alProjectableComputedProperty.verified.txt | 4 ++ ...imaryConstructorAndProperties.verified.txt | 6 ++ ...exProjectableComputedProperty.verified.txt | 4 ++ ...torTests.NavigationProperties.verified.txt | 4 ++ ...nalNullCoalesceTypeConversion.verified.txt | 2 + ...gnoreSupport_IsBeingRewritten.verified.txt | 6 ++ ...writeSupport_IsBeingRewritten.verified.txt | 6 ++ ...gnoreSupport_IsBeingRewritten.verified.txt | 5 ++ ...writeSupport_IsBeingRewritten.verified.txt | 5 ++ ...gnoreSupport_IsBeingRewritten.verified.txt | 5 ++ ...writeSupport_IsBeingRewritten.verified.txt | 5 ++ ...writeSupport_IsBeingRewritten.verified.txt | 6 ++ ...ypeCastOperatorGetsEliminated.verified.txt | 6 ++ ...erenceTypesAreBeingEliminated.verified.txt | 5 ++ ...gnoreSupport_IsBeingRewritten.verified.txt | 5 ++ ...writeSupport_IsBeingRewritten.verified.txt | 5 ++ ...ableValueCastOperatorsPersist.verified.txt | 6 ++ ...sts.ParamsModifiedGetsRemoved.verified.txt | 2 + ...edMethodWithMultipleArguments.verified.txt | 4 ++ ...putedMethodWithSingleArgument.verified.txt | 4 ++ ...ectableComputedPropertyMethod.verified.txt | 4 ++ ...ableComputedPropertyUsingThis.verified.txt | 4 ++ ...ts.ProjectableExtensionMethod.verified.txt | 5 ++ ...s.ProjectableExtensionMethod2.verified.txt | 5 ++ ...s.ProjectableExtensionMethod3.verified.txt | 5 ++ ...s.ProjectableExtensionMethod4.verified.txt | 5 ++ ...ropertyToNavigationalProperty.verified.txt | 5 ++ ...ratorTests.RelationalProperty.verified.txt | 6 ++ ...eratorTests.RequiredNamespace.verified.txt | 3 + ...ComputedInNestedClassProperty.verified.txt | 4 ++ ...leProjectableComputedProperty.verified.txt | 4 ++ ...Tests.SimpleProjectableMethod.verified.txt | 4 ++ ...sts.SimpleProjectableProperty.verified.txt | 4 ++ ...nGeneratorTests.StaticMembers.verified.txt | 6 ++ ...GeneratorTests.StaticMembers2.verified.txt | 6 ++ ....StaticMethodWithNoParameters.verified.txt | 5 ++ ...ts.StaticMethodWithParameters.verified.txt | 5 ++ ...TypesInBodyGetsFullyQualified.verified.txt | 5 ++ .../ProjectionExpressionGeneratorTests.cs | 57 +++++++++++++++++++ 63 files changed, 370 insertions(+), 1 deletion(-) create mode 100644 tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Issue65.verified.txt create mode 100644 tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Issue652.verified.txt diff --git a/src/EntityFrameworkCore.Projectables.Generator/ProjectableDescriptor.cs b/src/EntityFrameworkCore.Projectables.Generator/ProjectableDescriptor.cs index b5344f8..f428a76 100644 --- a/src/EntityFrameworkCore.Projectables.Generator/ProjectableDescriptor.cs +++ b/src/EntityFrameworkCore.Projectables.Generator/ProjectableDescriptor.cs @@ -11,6 +11,8 @@ namespace EntityFrameworkCore.Projectables.Generator { public class ProjectableDescriptor { + public IEnumerable? UsingDirectives { get; set; } + public string? ClassNamespace { get; set; } public IEnumerable? NestedInClassNames { get; set; } diff --git a/src/EntityFrameworkCore.Projectables.Generator/ProjectableInterpreter.cs b/src/EntityFrameworkCore.Projectables.Generator/ProjectableInterpreter.cs index bcf315e..216a499 100644 --- a/src/EntityFrameworkCore.Projectables.Generator/ProjectableInterpreter.cs +++ b/src/EntityFrameworkCore.Projectables.Generator/ProjectableInterpreter.cs @@ -119,6 +119,8 @@ namespace EntityFrameworkCore.Projectables.Generator var declarationSyntaxRewriter = new DeclarationSyntaxRewriter(semanticModel); var descriptor = new ProjectableDescriptor { + + UsingDirectives = member.SyntaxTree.GetRoot().DescendantNodes().OfType(), ClassName = memberSymbol.ContainingType.Name, ClassNamespace = memberSymbol.ContainingType.ContainingNamespace.IsGlobalNamespace ? null : memberSymbol.ContainingType.ContainingNamespace.ToDisplayString(), MemberName = memberSymbol.Name, diff --git a/src/EntityFrameworkCore.Projectables.Generator/ProjectionExpressionGenerator.cs b/src/EntityFrameworkCore.Projectables.Generator/ProjectionExpressionGenerator.cs index c965e95..94dcdc1 100644 --- a/src/EntityFrameworkCore.Projectables.Generator/ProjectionExpressionGenerator.cs +++ b/src/EntityFrameworkCore.Projectables.Generator/ProjectionExpressionGenerator.cs @@ -153,7 +153,23 @@ namespace EntityFrameworkCore.Projectables.Generator #nullable disable - var compilationUnit = CompilationUnit() + var compilationUnit = CompilationUnit(); + + foreach (var usingDirective in projectable.UsingDirectives) + { + compilationUnit = compilationUnit.AddUsings(usingDirective); + } + + if (projectable.ClassNamespace is not null) + { + compilationUnit = compilationUnit.AddUsings( + UsingDirective( + ParseName(projectable.ClassNamespace) + ) + ); + } + + compilationUnit = compilationUnit .AddMembers( NamespaceDeclaration( ParseName("EntityFrameworkCore.Projectables.Generated") diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ArgumentlessProjectableComputedMethod.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ArgumentlessProjectableComputedMethod.verified.txt index 2c506a5..fa2d4ec 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ArgumentlessProjectableComputedMethod.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ArgumentlessProjectableComputedMethod.verified.txt @@ -1,5 +1,9 @@ // #nullable disable +using System; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMemberExplicitReference.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMemberExplicitReference.verified.txt index 3a11839..682df68 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMemberExplicitReference.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMemberExplicitReference.verified.txt @@ -1,5 +1,8 @@ // #nullable disable +using EntityFrameworkCore.Projectables; +using Projectables.Repro; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMemberImplicitReference.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMemberImplicitReference.verified.txt index 3a11839..682df68 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMemberImplicitReference.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMemberImplicitReference.verified.txt @@ -1,5 +1,8 @@ // #nullable disable +using EntityFrameworkCore.Projectables; +using Projectables.Repro; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMethodExplicitReference.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMethodExplicitReference.verified.txt index 529232e..fe999c7 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMethodExplicitReference.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMethodExplicitReference.verified.txt @@ -1,5 +1,8 @@ // #nullable disable +using EntityFrameworkCore.Projectables; +using Projectables.Repro; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMethorImplicitReference.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMethorImplicitReference.verified.txt index 529232e..fe999c7 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMethorImplicitReference.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.BaseMethorImplicitReference.verified.txt @@ -1,5 +1,8 @@ // #nullable disable +using EntityFrameworkCore.Projectables; +using Projectables.Repro; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Cast.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Cast.verified.txt index 9987c22..0035477 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Cast.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Cast.verified.txt @@ -1,5 +1,8 @@ // #nullable disable +using EntityFrameworkCore.Projectables; +using Projectables.Repro; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember.verified.txt index 643183d..d467476 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember.verified.txt @@ -1,5 +1,11 @@ // #nullable disable +using System; +using System.Linq; +using System.Collections.Generic; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember2.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember2.verified.txt index abe057b..5c768e9 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember2.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember2.verified.txt @@ -1,5 +1,11 @@ // #nullable disable +using System; +using System.Linq; +using System.Collections.Generic; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember3.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember3.verified.txt index 643183d..d467476 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember3.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ConstMember3.verified.txt @@ -1,5 +1,11 @@ // #nullable disable +using System; +using System.Linq; +using System.Collections.Generic; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DeclarationTypeNamesAreGettingFullyQualified.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DeclarationTypeNamesAreGettingFullyQualified.verified.txt index 103c17e..dd9cb44 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DeclarationTypeNamesAreGettingFullyQualified.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DeclarationTypeNamesAreGettingFullyQualified.verified.txt @@ -1,5 +1,11 @@ // #nullable disable +using System; +using System.Linq; +using System.Collections.Generic; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DefaultValuesGetRemoved.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DefaultValuesGetRemoved.verified.txt index c2eb349..0cb3392 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DefaultValuesGetRemoved.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.DefaultValuesGetRemoved.verified.txt @@ -1,5 +1,7 @@ // #nullable disable +using EntityFrameworkCore.Projectables; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.EnumAccessor.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.EnumAccessor.verified.txt index 0fe19c3..ce25012 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.EnumAccessor.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.EnumAccessor.verified.txt @@ -1,5 +1,7 @@ // #nullable disable +using EntityFrameworkCore.Projectables; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.FooOrBar.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.FooOrBar.verified.txt index 1109474..393afea 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.FooOrBar.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.FooOrBar.verified.txt @@ -1,5 +1,9 @@ // #nullable disable +using EntityFrameworkCore.Projectables; +using System.Collections.Generic; +using Projectables.Repro; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] 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 368090c..5468c2a 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericMethods_AreRewritten.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericMethods_AreRewritten.verified.txt @@ -1,5 +1,11 @@ // #nullable disable +using System; +using System.Linq; +using System.Collections.Generic; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericNullableReferenceTypesAreBeingEliminated.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericNullableReferenceTypesAreBeingEliminated.verified.txt index a0062d8..847f758 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericNullableReferenceTypesAreBeingEliminated.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericNullableReferenceTypesAreBeingEliminated.verified.txt @@ -1,5 +1,11 @@ // #nullable disable +using System; +using System.Collections.Generic; +using System.Linq; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericTypes.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericTypes.verified.txt index ed731e3..4c06e39 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericTypes.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericTypes.verified.txt @@ -1,5 +1,7 @@ // #nullable disable +using EntityFrameworkCore.Projectables; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericTypesWithConstraints.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericTypesWithConstraints.verified.txt index 801601b..468e6ad 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericTypesWithConstraints.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.GenericTypesWithConstraints.verified.txt @@ -1,5 +1,8 @@ // #nullable disable +using System; +using EntityFrameworkCore.Projectables; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.InheritedMembers.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.InheritedMembers.verified.txt index 1da8b27..f2157d2 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.InheritedMembers.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.InheritedMembers.verified.txt @@ -1,5 +1,11 @@ // #nullable disable +using System; +using System.Linq; +using System.Collections.Generic; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.IsOperator.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.IsOperator.verified.txt index e4cd0d0..55a8bc3 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.IsOperator.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.IsOperator.verified.txt @@ -1,5 +1,10 @@ // #nullable disable +using System; +using System.Linq; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Issue65.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Issue65.verified.txt new file mode 100644 index 0000000..e9ea658 --- /dev/null +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Issue65.verified.txt @@ -0,0 +1,16 @@ +// +#nullable disable +using System; +using EntityFrameworkCore.Projectables; + +namespace EntityFrameworkCore.Projectables.Generated +{ + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class _ContentExtensions_Outer + { + static global::System.Linq.Expressions.Expression> Expression() + { + return (string s) => s.Inner(); + } + } +} \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Issue652.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Issue652.verified.txt new file mode 100644 index 0000000..a90a8c0 --- /dev/null +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Issue652.verified.txt @@ -0,0 +1,17 @@ +// +#nullable disable +using System; +using EntityFrameworkCore.Projectables; +using Foo; + +namespace EntityFrameworkCore.Projectables.Generated +{ + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static class Foo_ContentExtensions_Outer + { + static global::System.Linq.Expressions.Expression> Expression() + { + return (string s) => s.Inner(); + } + } +} \ 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 456dab8..dccc517 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MinimalProjectableComputedProperty.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MinimalProjectableComputedProperty.verified.txt @@ -1,5 +1,9 @@ // #nullable disable +using System; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MixPrimaryConstructorAndProperties.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MixPrimaryConstructorAndProperties.verified.txt index 9c6adb3..30a1294 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MixPrimaryConstructorAndProperties.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MixPrimaryConstructorAndProperties.verified.txt @@ -1,5 +1,11 @@ // #nullable disable +using System; +using System.Linq; +using System.Collections.Generic; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MoreComplexProjectableComputedProperty.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MoreComplexProjectableComputedProperty.verified.txt index 21b55fa..59b563c 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MoreComplexProjectableComputedProperty.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.MoreComplexProjectableComputedProperty.verified.txt @@ -1,5 +1,9 @@ // #nullable disable +using System; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NavigationProperties.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NavigationProperties.verified.txt index ea9bbab..034257c 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NavigationProperties.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NavigationProperties.verified.txt @@ -1,5 +1,9 @@ // #nullable disable +using EntityFrameworkCore.Projectables; +using System.Collections.Generic; +using Projectables.Repro; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullConditionalNullCoalesceTypeConversion.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullConditionalNullCoalesceTypeConversion.verified.txt index d719a34..8d4eed8 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullConditionalNullCoalesceTypeConversion.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullConditionalNullCoalesceTypeConversion.verified.txt @@ -1,5 +1,7 @@ // #nullable disable +using EntityFrameworkCore.Projectables; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] 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 245fda4..3d8995b 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,5 +1,11 @@ // #nullable disable +using System; +using System.Linq; +using System.Collections.Generic; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] 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 a1079fc..1c20951 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,5 +1,11 @@ // #nullable disable +using System; +using System.Linq; +using System.Collections.Generic; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] 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 6d638b9..0420fa1 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,5 +1,10 @@ // #nullable disable +using System; +using System.Linq; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] 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 e144480..2786417 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,5 +1,10 @@ // #nullable disable +using System; +using System.Linq; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] 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 bf36da3..b8ce72b 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,5 +1,10 @@ // #nullable disable +using System; +using System.Linq; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] 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 56d0a78..d63f7c6 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,5 +1,10 @@ // #nullable disable +using System; +using System.Linq; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] 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 009576e..4187afb 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,5 +1,11 @@ // #nullable disable +using System; +using System.Linq; +using System.Collections.Generic; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypeCastOperatorGetsEliminated.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypeCastOperatorGetsEliminated.verified.txt index 223a00d..aa6fd95 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypeCastOperatorGetsEliminated.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypeCastOperatorGetsEliminated.verified.txt @@ -1,5 +1,11 @@ // #nullable disable +using System; +using System.Collections.Generic; +using System.Linq; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypesAreBeingEliminated.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypesAreBeingEliminated.verified.txt index aca6e43..88826b1 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypesAreBeingEliminated.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableReferenceTypesAreBeingEliminated.verified.txt @@ -1,5 +1,10 @@ // #nullable disable +using System; +using System.Linq; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] 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 fbf5589..827dcb3 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,5 +1,10 @@ // #nullable disable +using System; +using System.Linq; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] 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 8e1b353..2e3ba52 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,5 +1,10 @@ // #nullable disable +using System; +using System.Linq; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableValueCastOperatorsPersist.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableValueCastOperatorsPersist.verified.txt index 1ecf514..3f93eac 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableValueCastOperatorsPersist.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.NullableValueCastOperatorsPersist.verified.txt @@ -1,5 +1,11 @@ // #nullable disable +using System; +using System.Collections.Generic; +using System.Linq; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ParamsModifiedGetsRemoved.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ParamsModifiedGetsRemoved.verified.txt index 7efd579..3f5152f 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ParamsModifiedGetsRemoved.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ParamsModifiedGetsRemoved.verified.txt @@ -1,5 +1,7 @@ // #nullable disable +using EntityFrameworkCore.Projectables; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithMultipleArguments.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithMultipleArguments.verified.txt index 17a7c5b..e6f1903 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithMultipleArguments.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithMultipleArguments.verified.txt @@ -1,5 +1,9 @@ // #nullable disable +using System; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithSingleArgument.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithSingleArgument.verified.txt index 3ab4443..38b5559 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithSingleArgument.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedMethodWithSingleArgument.verified.txt @@ -1,5 +1,9 @@ // #nullable disable +using System; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedPropertyMethod.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedPropertyMethod.verified.txt index de9db08..4583693 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedPropertyMethod.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedPropertyMethod.verified.txt @@ -1,5 +1,9 @@ // #nullable disable +using System; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedPropertyUsingThis.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedPropertyUsingThis.verified.txt index 456dab8..dccc517 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedPropertyUsingThis.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableComputedPropertyUsingThis.verified.txt @@ -1,5 +1,9 @@ // #nullable disable +using System; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod.verified.txt index 96cf34b..e62ff27 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod.verified.txt @@ -1,5 +1,10 @@ // #nullable disable +using System; +using System.Linq; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod2.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod2.verified.txt index 20e79e4..4211a85 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod2.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod2.verified.txt @@ -1,5 +1,10 @@ // #nullable disable +using System; +using System.Linq; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod3.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod3.verified.txt index 8247b1c..0bd0865 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod3.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod3.verified.txt @@ -1,5 +1,10 @@ // #nullable disable +using System; +using System.Linq; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod4.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod4.verified.txt index 924c9ce..636c199 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod4.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectableExtensionMethod4.verified.txt @@ -1,5 +1,10 @@ // #nullable disable +using System; +using System.Linq; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectablePropertyToNavigationalProperty.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectablePropertyToNavigationalProperty.verified.txt index 2ff648b..bbf47b8 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectablePropertyToNavigationalProperty.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.ProjectablePropertyToNavigationalProperty.verified.txt @@ -1,5 +1,10 @@ // #nullable disable +using System; +using System.Linq; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.RelationalProperty.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.RelationalProperty.verified.txt index d387ce7..7e75c49 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.RelationalProperty.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.RelationalProperty.verified.txt @@ -1,5 +1,11 @@ // #nullable disable +using System; +using System.Linq; +using System.Collections.Generic; +using EntityFrameworkCore.Projectables; +using Foos; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.RequiredNamespace.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.RequiredNamespace.verified.txt index 9f69ddf..08e611e 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.RequiredNamespace.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.RequiredNamespace.verified.txt @@ -1,5 +1,8 @@ // #nullable disable +using EntityFrameworkCore.Projectables; +using One.Two; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableComputedInNestedClassProperty.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableComputedInNestedClassProperty.verified.txt index e524a2b..a493b87 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableComputedInNestedClassProperty.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableComputedInNestedClassProperty.verified.txt @@ -1,5 +1,9 @@ // #nullable disable +using System; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableComputedProperty.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableComputedProperty.verified.txt index f2bcdcc..47b3e7c 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableComputedProperty.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableComputedProperty.verified.txt @@ -1,5 +1,9 @@ // #nullable disable +using System; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableMethod.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableMethod.verified.txt index a87a611..ba0730c 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableMethod.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableMethod.verified.txt @@ -1,5 +1,9 @@ // #nullable disable +using System; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableProperty.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableProperty.verified.txt index a87a611..ba0730c 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableProperty.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.SimpleProjectableProperty.verified.txt @@ -1,5 +1,9 @@ // #nullable disable +using System; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMembers.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMembers.verified.txt index 643183d..d467476 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMembers.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMembers.verified.txt @@ -1,5 +1,11 @@ // #nullable disable +using System; +using System.Linq; +using System.Collections.Generic; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMembers2.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMembers2.verified.txt index abe057b..5c768e9 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMembers2.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMembers2.verified.txt @@ -1,5 +1,11 @@ // #nullable disable +using System; +using System.Linq; +using System.Collections.Generic; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMethodWithNoParameters.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMethodWithNoParameters.verified.txt index a57960f..e170859 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMethodWithNoParameters.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMethodWithNoParameters.verified.txt @@ -1,5 +1,10 @@ // #nullable disable +using System; +using System.Linq; +using System.Collections.Generic; +using EntityFrameworkCore.Projectables; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMethodWithParameters.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMethodWithParameters.verified.txt index ba05aef..6bfafc8 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMethodWithParameters.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.StaticMethodWithParameters.verified.txt @@ -1,5 +1,10 @@ // #nullable disable +using System; +using System.Linq; +using System.Collections.Generic; +using EntityFrameworkCore.Projectables; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.TypesInBodyGetsFullyQualified.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.TypesInBodyGetsFullyQualified.verified.txt index 7e0e17a..06f2ded 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.TypesInBodyGetsFullyQualified.verified.txt +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.TypesInBodyGetsFullyQualified.verified.txt @@ -1,5 +1,10 @@ // #nullable disable +using System; +using System.Linq; +using EntityFrameworkCore.Projectables; +using Foo; + namespace EntityFrameworkCore.Projectables.Generated { [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.cs b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.cs index 36981f2..c71f56b 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.cs +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.cs @@ -1615,6 +1615,63 @@ class EntityBase where TId : ICloneable, new() { return Verifier.Verify(result.GeneratedTrees[0].ToString()); } + [Fact] + public Task Issue65() + { + // issue: https://github.com/koenbeuk/EntityFrameworkCore.Projectables/issues/48 + + var compilation = CreateCompilation(@" +using System; +using EntityFrameworkCore.Projectables; + +public static class ContentExtensions +{ + public static string Inner(this string s) => s; + + [Projectable(NullConditionalRewriteSupport = NullConditionalRewriteSupport.Ignore)] + public static string Outer(this string s) => s?.Inner(); +} +"); + + var result = RunGenerator(compilation); + + Assert.Empty(result.Diagnostics); + Assert.Single(result.GeneratedTrees); + + return Verifier.Verify(result.GeneratedTrees[0].ToString()); + } + + [Fact] + public Task Issue652() + { + // issue: https://github.com/koenbeuk/EntityFrameworkCore.Projectables/issues/48 + + var compilation = CreateCompilation(@" +using System; +using EntityFrameworkCore.Projectables; + +namespace Foo; + +public static class ContentExtensions +{ + [Projectable(NullConditionalRewriteSupport = NullConditionalRewriteSupport.Ignore)] + public static string Outer(this string s) => s?.Inner(); +} + +public static class ContentExtensions2 +{ + public static string Inner(this string s) => s; +} +"); + + 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) From 458509c76cc4035cf8d1716d389a7c7597fe2cbb Mon Sep 17 00:00:00 2001 From: Koen Date: Wed, 19 Apr 2023 19:53:42 +0100 Subject: [PATCH 6/6] Removed 2 temp tests --- ...ressionGeneratorTests.Issue65.verified.txt | 16 ------ ...essionGeneratorTests.Issue652.verified.txt | 17 ------ .../ProjectionExpressionGeneratorTests.cs | 57 ------------------- 3 files changed, 90 deletions(-) delete mode 100644 tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Issue65.verified.txt delete mode 100644 tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Issue652.verified.txt diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Issue65.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Issue65.verified.txt deleted file mode 100644 index e9ea658..0000000 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Issue65.verified.txt +++ /dev/null @@ -1,16 +0,0 @@ -// -#nullable disable -using System; -using EntityFrameworkCore.Projectables; - -namespace EntityFrameworkCore.Projectables.Generated -{ - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _ContentExtensions_Outer - { - static global::System.Linq.Expressions.Expression> Expression() - { - return (string s) => s.Inner(); - } - } -} \ No newline at end of file diff --git a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Issue652.verified.txt b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Issue652.verified.txt deleted file mode 100644 index a90a8c0..0000000 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.Issue652.verified.txt +++ /dev/null @@ -1,17 +0,0 @@ -// -#nullable disable -using System; -using EntityFrameworkCore.Projectables; -using Foo; - -namespace EntityFrameworkCore.Projectables.Generated -{ - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_ContentExtensions_Outer - { - static global::System.Linq.Expressions.Expression> Expression() - { - return (string s) => s.Inner(); - } - } -} \ 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 c71f56b..36981f2 100644 --- a/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.cs +++ b/tests/EntityFrameworkCore.Projectables.Generator.Tests/ProjectionExpressionGeneratorTests.cs @@ -1615,63 +1615,6 @@ class EntityBase where TId : ICloneable, new() { return Verifier.Verify(result.GeneratedTrees[0].ToString()); } - [Fact] - public Task Issue65() - { - // issue: https://github.com/koenbeuk/EntityFrameworkCore.Projectables/issues/48 - - var compilation = CreateCompilation(@" -using System; -using EntityFrameworkCore.Projectables; - -public static class ContentExtensions -{ - public static string Inner(this string s) => s; - - [Projectable(NullConditionalRewriteSupport = NullConditionalRewriteSupport.Ignore)] - public static string Outer(this string s) => s?.Inner(); -} -"); - - var result = RunGenerator(compilation); - - Assert.Empty(result.Diagnostics); - Assert.Single(result.GeneratedTrees); - - return Verifier.Verify(result.GeneratedTrees[0].ToString()); - } - - [Fact] - public Task Issue652() - { - // issue: https://github.com/koenbeuk/EntityFrameworkCore.Projectables/issues/48 - - var compilation = CreateCompilation(@" -using System; -using EntityFrameworkCore.Projectables; - -namespace Foo; - -public static class ContentExtensions -{ - [Projectable(NullConditionalRewriteSupport = NullConditionalRewriteSupport.Ignore)] - public static string Outer(this string s) => s?.Inner(); -} - -public static class ContentExtensions2 -{ - public static string Inner(this string s) => s; -} -"); - - 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)