From 10cb0f65e758dd37cbb9320e216fcfb56ed04f0d Mon Sep 17 00:00:00 2001 From: Koen Date: Thu, 26 Mar 2026 01:08:41 +0000 Subject: [PATCH 1/2] refactor: Consolidate generated expression classes into partial classes --- .../Emitter/ReflectionFieldCache.cs | 88 ++++++--------- .../ExpressiveGenerator.cs | 46 ++++---- .../Registry/ExpressionRegistryEmitter.cs | 9 +- .../Registry/ExpressionRegistryEntry.cs | 1 + .../Services/ExpressionClassNameGenerator.cs | 106 ++++++++++++++++++ .../Services/ExpressiveResolver.cs | 15 ++- ...lockBodiedMethod_SimpleReturn.verified.txt | 5 +- ....BlockBodiedMethod_WithIfElse.verified.txt | 9 +- ...odiedMethod_WithLocalVariable.verified.txt | 9 +- ...BodiedMethod_WithNestedIfElse.verified.txt | 11 +- ...diedMethod_WithPropertyAccess.verified.txt | 9 +- ..._WithTransitiveLocalVariables.verified.txt | 9 +- ...ithmeticTests.CheckedAddition.verified.txt | 12 +- ...hmeticTests.CheckedConversion.verified.txt | 9 +- ...icTests.CheckedMultiplication.verified.txt | 12 +- ...ithmeticTests.CheckedNegation.verified.txt | 9 +- ...meticTests.CheckedSubtraction.verified.txt | 12 +- ...ts.CollectionExpression_Array.verified.txt | 5 +- ...ionExpression_ArrayWithSpread.verified.txt | 17 +-- ...tionExpression_ListWithSpread.verified.txt | 17 +-- ...ionExpression_MultipleSpreads.verified.txt | 18 +-- ...llectionExpression_SpreadOnly.verified.txt | 12 +- ...tionInitializer_DictionaryAdd.verified.txt | 14 +-- ...llectionInitializer_ListOfInt.verified.txt | 16 +-- ...leConstructor_BodyAssignments.verified.txt | 15 +-- ...jectableConstructor_Overloads.verified.txt | 33 ++---- ...cingBasePropertyInDerivedBody.verified.txt | 20 ++-- ...gPreviouslyAssignedInBaseCtor.verified.txt | 18 +-- ...ingPreviouslyAssignedProperty.verified.txt | 27 ++--- ..._ReferencingStaticConstMember.verified.txt | 20 ++-- ...nitializer_ChainedThisAndBase.verified.txt | 17 +-- ...RefPreviouslyAssignedProperty.verified.txt | 9 +- ...hisInitializer_SimpleOverload.verified.txt | 9 +- ...ThisInitializer_WithBodyAfter.verified.txt | 34 +++--- ...ializer_WithIfElseInDelegated.verified.txt | 17 +-- ...nstructor_WithBaseInitializer.verified.txt | 12 +- ..._WithBaseInitializerAndIfElse.verified.txt | 12 +- ...WithBaseInitializerExpression.verified.txt | 12 +- ...aseInitializer_AndEarlyReturn.verified.txt | 15 +-- ...lizer_AndIfElse_InDerivedBody.verified.txt | 21 ++-- ...Constructor_WithClassArgument.verified.txt | 21 ++-- ...eConstructor_WithDeepNestedIf.verified.txt | 12 +- ...r_WithEarlyReturn_GuardClause.verified.txt | 18 +-- ...leConstructor_WithElseIfChain.verified.txt | 12 +- ...meterlessConstructor_Succeeds.verified.txt | 12 +- ...bleConstructor_WithFullObject.verified.txt | 44 +++----- ...leConstructor_WithIfElseLogic.verified.txt | 15 +-- ...ithIfInsideLocalScope_AndElse.verified.txt | 21 ++-- ...tableConstructor_WithIfNoElse.verified.txt | 12 +- ...Constructor_WithLocalVariable.verified.txt | 17 +-- ...hLocalVariableUsedInCondition.verified.txt | 18 +-- ...or_WithMultipleClassArguments.verified.txt | 20 ++-- ...ctor_WithMultipleEarlyReturns.verified.txt | 12 +- ...or_WithMultipleLocalVariables.verified.txt | 32 ++---- ...eConstructor_WithNestedIfElse.verified.txt | 12 +- ...onstructor_WithNullCoalescing.verified.txt | 18 +-- ...tructor_WithNullableParameter.verified.txt | 15 +-- ...Constructor_WithSequentialIfs.verified.txt | 18 +-- ...structor_WithSwitchExpression.verified.txt | 18 +-- ...chExpression_AndExtraProperty.verified.txt | 28 ++--- ...tructor_WithTernaryAssignment.verified.txt | 21 ++-- ...isInitializer_AndElseIfInBody.verified.txt | 12 +- ...ndEnumMethodsReturningBoolean.verified.txt | 16 +-- ...ndEnumMethodsReturningInteger.verified.txt | 16 +-- ...thodsWithDescriptionAttribute.verified.txt | 16 +-- ...umMethodsWithDisplayAttribute.verified.txt | 14 +-- ...ndEnumMethodsWithNullableEnum.verified.txt | 22 ++-- ...xpandEnumMethodsWithParameter.verified.txt | 16 +-- ...erTests.ExtensionMemberMethod.verified.txt | 9 +- ...ionMemberMethodWithParameters.verified.txt | 9 +- ...ts.ExtensionMemberOnInterface.verified.txt | 18 +-- ...ts.ExtensionMemberOnPrimitive.verified.txt | 5 +- ...Tests.ExtensionMemberProperty.verified.txt | 9 +- ....ExtensionMemberWithBlockBody.verified.txt | 12 +- ...MemberWithIsPatternExpression.verified.txt | 9 +- ...tensionMemberWithMemberAccess.verified.txt | 18 +-- ...ionMemberWithSwitchExpression.verified.txt | 9 +- ...sts.ExpressiveExtensionMethod.verified.txt | 5 +- ...thod_CallingAnotherExpressive.verified.txt | 5 +- ...veExtensionMethod_OnValueType.verified.txt | 5 +- ...ExtensionMethod_SelfRecursive.verified.txt | 9 +- ...sWithConstraints_AreRewritten.verified.txt | 27 ++--- ...hTypeConstraints_AreRewritten.verified.txt | 24 ++-- ...s.GenericMethods_AreRewritten.verified.txt | 9 +- .../GenericTests.GenericTypes.verified.txt | 5 +- ...s.GenericTypesWithConstraints.verified.txt | 5 +- ...ndexFromEnd_WorksAsExpression.verified.txt | 9 +- ...Tests.Range_WorksAsExpression.verified.txt | 17 +-- ...eTests.DefaultInterfaceMember.verified.txt | 9 +- ...plicitInterfaceImplementation.verified.txt | 9 +- ...Tests.ExplicitInterfaceMember.verified.txt | 9 +- ...Tests.ListPattern_FixedLength.verified.txt | 19 ++-- ...rnTests.ListPattern_WithSlice.verified.txt | 15 +-- .../LoopTests.ForEach_Aggregate.verified.txt | 15 +-- .../LoopTests.ForEach_All.verified.txt | 15 +-- .../LoopTests.ForEach_Any.verified.txt | 15 +-- ....ForEach_ConditionalAggregate.verified.txt | 15 +-- ...onditionalMinWithMemberAccess.verified.txt | 26 ++--- ...nditionalSelectWithMethodCall.verified.txt | 27 ++--- ...pTests.ForEach_ConditionalSum.verified.txt | 15 +-- .../LoopTests.ForEach_CountAll.verified.txt | 15 +-- ...ts.ForEach_CountWithPredicate.verified.txt | 15 +-- ....ForEach_InstanceMethodInBody.verified.txt | 18 +-- .../LoopTests.ForEach_Min.verified.txt | 21 ++-- ....ForEach_SelectWithMethodCall.verified.txt | 24 ++-- .../LoopTests.ForEach_Sum.verified.txt | 15 +-- ...ch_SumWithChainedMemberAccess.verified.txt | 21 ++-- ...sts.ForEach_SumWithMethodCall.verified.txt | 18 +-- ...Tests.ForEach_SumWithSelector.verified.txt | 18 +-- ...oopDisableFlag_StillEmitsLoop.verified.txt | 15 +-- .../LoopTests.ForLoop_ArraySum.verified.txt | 9 +- ...hileLoop_EmitsBlockExpression.verified.txt | 5 +- ...s.BaseMemberExplicitReference.verified.txt | 9 +- ...s.BaseMemberImplicitReference.verified.txt | 9 +- ...s.BaseMethodExplicitReference.verified.txt | 9 +- .../MethodTests.Cast.verified.txt | 9 +- .../MethodTests.ConstMember.verified.txt | 12 +- ...NamesAreGettingFullyQualified.verified.txt | 5 +- ...Tests.DefaultValuesGetRemoved.verified.txt | 5 +- ...edMethodWithMultipleArguments.verified.txt | 5 +- ...putedMethodWithSingleArgument.verified.txt | 5 +- .../MethodTests.InheritedMembers.verified.txt | 9 +- .../MethodTests.IsOperator.verified.txt | 5 +- ..._WithDifferentParameterCounts.verified.txt | 10 +- ...s_WithDifferentParameterTypes.verified.txt | 14 +-- ...sts.ParamsModifierGetsRemoved.verified.txt | 5 +- ...MethodTests.RequiredNamespace.verified.txt | 9 +- ...dTests.SimpleExpressiveMethod.verified.txt | 5 +- .../MethodTests.StaticMembers.verified.txt | 12 +- .../MethodTests.StaticMembers2.verified.txt | 12 +- ....StaticMethodWithNoParameters.verified.txt | 5 +- ...ts.StaticMethodWithParameters.verified.txt | 5 +- ...thStaticCall_IsBeingRewritten.verified.txt | 25 ++--- ...Interpolation_FormatSpecifier.verified.txt | 12 +- ...ringInterpolation_LiteralOnly.verified.txt | 5 +- ...ltiplePartsWithNullCoalescing.verified.txt | 22 ++-- ...terpolation_SimpleIntProperty.verified.txt | 15 +-- ...TypesInBodyGetsFullyQualified.verified.txt | 15 +-- ...writeSupport_IsBeingRewritten.verified.txt | 9 +- ...erenceTypesAreBeingEliminated.verified.txt | 5 +- ...nalNullCoalesceTypeConversion.verified.txt | 9 +- ...gnoreSupport_IsBeingRewritten.verified.txt | 12 +- ...writeSupport_IsBeingRewritten.verified.txt | 12 +- ...gnoreSupport_IsBeingRewritten.verified.txt | 12 +- ...writeSupport_IsBeingRewritten.verified.txt | 12 +- ...ithDisableFlag_StillGenerates.verified.txt | 9 +- ...gnoreSupport_IsBeingRewritten.verified.txt | 9 +- ...writeSupport_IsBeingRewritten.verified.txt | 9 +- ...writeSupport_IsBeingRewritten.verified.txt | 17 +-- ...ypeCastOperatorGetsEliminated.verified.txt | 5 +- ...erenceTypesAreBeingEliminated.verified.txt | 5 +- ...gnoreSupport_IsBeingRewritten.verified.txt | 9 +- ...writeSupport_IsBeingRewritten.verified.txt | 9 +- ...ableValueCastOperatorsPersist.verified.txt | 5 +- ...writeSupport_IsBeingRewritten.verified.txt | 9 +- ...gnoreSupport_IsBeingRewritten.verified.txt | 9 +- ...writeSupport_IsBeingRewritten.verified.txt | 9 +- ...ternWithRelationalSubPatterns.verified.txt | 12 +- ...ssion_RecordPositionalPattern.verified.txt | 12 +- ...RecordStructPositionalPattern.verified.txt | 12 +- ...ssion_RecordPositionalPattern.verified.txt | 16 +-- ...ressiveComputedPropertyMethod.verified.txt | 9 +- ...siveComputedPropertyUsingThis.verified.txt | 9 +- ...opertyWithExplicitBlockGetter.verified.txt | 9 +- ...yWithExplicitExpressionGetter.verified.txt | 9 +- ...ropertyToNavigationalProperty.verified.txt | 12 +- ...opertyWithExplicitBlockGetter.verified.txt | 5 +- ...licitBlockGetterAndMethodCall.verified.txt | 9 +- ...hExplicitBlockGetterUsingThis.verified.txt | 9 +- ...yWithExplicitExpressionGetter.verified.txt | 5 +- .../PropertyTests.FooOrBar.verified.txt | 14 +-- ...malExpressiveComputedProperty.verified.txt | 9 +- ...lexExpressiveComputedProperty.verified.txt | 13 +-- ...rtyTests.NavigationProperties.verified.txt | 17 +-- ...ropertyWithCustomTransformers.verified.txt | 14 +-- ...pertyTests.RelationalProperty.verified.txt | 12 +- ...ComputedInNestedClassProperty.verified.txt | 9 +- ...pleExpressiveComputedProperty.verified.txt | 9 +- ...iveComputedPropertyWithSetter.verified.txt | 9 +- ...ests.SimpleExpressiveProperty.verified.txt | 5 +- ...ethodOverloads_BothRegistered.verified.txt | 11 +- ...ipleExpressives_AllRegistered.verified.txt | 11 +- ...eMethod_RegistryContainsEntry.verified.txt | 9 +- ...roperty_RegistryContainsEntry.verified.txt | 9 +- ...catenationTests.IntPlusString.verified.txt | 18 +-- ...ationTests.SingleStringConcat.verified.txt | 15 +-- ...enationTests.StringPlusString.verified.txt | 17 +-- ...died_IsPattern_WithAndPattern.verified.txt | 9 +- ..._IsPattern_WithNotNullPattern.verified.txt | 9 +- ...odied_IsPattern_WithOrPattern.verified.txt | 9 +- ...ExpressionWithConstantPattern.verified.txt | 9 +- ...itchExpressionWithTypePattern.verified.txt | 28 ++--- ...ression_WithRelationalPattern.verified.txt | 9 +- ...onalPattern_OnExtensionMethod.verified.txt | 9 +- ...TupleTests.NestedTupleLiteral.verified.txt | 12 +- ...pleTests.TupleBinary_Equality.verified.txt | 22 ++-- ...eTests.TupleBinary_Inequality.verified.txt | 22 ++-- ...pleTests.TupleLiteralInMethod.verified.txt | 15 +-- ...sts.TupleLiteralWith8Elements.verified.txt | 12 +- ...TupleLiteralWithNamedElements.verified.txt | 15 +-- ...ts.TupleLiteralWithParameters.verified.txt | 9 +- ...Tests.WithExpression_OnRecord.verified.txt | 19 ++-- ...ditionalIgnore_UsesIgnoreMode.verified.txt | 7 +- ...AppliesWithoutPerCallOverride.verified.txt | 7 +- ....Where_PerCallOverridesGlobal.verified.txt | 7 +- ...y_GeneratesGroupingReturnType.verified.txt | 4 +- ...nalRewrite_ExpandsInWhereBody.verified.txt | 7 +- ....OrderBy_GeneratesInterceptor.verified.txt | 4 +- ...enBy_CastsToIOrderedQueryable.verified.txt | 7 +- ...eArgument_GeneratesExpression.verified.txt | 4 +- ...lConditional_RewritesOperator.verified.txt | 7 +- ...pleLambda_GeneratesExpression.verified.txt | 4 +- ...e_GeneratesGenericInterceptor.verified.txt | 7 +- ...Expression_GeneratesCorrectly.verified.txt | 10 +- ..._GeneratesConcreteInterceptor.verified.txt | 4 +- ...lect_GeneratesTwoInterceptors.verified.txt | 7 +- ...ondition_GeneratesInterceptor.verified.txt | 4 +- .../ExpressionClassNameGeneratorTests.cs | 77 +++++++++++++ 218 files changed, 1177 insertions(+), 1825 deletions(-) diff --git a/src/ExpressiveSharp.Generator/Emitter/ReflectionFieldCache.cs b/src/ExpressiveSharp.Generator/Emitter/ReflectionFieldCache.cs index 178463d..42099d2 100644 --- a/src/ExpressiveSharp.Generator/Emitter/ReflectionFieldCache.cs +++ b/src/ExpressiveSharp.Generator/Emitter/ReflectionFieldCache.cs @@ -3,71 +3,59 @@ namespace ExpressiveSharp.Generator.Emitter; /// -/// Tracks and deduplicates private static readonly reflection field declarations -/// (, , -/// , ) +/// Returns inline reflection expressions for +/// , , +/// , and /// needed by the emitted expression-tree-building code. +/// Each Ensure* method returns a C# expression string that evaluates to the +/// reflection object at runtime, rather than a static field name. /// internal sealed class ReflectionFieldCache { private static readonly SymbolDisplayFormat _fullyQualifiedFormat = SymbolDisplayFormat.FullyQualifiedFormat; - private readonly string _prefix; - private readonly Dictionary _fieldNamesByKey = new(); - private readonly List _declarations = new(); - private int _propertyCounter; - private int _methodCounter; - private int _constructorCounter; - private int _fieldCounter; + private readonly Dictionary _expressionsByKey = new(); public ReflectionFieldCache(string prefix = "") { - _prefix = prefix; } /// - /// Returns the field name for a cached , - /// creating the declaration if this property hasn't been seen before. + /// Returns an inline reflection expression for a . /// public string EnsurePropertyInfo(IPropertySymbol property) { var typeFqn = property.ContainingType.ToDisplayString(_fullyQualifiedFormat); var key = $"P:{typeFqn}.{property.Name}"; - if (_fieldNamesByKey.TryGetValue(key, out var fieldName)) - return fieldName; + if (_expressionsByKey.TryGetValue(key, out var cached)) + return cached; - fieldName = $"_{_prefix}p{_propertyCounter++}"; - var declaration = $"""private static readonly global::System.Reflection.PropertyInfo {fieldName} = typeof({typeFqn}).GetProperty("{property.Name}");"""; - _fieldNamesByKey[key] = fieldName; - _declarations.Add(declaration); - return fieldName; + var expr = $"typeof({typeFqn}).GetProperty(\"{property.Name}\")"; + _expressionsByKey[key] = expr; + return expr; } /// - /// Returns the field name for a cached , - /// creating the declaration if this field hasn't been seen before. + /// Returns an inline reflection expression for a . /// public string EnsureFieldInfo(IFieldSymbol field) { var typeFqn = field.ContainingType.ToDisplayString(_fullyQualifiedFormat); var key = $"F:{typeFqn}.{field.Name}"; - if (_fieldNamesByKey.TryGetValue(key, out var fieldName)) - return fieldName; + if (_expressionsByKey.TryGetValue(key, out var cached)) + return cached; - fieldName = $"_{_prefix}f{_fieldCounter++}"; var flags = field.IsStatic ? "global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static" : "global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance"; - var declaration = $"""private static readonly global::System.Reflection.FieldInfo {fieldName} = typeof({typeFqn}).GetField("{field.Name}", {flags});"""; - _fieldNamesByKey[key] = fieldName; - _declarations.Add(declaration); - return fieldName; + var expr = $"typeof({typeFqn}).GetField(\"{field.Name}\", {flags})"; + _expressionsByKey[key] = expr; + return expr; } /// - /// Returns the field name for a cached , - /// creating the declaration if this method hasn't been seen before. + /// Returns an inline reflection expression for a . /// public string EnsureMethodInfo(IMethodSymbol method) { @@ -75,40 +63,34 @@ public string EnsureMethodInfo(IMethodSymbol method) var paramTypes = string.Join(", ", method.Parameters.Select(p => $"typeof({p.Type.ToDisplayString(_fullyQualifiedFormat)})")); var key = $"M:{typeFqn}.{method.Name}({paramTypes})"; - if (_fieldNamesByKey.TryGetValue(key, out var fieldName)) - return fieldName; + if (_expressionsByKey.TryGetValue(key, out var cached)) + return cached; - fieldName = $"_{_prefix}m{_methodCounter++}"; var flags = method.IsStatic ? "global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static" : "global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance"; - string declaration; + string expr; if (method.IsGenericMethod) { - // Generic methods: find by name + generic arity + param count, then MakeGenericMethod. - // We can't use GetMethod with parameter types because the definition's parameters - // reference its own type parameters (e.g. IEnumerable) which aren't valid C# types. var originalDef = method.OriginalDefinition; var genericArity = originalDef.TypeParameters.Length; var paramCount = originalDef.Parameters.Length; var typeArgs = string.Join(", ", method.TypeArguments.Select(t => $"typeof({t.ToDisplayString(_fullyQualifiedFormat)})")); - declaration = $"private static readonly global::System.Reflection.MethodInfo {fieldName} = global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof({typeFqn}).GetMethods({flags}), m => m.Name == \"{method.Name}\" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == {genericArity} && m.GetParameters().Length == {paramCount})).MakeGenericMethod({typeArgs});"; + expr = $"global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof({typeFqn}).GetMethods({flags}), m => m.Name == \"{method.Name}\" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == {genericArity} && m.GetParameters().Length == {paramCount})).MakeGenericMethod({typeArgs})"; } else { - declaration = $"private static readonly global::System.Reflection.MethodInfo {fieldName} = typeof({typeFqn}).GetMethod(\"{method.Name}\", {flags}, null, new global::System.Type[] {{ {paramTypes} }}, null);"; + expr = $"typeof({typeFqn}).GetMethod(\"{method.Name}\", {flags}, null, new global::System.Type[] {{ {paramTypes} }}, null)"; } - _fieldNamesByKey[key] = fieldName; - _declarations.Add(declaration); - return fieldName; + _expressionsByKey[key] = expr; + return expr; } /// - /// Returns the field name for a cached , - /// creating the declaration if this constructor hasn't been seen before. + /// Returns an inline reflection expression for a . /// public string EnsureConstructorInfo(IMethodSymbol constructor) { @@ -116,21 +98,19 @@ public string EnsureConstructorInfo(IMethodSymbol constructor) var paramTypes = string.Join(", ", constructor.Parameters.Select(p => $"typeof({p.Type.ToDisplayString(_fullyQualifiedFormat)})")); var key = $"C:{typeFqn}({paramTypes})"; - if (_fieldNamesByKey.TryGetValue(key, out var fieldName)) - return fieldName; + if (_expressionsByKey.TryGetValue(key, out var cached)) + return cached; - fieldName = $"_{_prefix}c{_constructorCounter++}"; - var declaration = $"private static readonly global::System.Reflection.ConstructorInfo {fieldName} = typeof({typeFqn}).GetConstructor(new global::System.Type[] {{ {paramTypes} }});"; - _fieldNamesByKey[key] = fieldName; - _declarations.Add(declaration); - return fieldName; + var expr = $"typeof({typeFqn}).GetConstructor(new global::System.Type[] {{ {paramTypes} }})"; + _expressionsByKey[key] = expr; + return expr; } /// - /// Returns all generated private static readonly field declarations. + /// Returns all static field declarations. Always empty since reflection is now inlined. /// public IReadOnlyList GetDeclarations() { - return _declarations; + return Array.Empty(); } } diff --git a/src/ExpressiveSharp.Generator/ExpressiveGenerator.cs b/src/ExpressiveSharp.Generator/ExpressiveGenerator.cs index b5d1ecd..3539410 100644 --- a/src/ExpressiveSharp.Generator/ExpressiveGenerator.cs +++ b/src/ExpressiveSharp.Generator/ExpressiveGenerator.cs @@ -117,24 +117,29 @@ private static void Execute( factoryCandidate.Identifier.Text)); } - var generatedClassName = ExpressionClassNameGenerator.GenerateName(expressive.ClassNamespace, expressive.NestedInClassNames, expressive.MemberName, expressive.ParameterTypeNames); - var generatedFileName = expressive.ClassTypeParameterList is not null ? $"{generatedClassName}-{expressive.ClassTypeParameterList.Parameters.Count}.g.cs" : $"{generatedClassName}.g.cs"; + var generatedClassName = ExpressionClassNameGenerator.GenerateClassName(expressive.ClassNamespace, expressive.NestedInClassNames); + var methodSuffix = ExpressionClassNameGenerator.GenerateMethodSuffix(expressive.MemberName, expressive.ParameterTypeNames); + var generatedFileName = expressive.ClassTypeParameterList is not null + ? $"{generatedClassName}-{expressive.ClassTypeParameterList.Parameters.Count}.{methodSuffix}.g.cs" + : $"{generatedClassName}.{methodSuffix}.g.cs"; if (expressive.ExpressionTreeEmission is null) { throw new InvalidOperationException("ExpressionTreeEmission must be set"); } - EmitExpressionTreeSource(expressive, generatedClassName, generatedFileName, member, compilation, context); + EmitExpressionTreeSource(expressive, generatedClassName, methodSuffix, generatedFileName, member, compilation, context); } /// /// Emits the generated source file using raw text when is available. - /// This path generates imperative Expression.* factory calls instead of a lambda return. + /// Each file declares the same static partial class — one per declaring type — and adds + /// a uniquely-named {methodSuffix}_Expression() method for this member. /// private static void EmitExpressionTreeSource( ExpressiveDescriptor expressive, string generatedClassName, + string methodSuffix, string generatedFileName, MemberDeclarationSyntax member, Compilation? compilation, @@ -186,21 +191,9 @@ private static void EmitExpressionTreeSource( ? string.Join(" ", expressive.ConstraintClauses.Value.Select(c => c.NormalizeWhitespace().ToFullString())) : ""; - sb.AppendLine($" [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]"); - sb.AppendLine($" static class {generatedClassName}{typeParamList} {constraintClauses}"); + sb.AppendLine($" static partial class {generatedClassName}{typeParamList} {constraintClauses}"); sb.AppendLine(" {"); - // Static fields for cached reflection info - foreach (var field in emission.StaticFields) - { - sb.AppendLine($" {field}"); - } - - if (emission.StaticFields.Count > 0) - { - sb.AppendLine(); - } - // Source comment showing the original C# member var sourceText = member.NormalizeWhitespace().ToFullString(); foreach (var line in sourceText.Split('\n')) @@ -209,19 +202,19 @@ private static void EmitExpressionTreeSource( sb.AppendLine($" // {trimmed}"); } - // Expression() method - sb.AppendLine($" static {returnType} Expression{methodTypeParamList}() {methodConstraintClauses}"); + // {methodSuffix}_Expression() method + sb.AppendLine($" static {returnType} {methodSuffix}_Expression{methodTypeParamList}() {methodConstraintClauses}"); sb.AppendLine(" {"); sb.Append(emission.Body); sb.AppendLine(" }"); - // Transformers property (when declared via attribute) + // Transformers (when declared via attribute) if (expressive.DeclaredTransformerTypeNames.Count > 0) { sb.AppendLine(); var transformerInstances = string.Join(", ", expressive.DeclaredTransformerTypeNames.Select(t => $"new {t}()")); - sb.AppendLine($" static global::ExpressiveSharp.IExpressionTreeTransformer[] Transformers() => [{transformerInstances}];"); + sb.AppendLine($" static global::ExpressiveSharp.IExpressionTreeTransformer[] {methodSuffix}_Transformers() => [{transformerInstances}];"); } sb.AppendLine(" }"); @@ -285,20 +278,22 @@ private static void EmitExpressionTreeSource( memberLookupName = memberSymbol.Name; } - // Build the generated class name using the same logic as Execute + // Build the generated class name and method name using the same logic as Execute var classNamespace = containingType.ContainingNamespace.IsGlobalNamespace ? null : containingType.ContainingNamespace.ToDisplayString(); var nestedTypePath = GetRegistryNestedTypePath(containingType); - var generatedClassName = ExpressionClassNameGenerator.GenerateName( + var generatedClassFullName = ExpressionClassNameGenerator.GenerateClassFullName( classNamespace, - nestedTypePath, + nestedTypePath); + + var methodSuffix = ExpressionClassNameGenerator.GenerateMethodSuffix( memberLookupName, parameterTypeNames.IsEmpty ? null : parameterTypeNames); - var generatedClassFullName = "ExpressiveSharp.Generated." + generatedClassName; + var expressionMethodName = methodSuffix + "_Expression"; var declaringTypeFullName = containingType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); @@ -307,6 +302,7 @@ private static void EmitExpressionTreeSource( MemberKind: memberKind, MemberLookupName: memberLookupName, GeneratedClassFullName: generatedClassFullName, + ExpressionMethodName: expressionMethodName, ParameterTypeNames: parameterTypeNames); } diff --git a/src/ExpressiveSharp.Generator/Registry/ExpressionRegistryEmitter.cs b/src/ExpressiveSharp.Generator/Registry/ExpressionRegistryEmitter.cs index 6065a4a..f56bc77 100644 --- a/src/ExpressiveSharp.Generator/Registry/ExpressionRegistryEmitter.cs +++ b/src/ExpressiveSharp.Generator/Registry/ExpressionRegistryEmitter.cs @@ -126,7 +126,7 @@ private static void WriteRegistryEntryStatement(IndentedTextWriter writer, Expre if (memberCallExpr is not null) { - writer.WriteLine($"Register(map, {memberCallExpr}, \"{entry.GeneratedClassFullName}\");"); + writer.WriteLine($"Register(map, {memberCallExpr}, \"{entry.GeneratedClassFullName}\", \"{entry.ExpressionMethodName}\");"); } } @@ -174,17 +174,18 @@ private static void EmitTryGetMethod(IndentedTextWriter writer) /// private static void EmitRegisterHelper(IndentedTextWriter writer) { - writer.WriteLine("private static void Register(Dictionary map, MethodBase m, string exprClass)"); + writer.WriteLine("private static void Register(Dictionary map, MethodBase m, string exprClass, string exprMethodName)"); writer.WriteLine("{"); writer.Indent++; writer.WriteLine("if (m is null) return;"); writer.WriteLine("var exprType = m.DeclaringType?.Assembly.GetType(exprClass);"); - writer.WriteLine(@"var exprMethod = exprType?.GetMethod(""Expression"", BindingFlags.Static | BindingFlags.NonPublic);"); + writer.WriteLine(@"var exprMethod = exprType?.GetMethod(exprMethodName, BindingFlags.Static | BindingFlags.NonPublic);"); writer.WriteLine("if (exprMethod is null) return;"); writer.WriteLine("var expr = (LambdaExpression)exprMethod.Invoke(null, null)!;"); writer.WriteLine(); writer.WriteLine("// Apply declared transformers from the generated class (if any)"); - writer.WriteLine(@"var transformersMethod = exprType.GetMethod(""Transformers"", BindingFlags.Static | BindingFlags.NonPublic);"); + writer.WriteLine(@"var transformersSuffix = exprMethodName.Substring(0, exprMethodName.Length - ""_Expression"".Length) + ""_Transformers"";"); + writer.WriteLine(@"var transformersMethod = exprType.GetMethod(transformersSuffix, BindingFlags.Static | BindingFlags.NonPublic);"); writer.WriteLine(@"if (transformersMethod?.Invoke(null, null) is global::ExpressiveSharp.IExpressionTreeTransformer[] transformers)"); writer.WriteLine("{"); writer.Indent++; diff --git a/src/ExpressiveSharp.Generator/Registry/ExpressionRegistryEntry.cs b/src/ExpressiveSharp.Generator/Registry/ExpressionRegistryEntry.cs index b935431..bac74d7 100644 --- a/src/ExpressiveSharp.Generator/Registry/ExpressionRegistryEntry.cs +++ b/src/ExpressiveSharp.Generator/Registry/ExpressionRegistryEntry.cs @@ -12,6 +12,7 @@ sealed internal record ExpressionRegistryEntry( ExpressionRegistryMemberType MemberKind, string MemberLookupName, string GeneratedClassFullName, + string ExpressionMethodName, EquatableImmutableArray ParameterTypeNames ); diff --git a/src/ExpressiveSharp/Services/ExpressionClassNameGenerator.cs b/src/ExpressiveSharp/Services/ExpressionClassNameGenerator.cs index f0f463d..9beffdb 100644 --- a/src/ExpressiveSharp/Services/ExpressionClassNameGenerator.cs +++ b/src/ExpressiveSharp/Services/ExpressionClassNameGenerator.cs @@ -34,6 +34,112 @@ public static string GenerateFullName(string? namespaceName, IEnumerable return GenerateNameImpl(stringBuilder, namespaceName, nestedInClassNames, memberName, parameterTypeNames); } + /// + /// Generates the class-level name (without member or parameter suffixes) for the + /// consolidated partial class that holds all expression methods for a given type. + /// + public static string GenerateClassName(string? namespaceName, IEnumerable? nestedInClassNames) + { + var sb = new StringBuilder(); + return GenerateClassNameImpl(sb, namespaceName, nestedInClassNames); + } + + /// + /// Generates the fully-qualified class name (with prefix) + /// for the consolidated partial class. + /// + public static string GenerateClassFullName(string? namespaceName, IEnumerable? nestedInClassNames) + { + var sb = new StringBuilder(Namespace); + sb.Append('.'); + return GenerateClassNameImpl(sb, namespaceName, nestedInClassNames); + } + + /// + /// Generates the method suffix that encodes a member name and its parameter types. + /// The result is used as a method name prefix (e.g. "Add_P0_int") within the + /// consolidated partial class. + /// + public static string GenerateMethodSuffix(string memberName, IEnumerable? parameterTypeNames) + { + var sb = new StringBuilder(); + + if (memberName.IndexOf('.') >= 0) + { + sb.Append(memberName.Replace(".", "__")); + } + else + { + sb.Append(memberName); + } + + if (parameterTypeNames is not null) + { + var parameterIndex = 0; + foreach (var parameterTypeName in parameterTypeNames) + { + sb.Append("_P"); + sb.Append(parameterIndex); + sb.Append('_'); + AppendSanitizedTypeName(sb, parameterTypeName); + parameterIndex++; + } + } + + return sb.ToString(); + } + + static string GenerateClassNameImpl(StringBuilder stringBuilder, string? namespaceName, IEnumerable? nestedInClassNames) + { + if (namespaceName is not null) + { + foreach (var c in namespaceName) + { + stringBuilder.Append(c == '.' ? '_' : c); + } + } + + stringBuilder.Append('_'); + var arity = 0; + + if (nestedInClassNames is not null) + { + foreach (var className in nestedInClassNames) + { + 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('_'); + } + } + + // Remove trailing '_' from class names (the member name used to follow) + if (stringBuilder.Length > 0 && stringBuilder[stringBuilder.Length - 1] == '_') + { + stringBuilder.Length--; + } + + if (arity > 0) + { + stringBuilder.Append('`'); + stringBuilder.Append(arity); + } + + return stringBuilder.ToString(); + } + static string GenerateNameImpl(StringBuilder stringBuilder, string? namespaceName, IEnumerable? nestedInClassNames, string memberName, IEnumerable? parameterTypeNames) { // Append namespace, replacing '.' separators with '_' in a single pass (no intermediate string). diff --git a/src/ExpressiveSharp/Services/ExpressiveResolver.cs b/src/ExpressiveSharp/Services/ExpressiveResolver.cs index f5bfdc6..ebf5dfe 100644 --- a/src/ExpressiveSharp/Services/ExpressiveResolver.cs +++ b/src/ExpressiveSharp/Services/ExpressiveResolver.cs @@ -216,12 +216,16 @@ private static LambdaExpression ResolveExpressionCore(MemberInfo expressiveMembe } } - // GetNestedTypePath() returns a Type[] — project to string[] with a direct loop, no LINQ Select. - var generatedContainingTypeName = ExpressionClassNameGenerator.GenerateFullName( + // Build the generated class name (without member) and method suffix separately. + var nestedTypeNames = NestedTypePathToNames(declaringType.GetNestedTypePath()); + var generatedContainingTypeName = ExpressionClassNameGenerator.GenerateClassFullName( declaringType.Namespace, - NestedTypePathToNames(declaringType.GetNestedTypePath()), + nestedTypeNames); + + var methodSuffix = ExpressionClassNameGenerator.GenerateMethodSuffix( memberLookupName, parameterTypeNames); + var expressionMethodName = methodSuffix + "_Expression"; var expressionFactoryType = declaringType.Assembly.GetType(generatedContainingTypeName); @@ -235,7 +239,7 @@ private static LambdaExpression ResolveExpressionCore(MemberInfo expressiveMembe expressionFactoryType = expressionFactoryType.MakeGenericType(originalDeclaringType.GenericTypeArguments); } - var expressionFactoryMethod = expressionFactoryType.GetMethod("Expression", BindingFlags.Static | BindingFlags.NonPublic); + var expressionFactoryMethod = expressionFactoryType.GetMethod(expressionMethodName, BindingFlags.Static | BindingFlags.NonPublic); if (expressionFactoryMethod is null) { @@ -252,7 +256,8 @@ private static LambdaExpression ResolveExpressionCore(MemberInfo expressiveMembe return null; // Apply declared transformers from the generated class (if any) - var transformersMethod = expressionFactoryType.GetMethod("Transformers", BindingFlags.Static | BindingFlags.NonPublic); + var transformerMethodName = methodSuffix + "_Transformers"; + var transformersMethod = expressionFactoryType.GetMethod(transformerMethodName, BindingFlags.Static | BindingFlags.NonPublic); if (transformersMethod?.Invoke(null, null) is IExpressionTreeTransformer[] transformers) { Expression result = expression; diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_SimpleReturn.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_SimpleReturn.verified.txt index c1e75bc..5eec2a2 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_SimpleReturn.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_SimpleReturn.verified.txt @@ -5,15 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { // [Expressive(AllowBlockBody = true)] // public int Foo() // { // return 42; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var expr_0 = global::System.Linq.Expressions.Expression.Constant(42, typeof(int)); // 42 diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_WithIfElse.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_WithIfElse.verified.txt index bbe15dd..47c619d 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_WithIfElse.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_WithIfElse.verified.txt @@ -5,11 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Bar"); - // [Expressive(AllowBlockBody = true)] // public int Foo() // { @@ -22,10 +19,10 @@ namespace ExpressiveSharp.Generated // return 0; // } // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Bar + var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Bar")); // Bar var expr_3 = global::System.Linq.Expressions.Expression.Constant(10, typeof(int)); // 10 var expr_1 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThan, expr_2, expr_3); var expr_4 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_WithLocalVariable.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_WithLocalVariable.verified.txt index 857e45c..26bd7b2 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_WithLocalVariable.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_WithLocalVariable.verified.txt @@ -5,22 +5,19 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Bar"); - // [Expressive(AllowBlockBody = true)] // public int Foo() // { // var temp = Bar * 2; // return temp + 5; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var expr_0 = global::System.Linq.Expressions.Expression.Variable(typeof(int), "temp"); // { var temp = Bar * 2; return temp... - var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Bar + var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Bar")); // Bar var expr_3 = global::System.Linq.Expressions.Expression.Constant(2, typeof(int)); // 2 var expr_1 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Multiply, expr_2, expr_3); var expr_4 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_1); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_WithNestedIfElse.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_WithNestedIfElse.verified.txt index a8c58c3..fb92d48 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_WithNestedIfElse.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_WithNestedIfElse.verified.txt @@ -5,11 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Bar"); - // [Expressive(AllowBlockBody = true)] // public string Foo() // { @@ -26,14 +23,14 @@ namespace ExpressiveSharp.Generated // return "Low"; // } // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Bar + var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Bar")); // Bar var expr_3 = global::System.Linq.Expressions.Expression.Constant(10, typeof(int)); // 10 var expr_1 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThan, expr_2, expr_3); var expr_4 = global::System.Linq.Expressions.Expression.Constant("High", typeof(string)); // "High" - var expr_7 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Bar + var expr_7 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Bar")); // Bar var expr_8 = global::System.Linq.Expressions.Expression.Constant(5, typeof(int)); // 5 var expr_6 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThan, expr_7, expr_8); var expr_9 = global::System.Linq.Expressions.Expression.Constant("Medium", typeof(string)); // "Medium" diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_WithPropertyAccess.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_WithPropertyAccess.verified.txt index 7126f3d..cb16535 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_WithPropertyAccess.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_WithPropertyAccess.verified.txt @@ -5,20 +5,17 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Bar"); - // [Expressive(AllowBlockBody = true)] // public int Foo() // { // return Bar + 10; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Bar + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Bar")); // Bar var expr_2 = global::System.Linq.Expressions.Expression.Constant(10, typeof(int)); // 10 var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_1, expr_2); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_WithTransitiveLocalVariables.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_WithTransitiveLocalVariables.verified.txt index 3fdc53e..769da89 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_WithTransitiveLocalVariables.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/BlockBodyTests.BlockBodiedMethod_WithTransitiveLocalVariables.verified.txt @@ -5,11 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Bar"); - // [Expressive(AllowBlockBody = true)] // public int Foo() // { @@ -17,11 +14,11 @@ namespace ExpressiveSharp.Generated // var b = a + 5; // return b + 10; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var expr_0 = global::System.Linq.Expressions.Expression.Variable(typeof(int), "a"); // { var a = Bar * 2; var b = a + 5;... - var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Bar + var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Bar")); // Bar var expr_3 = global::System.Linq.Expressions.Expression.Constant(2, typeof(int)); // 2 var expr_1 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Multiply, expr_2, expr_3); var expr_4 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_1); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CheckedArithmeticTests.CheckedAddition.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CheckedArithmeticTests.CheckedAddition.verified.txt index dc3879e..f209761 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CheckedArithmeticTests.CheckedAddition.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CheckedArithmeticTests.CheckedAddition.verified.txt @@ -5,19 +5,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Sum + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("A"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.C).GetProperty("B"); - // [Expressive] // public int Sum => checked(A + B); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Sum_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // A - var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, _p1); // B + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("A")); // A + var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("B")); // B var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.AddChecked, expr_1, expr_2); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CheckedArithmeticTests.CheckedConversion.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CheckedArithmeticTests.CheckedConversion.verified.txt index b2f35fe..3548082 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CheckedArithmeticTests.CheckedConversion.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CheckedArithmeticTests.CheckedConversion.verified.txt @@ -5,17 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Truncated + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Value"); - // [Expressive] // public int Truncated => checked((int)Value); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Truncated_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Value + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Value")); // Value var expr_0 = global::System.Linq.Expressions.Expression.ConvertChecked(expr_1, typeof(int)); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CheckedArithmeticTests.CheckedMultiplication.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CheckedArithmeticTests.CheckedMultiplication.verified.txt index 221cff9..4f4c0d0 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CheckedArithmeticTests.CheckedMultiplication.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CheckedArithmeticTests.CheckedMultiplication.verified.txt @@ -5,19 +5,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Product + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("A"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.C).GetProperty("B"); - // [Expressive] // public int Product => checked(A * B); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Product_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // A - var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, _p1); // B + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("A")); // A + var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("B")); // B var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.MultiplyChecked, expr_1, expr_2); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CheckedArithmeticTests.CheckedNegation.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CheckedArithmeticTests.CheckedNegation.verified.txt index 6eae859..cc7d04b 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CheckedArithmeticTests.CheckedNegation.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CheckedArithmeticTests.CheckedNegation.verified.txt @@ -5,17 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Negated + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("A"); - // [Expressive] // public int Negated => checked(-A); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Negated_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // A + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("A")); // A var expr_0 = global::System.Linq.Expressions.Expression.MakeUnary(global::System.Linq.Expressions.ExpressionType.NegateChecked, expr_1, typeof(int)); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CheckedArithmeticTests.CheckedSubtraction.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CheckedArithmeticTests.CheckedSubtraction.verified.txt index 4542caf..ac19225 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CheckedArithmeticTests.CheckedSubtraction.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CheckedArithmeticTests.CheckedSubtraction.verified.txt @@ -5,19 +5,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Diff + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("A"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.C).GetProperty("B"); - // [Expressive] // public int Diff => checked(A - B); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Diff_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // A - var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, _p1); // B + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("A")); // A + var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("B")); // B var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.SubtractChecked, expr_1, expr_2); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionExpression_Array.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionExpression_Array.verified.txt index fda8102..164a7eb 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionExpression_Array.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionExpression_Array.verified.txt @@ -5,12 +5,11 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Numbers + static partial class Foo_C { // [Expressive] // public int[] Numbers => [1, 2, 3]; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Numbers_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var expr_1 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionExpression_ArrayWithSpread.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionExpression_ArrayWithSpread.verified.txt index c2e9470..6e24d8f 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionExpression_ArrayWithSpread.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionExpression_ArrayWithSpread.verified.txt @@ -5,26 +5,21 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Combined + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "ToArray" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 1)).MakeGenericMethod(typeof(int)); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Items"); - private static readonly global::System.Reflection.MethodInfo _m1 = global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "Concat" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 2)).MakeGenericMethod(typeof(int)); - // [Expressive] // public int[] Combined => [1, ..Items, 2]; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Combined_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var expr_1 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 var expr_2 = global::System.Linq.Expressions.Expression.NewArrayInit(typeof(int), expr_1); - var expr_3 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Items + var expr_3 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Items")); // Items var expr_4 = global::System.Linq.Expressions.Expression.Constant(2, typeof(int)); // 2 var expr_5 = global::System.Linq.Expressions.Expression.NewArrayInit(typeof(int), expr_4); - var expr_6 = global::System.Linq.Expressions.Expression.Call(_m1, expr_2, expr_3); - var expr_7 = global::System.Linq.Expressions.Expression.Call(_m1, expr_6, expr_5); - var expr_0 = global::System.Linq.Expressions.Expression.Call(_m0, expr_7); + var expr_6 = global::System.Linq.Expressions.Expression.Call(global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "Concat" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 2)).MakeGenericMethod(typeof(int)), expr_2, expr_3); + var expr_7 = global::System.Linq.Expressions.Expression.Call(global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "Concat" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 2)).MakeGenericMethod(typeof(int)), expr_6, expr_5); + var expr_0 = global::System.Linq.Expressions.Expression.Call(global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "ToArray" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 1)).MakeGenericMethod(typeof(int)), expr_7); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionExpression_ListWithSpread.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionExpression_ListWithSpread.verified.txt index e59ee12..9652f48 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionExpression_ListWithSpread.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionExpression_ListWithSpread.verified.txt @@ -5,26 +5,21 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Combined + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "ToList" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 1)).MakeGenericMethod(typeof(int)); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Items"); - private static readonly global::System.Reflection.MethodInfo _m1 = global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "Concat" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 2)).MakeGenericMethod(typeof(int)); - // [Expressive] // public List Combined => [1, ..Items, 2]; - static global::System.Linq.Expressions.Expression>> Expression() + static global::System.Linq.Expressions.Expression>> Combined_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var expr_1 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 var expr_2 = global::System.Linq.Expressions.Expression.NewArrayInit(typeof(int), expr_1); - var expr_3 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Items + var expr_3 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Items")); // Items var expr_4 = global::System.Linq.Expressions.Expression.Constant(2, typeof(int)); // 2 var expr_5 = global::System.Linq.Expressions.Expression.NewArrayInit(typeof(int), expr_4); - var expr_6 = global::System.Linq.Expressions.Expression.Call(_m1, expr_2, expr_3); - var expr_7 = global::System.Linq.Expressions.Expression.Call(_m1, expr_6, expr_5); - var expr_0 = global::System.Linq.Expressions.Expression.Call(_m0, expr_7); + var expr_6 = global::System.Linq.Expressions.Expression.Call(global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "Concat" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 2)).MakeGenericMethod(typeof(int)), expr_2, expr_3); + var expr_7 = global::System.Linq.Expressions.Expression.Call(global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "Concat" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 2)).MakeGenericMethod(typeof(int)), expr_6, expr_5); + var expr_0 = global::System.Linq.Expressions.Expression.Call(global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "ToList" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 1)).MakeGenericMethod(typeof(int)), expr_7); return global::System.Linq.Expressions.Expression.Lambda>>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionExpression_MultipleSpreads.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionExpression_MultipleSpreads.verified.txt index 660774c..c528328 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionExpression_MultipleSpreads.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionExpression_MultipleSpreads.verified.txt @@ -5,23 +5,17 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_All + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "ToArray" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 1)).MakeGenericMethod(typeof(int)); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Items"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.C).GetProperty("Others"); - private static readonly global::System.Reflection.MethodInfo _m1 = global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "Concat" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 2)).MakeGenericMethod(typeof(int)); - // [Expressive] // public int[] All => [..Items, ..Others]; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> All_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Items - var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, _p1); // Others - var expr_3 = global::System.Linq.Expressions.Expression.Call(_m1, expr_1, expr_2); - var expr_0 = global::System.Linq.Expressions.Expression.Call(_m0, expr_3); + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Items")); // Items + var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Others")); // Others + var expr_3 = global::System.Linq.Expressions.Expression.Call(global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "Concat" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 2)).MakeGenericMethod(typeof(int)), expr_1, expr_2); + var expr_0 = global::System.Linq.Expressions.Expression.Call(global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "ToArray" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 1)).MakeGenericMethod(typeof(int)), expr_3); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionExpression_SpreadOnly.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionExpression_SpreadOnly.verified.txt index 95a8616..3c87ebc 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionExpression_SpreadOnly.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionExpression_SpreadOnly.verified.txt @@ -5,19 +5,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Copy + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "ToArray" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 1)).MakeGenericMethod(typeof(int)); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Items"); - // [Expressive] // public int[] Copy => [..Items]; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Copy_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Items - var expr_0 = global::System.Linq.Expressions.Expression.Call(_m0, expr_1); + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Items")); // Items + var expr_0 = global::System.Linq.Expressions.Expression.Call(global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "ToArray" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 1)).MakeGenericMethod(typeof(int)), expr_1); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionInitializer_DictionaryAdd.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionInitializer_DictionaryAdd.verified.txt index 31b0f67..65940d6 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionInitializer_DictionaryAdd.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionInitializer_DictionaryAdd.verified.txt @@ -5,12 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Map + static partial class Foo_C { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::System.Collections.Generic.Dictionary).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.Collections.Generic.Dictionary).GetMethod("Add", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(string), typeof(int) }, null); - // [Expressive] // public Dictionary Map => new Dictionary // { @@ -23,16 +19,16 @@ namespace ExpressiveSharp.Generated // 2 // } // }; - static global::System.Linq.Expressions.Expression>> Expression() + static global::System.Linq.Expressions.Expression>> Map_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.New(_c0); // new Dictionary { { "a", 1 }, { "b", 2 } } + var expr_1 = global::System.Linq.Expressions.Expression.New(typeof(global::System.Collections.Generic.Dictionary).GetConstructor(new global::System.Type[] { })); // new Dictionary { { "a", 1 }, { "b", 2 } } var expr_2 = global::System.Linq.Expressions.Expression.Constant("a", typeof(string)); // "a" var expr_3 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 - var expr_4 = global::System.Linq.Expressions.Expression.ElementInit(_m0, expr_2, expr_3); + var expr_4 = global::System.Linq.Expressions.Expression.ElementInit(typeof(global::System.Collections.Generic.Dictionary).GetMethod("Add", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(string), typeof(int) }, null), expr_2, expr_3); var expr_5 = global::System.Linq.Expressions.Expression.Constant("b", typeof(string)); // "b" var expr_6 = global::System.Linq.Expressions.Expression.Constant(2, typeof(int)); // 2 - var expr_7 = global::System.Linq.Expressions.Expression.ElementInit(_m0, expr_5, expr_6); + var expr_7 = global::System.Linq.Expressions.Expression.ElementInit(typeof(global::System.Collections.Generic.Dictionary).GetMethod("Add", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(string), typeof(int) }, null), expr_5, expr_6); var expr_0 = global::System.Linq.Expressions.Expression.ListInit(expr_1, expr_4, expr_7); return global::System.Linq.Expressions.Expression.Lambda>>(expr_0, p__this); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionInitializer_ListOfInt.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionInitializer_ListOfInt.verified.txt index 12c2448..da5af91 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionInitializer_ListOfInt.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/CollectionExpressionTests.CollectionInitializer_ListOfInt.verified.txt @@ -5,12 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Numbers + static partial class Foo_C { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::System.Collections.Generic.List).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.Collections.Generic.List).GetMethod("Add", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int) }, null); - // [Expressive] // public List Numbers => new List // { @@ -18,16 +14,16 @@ namespace ExpressiveSharp.Generated // 2, // 3 // }; - static global::System.Linq.Expressions.Expression>> Expression() + static global::System.Linq.Expressions.Expression>> Numbers_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.New(_c0); // new List { 1, 2, 3 } + var expr_1 = global::System.Linq.Expressions.Expression.New(typeof(global::System.Collections.Generic.List).GetConstructor(new global::System.Type[] { })); // new List { 1, 2, 3 } var expr_2 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 - var expr_3 = global::System.Linq.Expressions.Expression.ElementInit(_m0, expr_2); + var expr_3 = global::System.Linq.Expressions.Expression.ElementInit(typeof(global::System.Collections.Generic.List).GetMethod("Add", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int) }, null), expr_2); var expr_4 = global::System.Linq.Expressions.Expression.Constant(2, typeof(int)); // 2 - var expr_5 = global::System.Linq.Expressions.Expression.ElementInit(_m0, expr_4); + var expr_5 = global::System.Linq.Expressions.Expression.ElementInit(typeof(global::System.Collections.Generic.List).GetMethod("Add", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int) }, null), expr_4); var expr_6 = global::System.Linq.Expressions.Expression.Constant(3, typeof(int)); // 3 - var expr_7 = global::System.Linq.Expressions.Expression.ElementInit(_m0, expr_6); + var expr_7 = global::System.Linq.Expressions.Expression.ElementInit(typeof(global::System.Collections.Generic.List).GetMethod("Add", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int) }, null), expr_6); var expr_0 = global::System.Linq.Expressions.Expression.ListInit(expr_1, expr_3, expr_5, expr_7); return global::System.Linq.Expressions.Expression.Lambda>>(expr_0, p__this); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_BodyAssignments.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_BodyAssignments.verified.txt index bd7c1ad..50a91c4 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_BodyAssignments.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_BodyAssignments.verified.txt @@ -5,26 +5,21 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_PointDto__ctor_P0_int_P1_int + static partial class Foo_PointDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.PointDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.PointDto).GetProperty("X"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.PointDto).GetProperty("Y"); - // [Expressive] // public PointDto(int x, int y) // { // X = x; // Y = y; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_int_P1_int_Expression() { var p_x = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "x"); var p_y = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "y"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); - var expr_1 = global::System.Linq.Expressions.Expression.Bind(_p0, p_x); - var expr_2 = global::System.Linq.Expressions.Expression.Bind(_p1, p_y); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.PointDto).GetConstructor(new global::System.Type[] { })); + var expr_1 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PointDto).GetProperty("X"), p_x); + var expr_2 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PointDto).GetProperty("Y"), p_y); var expr_3 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_1, expr_2); return global::System.Linq.Expressions.Expression.Lambda>(expr_3, p_x, p_y); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_Overloads.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_Overloads.verified.txt index 5c24bc2..a8cdaea 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_Overloads.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_Overloads.verified.txt @@ -6,26 +6,21 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_PersonDto__ctor_P0_string_P1_string + static partial class Foo_PersonDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.PersonDto).GetProperty("FirstName"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.PersonDto).GetProperty("LastName"); - // [Expressive] // public PersonDto(string firstName, string lastName) // { // FirstName = firstName; // LastName = lastName; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_string_P1_string_Expression() { var p_firstName = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "firstName"); var p_lastName = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "lastName"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); - var expr_1 = global::System.Linq.Expressions.Expression.Bind(_p0, p_firstName); - var expr_2 = global::System.Linq.Expressions.Expression.Bind(_p1, p_lastName); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { })); + var expr_1 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PersonDto).GetProperty("FirstName"), p_firstName); + var expr_2 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PersonDto).GetProperty("LastName"), p_lastName); var expr_3 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_1, expr_2); return global::System.Linq.Expressions.Expression.Lambda>(expr_3, p_firstName, p_lastName); } @@ -40,27 +35,21 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_PersonDto__ctor_P0_string + static partial class Foo_PersonDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.FieldInfo _f0 = typeof(string).GetField("Empty", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.PersonDto).GetProperty("FirstName"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.PersonDto).GetProperty("LastName"); - // [Expressive] // public PersonDto(string fullName) // { // FirstName = fullName; // LastName = string.Empty; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_string_Expression() { var p_fullName = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "fullName"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); - var expr_1 = global::System.Linq.Expressions.Expression.Field(null, _f0); // string.Empty - var expr_2 = global::System.Linq.Expressions.Expression.Bind(_p0, p_fullName); - var expr_3 = global::System.Linq.Expressions.Expression.Bind(_p1, expr_1); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { })); + var expr_1 = global::System.Linq.Expressions.Expression.Field(null, typeof(string).GetField("Empty", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static)); // string.Empty + var expr_2 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PersonDto).GetProperty("FirstName"), p_fullName); + var expr_3 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PersonDto).GetProperty("LastName"), expr_1); var expr_4 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_2, expr_3); return global::System.Linq.Expressions.Expression.Lambda>(expr_4, p_fullName); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ReferencingBasePropertyInDerivedBody.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ReferencingBasePropertyInDerivedBody.verified.txt index 84f90a4..97c99dc 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ReferencingBasePropertyInDerivedBody.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ReferencingBasePropertyInDerivedBody.verified.txt @@ -5,30 +5,24 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Child__ctor_P0_string + static partial class Foo_Child { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.Child).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Base).GetProperty("Code"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.Child).GetProperty("Label"); - // [Expressive] // public Child(string code) : base(code) // { // Label = "[" + Code + "]"; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_string_Expression() { var p_code = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "code"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.Child).GetConstructor(new global::System.Type[] { })); var expr_3 = global::System.Linq.Expressions.Expression.Constant("[", typeof(string)); // "[" var p___this = global::System.Linq.Expressions.Expression.Parameter(typeof(object), "@this"); // Code - var expr_4 = global::System.Linq.Expressions.Expression.Property(p___this, _p0); - var expr_2 = global::System.Linq.Expressions.Expression.Call(_m0, expr_3, expr_4); + var expr_4 = global::System.Linq.Expressions.Expression.Property(p___this, typeof(global::Foo.Base).GetProperty("Code")); + var expr_2 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_3, expr_4); var expr_5 = global::System.Linq.Expressions.Expression.Constant("]", typeof(string)); // "]" - var expr_1 = global::System.Linq.Expressions.Expression.Call(_m0, expr_2, expr_5); - var expr_6 = global::System.Linq.Expressions.Expression.Bind(_p1, expr_1); + var expr_1 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_2, expr_5); + var expr_6 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.Child).GetProperty("Label"), expr_1); var expr_7 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_6); return global::System.Linq.Expressions.Expression.Lambda>(expr_7, p_code); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ReferencingPreviouslyAssignedInBaseCtor.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ReferencingPreviouslyAssignedInBaseCtor.verified.txt index 70d97fa..926f2e0 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ReferencingPreviouslyAssignedInBaseCtor.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ReferencingPreviouslyAssignedInBaseCtor.verified.txt @@ -5,29 +5,23 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Child__ctor_P0_int_P1_int + static partial class Foo_Child { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.Child).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Base).GetProperty("X"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.Base).GetProperty("Y"); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::Foo.Child).GetProperty("Sum"); - // [Expressive] // public Child(int a, int b) : base(a, b) // { // Sum = X + Y; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_int_P1_int_Expression() { var p_a = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "a"); var p_b = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "b"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.Child).GetConstructor(new global::System.Type[] { })); var p___this = global::System.Linq.Expressions.Expression.Parameter(typeof(object), "@this"); // X - var expr_2 = global::System.Linq.Expressions.Expression.Property(p___this, _p0); - var expr_3 = global::System.Linq.Expressions.Expression.Property(p___this, _p1); // Y + var expr_2 = global::System.Linq.Expressions.Expression.Property(p___this, typeof(global::Foo.Base).GetProperty("X")); + var expr_3 = global::System.Linq.Expressions.Expression.Property(p___this, typeof(global::Foo.Base).GetProperty("Y")); // Y var expr_1 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_2, expr_3); - var expr_4 = global::System.Linq.Expressions.Expression.Bind(_p2, expr_1); + var expr_4 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.Child).GetProperty("Sum"), expr_1); var expr_5 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_4); return global::System.Linq.Expressions.Expression.Lambda>(expr_5, p_a, p_b); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ReferencingPreviouslyAssignedProperty.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ReferencingPreviouslyAssignedProperty.verified.txt index 4afda40..0ffaaac 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ReferencingPreviouslyAssignedProperty.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ReferencingPreviouslyAssignedProperty.verified.txt @@ -5,15 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_PersonDto__ctor_P0_string_P1_string + static partial class Foo_PersonDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.PersonDto).GetProperty("FirstName"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.PersonDto).GetProperty("LastName"); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::Foo.PersonDto).GetProperty("FullName"); - // [Expressive] // public PersonDto(string firstName, string lastName) // { @@ -21,20 +14,20 @@ namespace ExpressiveSharp.Generated // LastName = lastName; // FullName = FirstName + " " + LastName; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_string_P1_string_Expression() { var p_firstName = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "firstName"); var p_lastName = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "lastName"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { })); var p___this = global::System.Linq.Expressions.Expression.Parameter(typeof(object), "@this"); // FirstName - var expr_3 = global::System.Linq.Expressions.Expression.Property(p___this, _p0); + var expr_3 = global::System.Linq.Expressions.Expression.Property(p___this, typeof(global::Foo.PersonDto).GetProperty("FirstName")); var expr_4 = global::System.Linq.Expressions.Expression.Constant(" ", typeof(string)); // " " - var expr_2 = global::System.Linq.Expressions.Expression.Call(_m0, expr_3, expr_4); - var expr_5 = global::System.Linq.Expressions.Expression.Property(p___this, _p1); // LastName - var expr_1 = global::System.Linq.Expressions.Expression.Call(_m0, expr_2, expr_5); - var expr_6 = global::System.Linq.Expressions.Expression.Bind(_p0, p_firstName); - var expr_7 = global::System.Linq.Expressions.Expression.Bind(_p1, p_lastName); - var expr_8 = global::System.Linq.Expressions.Expression.Bind(_p2, expr_1); + var expr_2 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_3, expr_4); + var expr_5 = global::System.Linq.Expressions.Expression.Property(p___this, typeof(global::Foo.PersonDto).GetProperty("LastName")); // LastName + var expr_1 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_2, expr_5); + var expr_6 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PersonDto).GetProperty("FirstName"), p_firstName); + var expr_7 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PersonDto).GetProperty("LastName"), p_lastName); + var expr_8 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PersonDto).GetProperty("FullName"), expr_1); var expr_9 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_6, expr_7, expr_8); return global::System.Linq.Expressions.Expression.Lambda>(expr_9, p_firstName, p_lastName); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ReferencingStaticConstMember.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ReferencingStaticConstMember.verified.txt index c05d228..16bc38d 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ReferencingStaticConstMember.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ReferencingStaticConstMember.verified.txt @@ -5,28 +5,22 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_PersonDto__ctor_P0_string_P1_string + static partial class Foo_PersonDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.FieldInfo _f0 = typeof(global::Foo.PersonDto).GetField("Separator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.PersonDto).GetProperty("FullName"); - // [Expressive] // public PersonDto(string first, string last) // { // FullName = first + Separator + last; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_string_P1_string_Expression() { var p_first = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "first"); var p_last = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "last"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); - var expr_3 = global::System.Linq.Expressions.Expression.Field(null, _f0); // Separator - var expr_2 = global::System.Linq.Expressions.Expression.Call(_m0, p_first, expr_3); - var expr_1 = global::System.Linq.Expressions.Expression.Call(_m0, expr_2, p_last); - var expr_4 = global::System.Linq.Expressions.Expression.Bind(_p0, expr_1); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { })); + var expr_3 = global::System.Linq.Expressions.Expression.Field(null, typeof(global::Foo.PersonDto).GetField("Separator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static)); // Separator + var expr_2 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), p_first, expr_3); + var expr_1 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_2, p_last); + var expr_4 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PersonDto).GetProperty("FullName"), expr_1); var expr_5 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_4); return global::System.Linq.Expressions.Expression.Lambda>(expr_5, p_first, p_last); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ThisInitializer_ChainedThisAndBase.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ThisInitializer_ChainedThisAndBase.verified.txt index eec40be..2a0cc98 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ThisInitializer_ChainedThisAndBase.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ThisInitializer_ChainedThisAndBase.verified.txt @@ -5,28 +5,23 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Child__ctor_P0_int_P1_string_P2_string + static partial class Foo_Child { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.Child).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Child).GetProperty("Name"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null); - // [Expressive] // public Child(int id, string name, string suffix) : this(id, name) // { // Name = Name + suffix; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_int_P1_string_P2_string_Expression() { var p_id = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "id"); var p_name = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "name"); var p_suffix = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "suffix"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.Child).GetConstructor(new global::System.Type[] { })); var p___this = global::System.Linq.Expressions.Expression.Parameter(typeof(object), "@this"); // Name - var expr_2 = global::System.Linq.Expressions.Expression.Property(p___this, _p0); - var expr_1 = global::System.Linq.Expressions.Expression.Call(_m0, expr_2, p_suffix); - var expr_3 = global::System.Linq.Expressions.Expression.Bind(_p0, expr_1); + var expr_2 = global::System.Linq.Expressions.Expression.Property(p___this, typeof(global::Foo.Child).GetProperty("Name")); + var expr_1 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_2, p_suffix); + var expr_3 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.Child).GetProperty("Name"), expr_1); var expr_4 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_3); return global::System.Linq.Expressions.Expression.Lambda>(expr_4, p_id, p_name, p_suffix); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ThisInitializer_RefPreviouslyAssignedProperty.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ThisInitializer_RefPreviouslyAssignedProperty.verified.txt index 62a9dde..bcab035 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ThisInitializer_RefPreviouslyAssignedProperty.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ThisInitializer_RefPreviouslyAssignedProperty.verified.txt @@ -5,19 +5,16 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_PersonDto__ctor_P0_string + static partial class Foo_PersonDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { }); - // [Expressive] // public PersonDto(string firstName) : this(firstName, "Doe") // { // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_string_Expression() { var p_firstName = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "firstName"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { })); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p_firstName); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ThisInitializer_SimpleOverload.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ThisInitializer_SimpleOverload.verified.txt index e19090c..9923ca7 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ThisInitializer_SimpleOverload.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ThisInitializer_SimpleOverload.verified.txt @@ -5,19 +5,16 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_PersonDto__ctor_P0_string + static partial class Foo_PersonDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { }); - // [Expressive] // public PersonDto(string fullName) : this(fullName.ToUpper(), fullName.ToLower()) // { // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_string_Expression() { var p_fullName = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "fullName"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { })); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p_fullName); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ThisInitializer_WithBodyAfter.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ThisInitializer_WithBodyAfter.verified.txt index 8ce8d5b..a30dfb7 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ThisInitializer_WithBodyAfter.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ThisInitializer_WithBodyAfter.verified.txt @@ -5,41 +5,33 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_PersonDto__ctor_P0_string_P1_string_P2_bool + static partial class Foo_PersonDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("ToUpper", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.PersonDto).GetProperty("FirstName"); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.PersonDto).GetProperty("LastName"); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::Foo.PersonDto).GetProperty("FullName"); - // [Expressive] // public PersonDto(string fn, string ln, bool upper) : this(fn, ln) // { // FullName = upper ? (FirstName + " " + LastName).ToUpper() : FirstName + " " + LastName; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_string_P1_string_P2_bool_Expression() { var p_fn = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "fn"); var p_ln = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "ln"); var p_upper = global::System.Linq.Expressions.Expression.Parameter(typeof(bool), "upper"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { })); var p___this = global::System.Linq.Expressions.Expression.Parameter(typeof(object), "@this"); // FirstName - var expr_5 = global::System.Linq.Expressions.Expression.Property(p___this, _p0); + var expr_5 = global::System.Linq.Expressions.Expression.Property(p___this, typeof(global::Foo.PersonDto).GetProperty("FirstName")); var expr_6 = global::System.Linq.Expressions.Expression.Constant(" ", typeof(string)); // " " - var expr_4 = global::System.Linq.Expressions.Expression.Call(_m1, expr_5, expr_6); - var expr_7 = global::System.Linq.Expressions.Expression.Property(p___this, _p1); // LastName - var expr_3 = global::System.Linq.Expressions.Expression.Call(_m1, expr_4, expr_7); - var expr_2 = global::System.Linq.Expressions.Expression.Call(expr_3, _m0, global::System.Array.Empty()); - var expr_10 = global::System.Linq.Expressions.Expression.Property(p___this, _p0); // FirstName + var expr_4 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_5, expr_6); + var expr_7 = global::System.Linq.Expressions.Expression.Property(p___this, typeof(global::Foo.PersonDto).GetProperty("LastName")); // LastName + var expr_3 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_4, expr_7); + var expr_2 = global::System.Linq.Expressions.Expression.Call(expr_3, typeof(string).GetMethod("ToUpper", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null), global::System.Array.Empty()); + var expr_10 = global::System.Linq.Expressions.Expression.Property(p___this, typeof(global::Foo.PersonDto).GetProperty("FirstName")); // FirstName var expr_11 = global::System.Linq.Expressions.Expression.Constant(" ", typeof(string)); // " " - var expr_9 = global::System.Linq.Expressions.Expression.Call(_m1, expr_10, expr_11); - var expr_12 = global::System.Linq.Expressions.Expression.Property(p___this, _p1); // LastName - var expr_8 = global::System.Linq.Expressions.Expression.Call(_m1, expr_9, expr_12); + var expr_9 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_10, expr_11); + var expr_12 = global::System.Linq.Expressions.Expression.Property(p___this, typeof(global::Foo.PersonDto).GetProperty("LastName")); // LastName + var expr_8 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_9, expr_12); var expr_1 = global::System.Linq.Expressions.Expression.Condition(p_upper, expr_2, expr_8, typeof(string)); - var expr_13 = global::System.Linq.Expressions.Expression.Bind(_p2, expr_1); + var expr_13 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PersonDto).GetProperty("FullName"), expr_1); var expr_14 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_13); return global::System.Linq.Expressions.Expression.Lambda>(expr_14, p_fn, p_ln, p_upper); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ThisInitializer_WithIfElseInDelegated.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ThisInitializer_WithIfElseInDelegated.verified.txt index b7a3f7a..230cb2a 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ThisInitializer_WithIfElseInDelegated.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_ThisInitializer_WithIfElseInDelegated.verified.txt @@ -5,27 +5,22 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_PersonDto__ctor_P0_int_P1_string + static partial class Foo_PersonDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.PersonDto).GetProperty("Label"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null); - // [Expressive] // public PersonDto(int score, string prefix) : this(score) // { // Label = prefix + Label; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_int_P1_string_Expression() { var p_score = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "score"); var p_prefix = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "prefix"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { })); var p___this = global::System.Linq.Expressions.Expression.Parameter(typeof(object), "@this"); // Label - var expr_2 = global::System.Linq.Expressions.Expression.Property(p___this, _p0); - var expr_1 = global::System.Linq.Expressions.Expression.Call(_m0, p_prefix, expr_2); - var expr_3 = global::System.Linq.Expressions.Expression.Bind(_p0, expr_1); + var expr_2 = global::System.Linq.Expressions.Expression.Property(p___this, typeof(global::Foo.PersonDto).GetProperty("Label")); + var expr_1 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), p_prefix, expr_2); + var expr_3 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PersonDto).GetProperty("Label"), expr_1); var expr_4 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_3); return global::System.Linq.Expressions.Expression.Lambda>(expr_4, p_score, p_prefix); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithBaseInitializer.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithBaseInitializer.verified.txt index c5e7d63..2b0571f 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithBaseInitializer.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithBaseInitializer.verified.txt @@ -5,23 +5,19 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Child__ctor_P0_int_P1_string + static partial class Foo_Child { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.Child).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Child).GetProperty("Name"); - // [Expressive] // public Child(int id, string name) : base(id) // { // Name = name; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_int_P1_string_Expression() { var p_id = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "id"); var p_name = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "name"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); - var expr_1 = global::System.Linq.Expressions.Expression.Bind(_p0, p_name); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.Child).GetConstructor(new global::System.Type[] { })); + var expr_1 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.Child).GetProperty("Name"), p_name); var expr_2 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_1); return global::System.Linq.Expressions.Expression.Lambda>(expr_2, p_id, p_name); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithBaseInitializerAndIfElse.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithBaseInitializerAndIfElse.verified.txt index c5e7d63..2b0571f 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithBaseInitializerAndIfElse.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithBaseInitializerAndIfElse.verified.txt @@ -5,23 +5,19 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Child__ctor_P0_int_P1_string + static partial class Foo_Child { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.Child).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Child).GetProperty("Name"); - // [Expressive] // public Child(int id, string name) : base(id) // { // Name = name; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_int_P1_string_Expression() { var p_id = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "id"); var p_name = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "name"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); - var expr_1 = global::System.Linq.Expressions.Expression.Bind(_p0, p_name); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.Child).GetConstructor(new global::System.Type[] { })); + var expr_1 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.Child).GetProperty("Name"), p_name); var expr_2 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_1); return global::System.Linq.Expressions.Expression.Lambda>(expr_2, p_id, p_name); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithBaseInitializerExpression.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithBaseInitializerExpression.verified.txt index 7039c04..ea38b19 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithBaseInitializerExpression.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithBaseInitializerExpression.verified.txt @@ -5,23 +5,19 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Child__ctor_P0_string_P1_string + static partial class Foo_Child { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.Child).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Child).GetProperty("Name"); - // [Expressive] // public Child(string name, string rawCode) : base(rawCode.ToUpper()) // { // Name = name; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_string_P1_string_Expression() { var p_name = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "name"); var p_rawCode = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "rawCode"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); - var expr_1 = global::System.Linq.Expressions.Expression.Bind(_p0, p_name); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.Child).GetConstructor(new global::System.Type[] { })); + var expr_1 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.Child).GetProperty("Name"), p_name); var expr_2 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_1); return global::System.Linq.Expressions.Expression.Lambda>(expr_2, p_name, p_rawCode); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithBaseInitializer_AndEarlyReturn.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithBaseInitializer_AndEarlyReturn.verified.txt index 0ef306a..e5a0fa2 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithBaseInitializer_AndEarlyReturn.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithBaseInitializer_AndEarlyReturn.verified.txt @@ -5,13 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Car__ctor_P0_string_P1_int + static partial class Foo_Car { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.Car).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Car).GetProperty("Model"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.Car).GetProperty("Year"); - // [Expressive] // public Car(string model, int year) : base("Car") // { @@ -24,18 +19,18 @@ namespace ExpressiveSharp.Generated // // Year = year; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_string_P1_int_Expression() { var p_model = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "model"); var p_year = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "year"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.Car).GetConstructor(new global::System.Type[] { })); var expr_1 = global::System.Linq.Expressions.Expression.Constant(2000, typeof(int)); // 2000 var expr_3 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_2 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.LessThanOrEqual, p_year, expr_3); var expr_4 = global::System.Linq.Expressions.Expression.Default(typeof(int)); var expr_5 = global::System.Linq.Expressions.Expression.Condition(expr_2, expr_1, expr_4, typeof(int)); - var expr_6 = global::System.Linq.Expressions.Expression.Bind(_p0, p_model); - var expr_7 = global::System.Linq.Expressions.Expression.Bind(_p1, p_year); + var expr_6 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.Car).GetProperty("Model"), p_model); + var expr_7 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.Car).GetProperty("Year"), p_year); var expr_8 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_6, expr_7); return global::System.Linq.Expressions.Expression.Lambda>(expr_8, p_model, p_year); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithBaseInitializer_AndIfElse_InDerivedBody.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithBaseInitializer_AndIfElse_InDerivedBody.verified.txt index 8031df3..a5d6f31 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithBaseInitializer_AndIfElse_InDerivedBody.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithBaseInitializer_AndIfElse_InDerivedBody.verified.txt @@ -5,15 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Pet__ctor_P0_string_P1_string_P2_bool + static partial class Foo_Pet { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.Pet).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(string).GetProperty("Length"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("Substring", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int), typeof(int) }, null); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.Pet).GetProperty("Name"); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::Foo.Pet).GetProperty("Nickname"); - // [Expressive] // public Pet(string species, string name, bool useShortName) : base(species) // { @@ -27,22 +20,22 @@ namespace ExpressiveSharp.Generated // Nickname = name; // } // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_string_P1_string_P2_bool_Expression() { var p_species = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "species"); var p_name = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "name"); var p_useShortName = global::System.Linq.Expressions.Expression.Parameter(typeof(bool), "useShortName"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); - var expr_3 = global::System.Linq.Expressions.Expression.Property(p_name, _p0); // name.Length + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.Pet).GetConstructor(new global::System.Type[] { })); + var expr_3 = global::System.Linq.Expressions.Expression.Property(p_name, typeof(string).GetProperty("Length")); // name.Length var expr_4 = global::System.Linq.Expressions.Expression.Constant(3, typeof(int)); // 3 var expr_2 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThan, expr_3, expr_4); var expr_6 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_7 = global::System.Linq.Expressions.Expression.Constant(3, typeof(int)); // 3 - var expr_5 = global::System.Linq.Expressions.Expression.Call(p_name, _m0, new global::System.Linq.Expressions.Expression[] { expr_6, expr_7 }); + var expr_5 = global::System.Linq.Expressions.Expression.Call(p_name, typeof(string).GetMethod("Substring", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int), typeof(int) }, null), new global::System.Linq.Expressions.Expression[] { expr_6, expr_7 }); var expr_1 = global::System.Linq.Expressions.Expression.Condition(expr_2, expr_5, p_name, typeof(string)); var expr_8 = global::System.Linq.Expressions.Expression.Condition(p_useShortName, expr_1, p_name, typeof(string)); - var expr_9 = global::System.Linq.Expressions.Expression.Bind(_p1, p_name); - var expr_10 = global::System.Linq.Expressions.Expression.Bind(_p2, expr_8); + var expr_9 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.Pet).GetProperty("Name"), p_name); + var expr_10 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.Pet).GetProperty("Nickname"), expr_8); var expr_11 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_9, expr_10); return global::System.Linq.Expressions.Expression.Lambda>(expr_11, p_species, p_name, p_useShortName); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithClassArgument.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithClassArgument.verified.txt index 09853be..9b0c62b 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithClassArgument.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithClassArgument.verified.txt @@ -5,29 +5,22 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_PersonDto__ctor_P0_Foo_SourceEntity + static partial class Foo_PersonDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.SourceEntity).GetProperty("Id"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.SourceEntity).GetProperty("Name"); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::Foo.PersonDto).GetProperty("Id"); - private static readonly global::System.Reflection.PropertyInfo _p3 = typeof(global::Foo.PersonDto).GetProperty("Name"); - // [Expressive] // public PersonDto(SourceEntity source) // { // Id = source.Id; // Name = source.Name; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_Foo_SourceEntity_Expression() { var p_source = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.SourceEntity), "source"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p_source, _p0); // source.Id - var expr_2 = global::System.Linq.Expressions.Expression.Property(p_source, _p1); // source.Name - var expr_3 = global::System.Linq.Expressions.Expression.Bind(_p2, expr_1); - var expr_4 = global::System.Linq.Expressions.Expression.Bind(_p3, expr_2); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { })); + var expr_1 = global::System.Linq.Expressions.Expression.Property(p_source, typeof(global::Foo.SourceEntity).GetProperty("Id")); // source.Id + var expr_2 = global::System.Linq.Expressions.Expression.Property(p_source, typeof(global::Foo.SourceEntity).GetProperty("Name")); // source.Name + var expr_3 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PersonDto).GetProperty("Id"), expr_1); + var expr_4 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PersonDto).GetProperty("Name"), expr_2); var expr_5 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_3, expr_4); return global::System.Linq.Expressions.Expression.Lambda>(expr_5, p_source); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithDeepNestedIf.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithDeepNestedIf.verified.txt index 1f6285f..d89b695 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithDeepNestedIf.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithDeepNestedIf.verified.txt @@ -5,12 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_AccessDto__ctor_P0_bool_P1_bool_P2_bool + static partial class Foo_AccessDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.AccessDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.AccessDto).GetProperty("Access"); - // [Expressive] // public AccessDto(bool isLoggedIn, bool isVerified, bool isAdmin) // { @@ -37,12 +33,12 @@ namespace ExpressiveSharp.Generated // Access = "Guest"; // } // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_bool_P1_bool_P2_bool_Expression() { var p_isLoggedIn = global::System.Linq.Expressions.Expression.Parameter(typeof(bool), "isLoggedIn"); var p_isVerified = global::System.Linq.Expressions.Expression.Parameter(typeof(bool), "isVerified"); var p_isAdmin = global::System.Linq.Expressions.Expression.Parameter(typeof(bool), "isAdmin"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.AccessDto).GetConstructor(new global::System.Type[] { })); var expr_1 = global::System.Linq.Expressions.Expression.Constant("Full", typeof(string)); // "Full" var expr_2 = global::System.Linq.Expressions.Expression.Constant("Verified", typeof(string)); // "Verified" var expr_3 = global::System.Linq.Expressions.Expression.Condition(p_isAdmin, expr_1, expr_2, typeof(string)); @@ -50,7 +46,7 @@ namespace ExpressiveSharp.Generated var expr_5 = global::System.Linq.Expressions.Expression.Condition(p_isVerified, expr_3, expr_4, typeof(string)); var expr_6 = global::System.Linq.Expressions.Expression.Constant("Guest", typeof(string)); // "Guest" var expr_7 = global::System.Linq.Expressions.Expression.Condition(p_isLoggedIn, expr_5, expr_6, typeof(string)); - var expr_8 = global::System.Linq.Expressions.Expression.Bind(_p0, expr_7); + var expr_8 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.AccessDto).GetProperty("Access"), expr_7); var expr_9 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_8); return global::System.Linq.Expressions.Expression.Lambda>(expr_9, p_isLoggedIn, p_isVerified, p_isAdmin); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithEarlyReturn_GuardClause.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithEarlyReturn_GuardClause.verified.txt index 5154772..ed472c2 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithEarlyReturn_GuardClause.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithEarlyReturn_GuardClause.verified.txt @@ -5,14 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_ItemDto__ctor_P0_string_P1_string + static partial class Foo_ItemDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.ItemDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("IsNullOrEmpty", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string) }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.ItemDto).GetProperty("Name"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.ItemDto).GetProperty("Category"); - // [Expressive] // public ItemDto(string name, string category) // { @@ -25,17 +19,17 @@ namespace ExpressiveSharp.Generated // // Category = category; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_string_P1_string_Expression() { var p_name = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "name"); var p_category = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "category"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.ItemDto).GetConstructor(new global::System.Type[] { })); var expr_1 = global::System.Linq.Expressions.Expression.Constant("Unknown", typeof(string)); // "Unknown" - var expr_2 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { p_category }); // string.IsNullOrEmpty(category) + var expr_2 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("IsNullOrEmpty", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string) }, null), new global::System.Linq.Expressions.Expression[] { p_category }); // string.IsNullOrEmpty(category) var expr_3 = global::System.Linq.Expressions.Expression.Default(typeof(string)); var expr_4 = global::System.Linq.Expressions.Expression.Condition(expr_2, expr_1, expr_3, typeof(string)); - var expr_5 = global::System.Linq.Expressions.Expression.Bind(_p0, p_name); - var expr_6 = global::System.Linq.Expressions.Expression.Bind(_p1, p_category); + var expr_5 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.ItemDto).GetProperty("Name"), p_name); + var expr_6 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.ItemDto).GetProperty("Category"), p_category); var expr_7 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_5, expr_6); return global::System.Linq.Expressions.Expression.Lambda>(expr_7, p_name, p_category); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithElseIfChain.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithElseIfChain.verified.txt index 2719d5e..ed7c0b8 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithElseIfChain.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithElseIfChain.verified.txt @@ -5,12 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_GradeDto__ctor_P0_int + static partial class Foo_GradeDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.GradeDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.GradeDto).GetProperty("Grade"); - // [Expressive] // public GradeDto(int score) // { @@ -31,10 +27,10 @@ namespace ExpressiveSharp.Generated // Grade = "F"; // } // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_int_Expression() { var p_score = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "score"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.GradeDto).GetConstructor(new global::System.Type[] { })); var expr_1 = global::System.Linq.Expressions.Expression.Constant("A", typeof(string)); // "A" var expr_2 = global::System.Linq.Expressions.Expression.Constant("B", typeof(string)); // "B" var expr_3 = global::System.Linq.Expressions.Expression.Constant("C", typeof(string)); // "C" @@ -48,7 +44,7 @@ namespace ExpressiveSharp.Generated var expr_12 = global::System.Linq.Expressions.Expression.Constant(90, typeof(int)); // 90 var expr_11 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThanOrEqual, p_score, expr_12); var expr_13 = global::System.Linq.Expressions.Expression.Condition(expr_11, expr_1, expr_10, typeof(string)); - var expr_14 = global::System.Linq.Expressions.Expression.Bind(_p0, expr_13); + var expr_14 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.GradeDto).GetProperty("Grade"), expr_13); var expr_15 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_14); return global::System.Linq.Expressions.Expression.Lambda>(expr_15, p_score); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithExplicitParameterlessConstructor_Succeeds.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithExplicitParameterlessConstructor_Succeeds.verified.txt index 7fdbf70..f3e1b36 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithExplicitParameterlessConstructor_Succeeds.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithExplicitParameterlessConstructor_Succeeds.verified.txt @@ -5,22 +5,18 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_PersonDto__ctor_P0_string + static partial class Foo_PersonDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.PersonDto).GetProperty("Name"); - // [Expressive] // public PersonDto(string name) // { // Name = name; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_string_Expression() { var p_name = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "name"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); - var expr_1 = global::System.Linq.Expressions.Expression.Bind(_p0, p_name); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { })); + var expr_1 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PersonDto).GetProperty("Name"), p_name); var expr_2 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_1); return global::System.Linq.Expressions.Expression.Lambda>(expr_2, p_name); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithFullObject.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithFullObject.verified.txt index b6149fb..908f85c 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithFullObject.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithFullObject.verified.txt @@ -5,22 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_CustomerDto__ctor_P0_Foo_Customer + static partial class Foo_CustomerDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.CustomerDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Customer).GetProperty("Id"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.Customer).GetProperty("FirstName"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::Foo.Customer).GetProperty("LastName"); - private static readonly global::System.Reflection.PropertyInfo _p3 = typeof(global::Foo.Customer).GetProperty("IsActive"); - private static readonly global::System.Reflection.MethodInfo _m1 = global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "Count" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 1)).MakeGenericMethod(typeof(global::Foo.Order)); - private static readonly global::System.Reflection.PropertyInfo _p4 = typeof(global::Foo.Customer).GetProperty("Orders"); - private static readonly global::System.Reflection.PropertyInfo _p5 = typeof(global::Foo.CustomerDto).GetProperty("Id"); - private static readonly global::System.Reflection.PropertyInfo _p6 = typeof(global::Foo.CustomerDto).GetProperty("FullName"); - private static readonly global::System.Reflection.PropertyInfo _p7 = typeof(global::Foo.CustomerDto).GetProperty("IsActive"); - private static readonly global::System.Reflection.PropertyInfo _p8 = typeof(global::Foo.CustomerDto).GetProperty("OrderCount"); - // [Expressive] // public CustomerDto(Customer customer) // { @@ -29,24 +15,24 @@ namespace ExpressiveSharp.Generated // IsActive = customer.IsActive; // OrderCount = customer.Orders.Count(); // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_Foo_Customer_Expression() { var p_customer = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Customer), "customer"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p_customer, _p0); // customer.Id - var expr_4 = global::System.Linq.Expressions.Expression.Property(p_customer, _p1); // customer.FirstName + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.CustomerDto).GetConstructor(new global::System.Type[] { })); + var expr_1 = global::System.Linq.Expressions.Expression.Property(p_customer, typeof(global::Foo.Customer).GetProperty("Id")); // customer.Id + var expr_4 = global::System.Linq.Expressions.Expression.Property(p_customer, typeof(global::Foo.Customer).GetProperty("FirstName")); // customer.FirstName var expr_5 = global::System.Linq.Expressions.Expression.Constant(" ", typeof(string)); // " " - var expr_3 = global::System.Linq.Expressions.Expression.Call(_m0, expr_4, expr_5); - var expr_6 = global::System.Linq.Expressions.Expression.Property(p_customer, _p2); // customer.LastName - var expr_2 = global::System.Linq.Expressions.Expression.Call(_m0, expr_3, expr_6); - var expr_7 = global::System.Linq.Expressions.Expression.Property(p_customer, _p3); // customer.IsActive - var expr_10 = global::System.Linq.Expressions.Expression.Property(p_customer, _p4); // customer.Orders + var expr_3 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_4, expr_5); + var expr_6 = global::System.Linq.Expressions.Expression.Property(p_customer, typeof(global::Foo.Customer).GetProperty("LastName")); // customer.LastName + var expr_2 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_3, expr_6); + var expr_7 = global::System.Linq.Expressions.Expression.Property(p_customer, typeof(global::Foo.Customer).GetProperty("IsActive")); // customer.IsActive + var expr_10 = global::System.Linq.Expressions.Expression.Property(p_customer, typeof(global::Foo.Customer).GetProperty("Orders")); // customer.Orders var expr_9 = global::System.Linq.Expressions.Expression.Convert(expr_10, typeof(global::System.Collections.Generic.IEnumerable)); - var expr_8 = global::System.Linq.Expressions.Expression.Call(_m1, new global::System.Linq.Expressions.Expression[] { expr_9 }); - var expr_11 = global::System.Linq.Expressions.Expression.Bind(_p5, expr_1); - var expr_12 = global::System.Linq.Expressions.Expression.Bind(_p6, expr_2); - var expr_13 = global::System.Linq.Expressions.Expression.Bind(_p7, expr_7); - var expr_14 = global::System.Linq.Expressions.Expression.Bind(_p8, expr_8); + var expr_8 = global::System.Linq.Expressions.Expression.Call(global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "Count" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 1)).MakeGenericMethod(typeof(global::Foo.Order)), new global::System.Linq.Expressions.Expression[] { expr_9 }); + var expr_11 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.CustomerDto).GetProperty("Id"), expr_1); + var expr_12 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.CustomerDto).GetProperty("FullName"), expr_2); + var expr_13 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.CustomerDto).GetProperty("IsActive"), expr_7); + var expr_14 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.CustomerDto).GetProperty("OrderCount"), expr_8); var expr_15 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_11, expr_12, expr_13, expr_14); return global::System.Linq.Expressions.Expression.Lambda>(expr_15, p_customer); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithIfElseLogic.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithIfElseLogic.verified.txt index d5e4ca1..fc7be55 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithIfElseLogic.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithIfElseLogic.verified.txt @@ -5,13 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_PersonDto__ctor_P0_int + static partial class Foo_PersonDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.PersonDto).GetProperty("Score"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.PersonDto).GetProperty("Label"); - // [Expressive] // public PersonDto(int score) // { @@ -25,17 +20,17 @@ namespace ExpressiveSharp.Generated // Label = "B"; // } // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_int_Expression() { var p_score = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "score"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { })); var expr_1 = global::System.Linq.Expressions.Expression.Constant("A", typeof(string)); // "A" var expr_2 = global::System.Linq.Expressions.Expression.Constant("B", typeof(string)); // "B" var expr_4 = global::System.Linq.Expressions.Expression.Constant(90, typeof(int)); // 90 var expr_3 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThanOrEqual, p_score, expr_4); var expr_5 = global::System.Linq.Expressions.Expression.Condition(expr_3, expr_1, expr_2, typeof(string)); - var expr_6 = global::System.Linq.Expressions.Expression.Bind(_p0, p_score); - var expr_7 = global::System.Linq.Expressions.Expression.Bind(_p1, expr_5); + var expr_6 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PersonDto).GetProperty("Score"), p_score); + var expr_7 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PersonDto).GetProperty("Label"), expr_5); var expr_8 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_6, expr_7); return global::System.Linq.Expressions.Expression.Lambda>(expr_8, p_score); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithIfInsideLocalScope_AndElse.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithIfInsideLocalScope_AndElse.verified.txt index 501b120..16b57dd 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithIfInsideLocalScope_AndElse.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithIfInsideLocalScope_AndElse.verified.txt @@ -5,15 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_OrderDto__ctor_P0_int_P1_bool + static partial class Foo_OrderDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.OrderDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.FieldInfo _f0 = typeof(string).GetField("Empty", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.OrderDto).GetProperty("Status"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.OrderDto).GetProperty("Note"); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::Foo.OrderDto).GetProperty("NeedsReview"); - // [Expressive] // public OrderDto(int amount, bool flagged) // { @@ -30,11 +23,11 @@ namespace ExpressiveSharp.Generated // NeedsReview = false; // } // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_int_P1_bool_Expression() { var p_amount = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "amount"); var p_flagged = global::System.Linq.Expressions.Expression.Parameter(typeof(bool), "flagged"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.OrderDto).GetConstructor(new global::System.Type[] { })); var expr_1 = global::System.Linq.Expressions.Expression.Constant("Flagged", typeof(string)); // "Flagged" var expr_2 = global::System.Linq.Expressions.Expression.Constant("Requires manual review", typeof(string)); // "Requires manual review" var expr_3 = global::System.Linq.Expressions.Expression.Constant(true, typeof(bool)); // true @@ -43,14 +36,14 @@ namespace ExpressiveSharp.Generated var expr_7 = global::System.Linq.Expressions.Expression.Constant("Large", typeof(string)); // "Large" var expr_8 = global::System.Linq.Expressions.Expression.Constant("Normal", typeof(string)); // "Normal" var expr_4 = global::System.Linq.Expressions.Expression.Condition(expr_5, expr_7, expr_8, typeof(string)); - var expr_9 = global::System.Linq.Expressions.Expression.Field(null, _f0); // string.Empty + var expr_9 = global::System.Linq.Expressions.Expression.Field(null, typeof(string).GetField("Empty", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static)); // string.Empty var expr_10 = global::System.Linq.Expressions.Expression.Constant(false, typeof(bool)); // false var expr_11 = global::System.Linq.Expressions.Expression.Condition(p_flagged, expr_1, expr_4, typeof(string)); var expr_12 = global::System.Linq.Expressions.Expression.Condition(p_flagged, expr_2, expr_9, typeof(string)); var expr_13 = global::System.Linq.Expressions.Expression.Condition(p_flagged, expr_3, expr_10, typeof(bool)); - var expr_14 = global::System.Linq.Expressions.Expression.Bind(_p0, expr_11); - var expr_15 = global::System.Linq.Expressions.Expression.Bind(_p1, expr_12); - var expr_16 = global::System.Linq.Expressions.Expression.Bind(_p2, expr_13); + var expr_14 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.OrderDto).GetProperty("Status"), expr_11); + var expr_15 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.OrderDto).GetProperty("Note"), expr_12); + var expr_16 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.OrderDto).GetProperty("NeedsReview"), expr_13); var expr_17 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_14, expr_15, expr_16); return global::System.Linq.Expressions.Expression.Lambda>(expr_17, p_amount, p_flagged); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithIfNoElse.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithIfNoElse.verified.txt index 89979aa..e53348a 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithIfNoElse.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithIfNoElse.verified.txt @@ -5,12 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_PersonDto__ctor_P0_int + static partial class Foo_PersonDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.PersonDto).GetProperty("Label"); - // [Expressive] // public PersonDto(int score) // { @@ -20,16 +16,16 @@ namespace ExpressiveSharp.Generated // Label = "A"; // } // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_int_Expression() { var p_score = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "score"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { })); var expr_1 = global::System.Linq.Expressions.Expression.Constant("none", typeof(string)); // "none" var expr_2 = global::System.Linq.Expressions.Expression.Constant("A", typeof(string)); // "A" var expr_4 = global::System.Linq.Expressions.Expression.Constant(90, typeof(int)); // 90 var expr_3 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThanOrEqual, p_score, expr_4); var expr_5 = global::System.Linq.Expressions.Expression.Condition(expr_3, expr_2, expr_1, typeof(string)); - var expr_6 = global::System.Linq.Expressions.Expression.Bind(_p0, expr_5); + var expr_6 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PersonDto).GetProperty("Label"), expr_5); var expr_7 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_6); return global::System.Linq.Expressions.Expression.Lambda>(expr_7, p_score); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithLocalVariable.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithLocalVariable.verified.txt index d8962f3..9eda2f8 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithLocalVariable.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithLocalVariable.verified.txt @@ -5,30 +5,25 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_PersonDto__ctor_P0_string_P1_string + static partial class Foo_PersonDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.PersonDto).GetProperty("FullName"); - // [Expressive] // public PersonDto(string first, string last) // { // var full = first + " " + last; // FullName = full; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_string_P1_string_Expression() { var p_first = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "first"); var p_last = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "last"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { })); var expr_1 = global::System.Linq.Expressions.Expression.Variable(typeof(string), "full"); var expr_4 = global::System.Linq.Expressions.Expression.Constant(" ", typeof(string)); // " " - var expr_3 = global::System.Linq.Expressions.Expression.Call(_m0, p_first, expr_4); - var expr_2 = global::System.Linq.Expressions.Expression.Call(_m0, expr_3, p_last); + var expr_3 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), p_first, expr_4); + var expr_2 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_3, p_last); var expr_5 = global::System.Linq.Expressions.Expression.Assign(expr_1, expr_2); - var expr_6 = global::System.Linq.Expressions.Expression.Bind(_p0, expr_1); + var expr_6 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PersonDto).GetProperty("FullName"), expr_1); var expr_7 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_6); return global::System.Linq.Expressions.Expression.Lambda>(expr_7, p_first, p_last); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithLocalVariableUsedInCondition.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithLocalVariableUsedInCondition.verified.txt index 284d9be..112fc94 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithLocalVariableUsedInCondition.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithLocalVariableUsedInCondition.verified.txt @@ -5,14 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_RangeDto__ctor_P0_int_P1_int + static partial class Foo_RangeDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.RangeDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.RangeDto).GetProperty("Min"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.RangeDto).GetProperty("Max"); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::Foo.RangeDto).GetProperty("IsValid"); - // [Expressive] // public RangeDto(int a, int b) // { @@ -29,11 +23,11 @@ namespace ExpressiveSharp.Generated // IsValid = false; // } // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_int_P1_int_Expression() { var p_a = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "a"); var p_b = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "b"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.RangeDto).GetConstructor(new global::System.Type[] { })); var expr_1 = global::System.Linq.Expressions.Expression.Variable(typeof(int), "lo"); var expr_3 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.LessThan, p_a, p_b); // a < b var expr_2 = global::System.Linq.Expressions.Expression.Condition(expr_3, p_a, p_b, typeof(int)); @@ -48,9 +42,9 @@ namespace ExpressiveSharp.Generated var expr_13 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_11 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThan, expr_12, expr_13); var expr_14 = global::System.Linq.Expressions.Expression.Condition(expr_11, expr_9, expr_10, typeof(bool)); - var expr_15 = global::System.Linq.Expressions.Expression.Bind(_p0, expr_1); - var expr_16 = global::System.Linq.Expressions.Expression.Bind(_p1, expr_5); - var expr_17 = global::System.Linq.Expressions.Expression.Bind(_p2, expr_14); + var expr_15 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.RangeDto).GetProperty("Min"), expr_1); + var expr_16 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.RangeDto).GetProperty("Max"), expr_5); + var expr_17 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.RangeDto).GetProperty("IsValid"), expr_14); var expr_18 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_15, expr_16, expr_17); return global::System.Linq.Expressions.Expression.Lambda>(expr_18, p_a, p_b); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithMultipleClassArguments.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithMultipleClassArguments.verified.txt index dd8f6f9..b4f3d10 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithMultipleClassArguments.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithMultipleClassArguments.verified.txt @@ -5,29 +5,23 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_PersonDto__ctor_P0_Foo_NamePart_P1_Foo_NamePart + static partial class Foo_PersonDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.NamePart).GetProperty("Value"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.PersonDto).GetProperty("FirstName"); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::Foo.PersonDto).GetProperty("LastName"); - // [Expressive] // public PersonDto(NamePart first, NamePart last) // { // FirstName = first.Value; // LastName = last.Value; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_Foo_NamePart_P1_Foo_NamePart_Expression() { var p_first = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.NamePart), "first"); var p_last = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.NamePart), "last"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p_first, _p0); // first.Value - var expr_2 = global::System.Linq.Expressions.Expression.Property(p_last, _p0); // last.Value - var expr_3 = global::System.Linq.Expressions.Expression.Bind(_p1, expr_1); - var expr_4 = global::System.Linq.Expressions.Expression.Bind(_p2, expr_2); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.PersonDto).GetConstructor(new global::System.Type[] { })); + var expr_1 = global::System.Linq.Expressions.Expression.Property(p_first, typeof(global::Foo.NamePart).GetProperty("Value")); // first.Value + var expr_2 = global::System.Linq.Expressions.Expression.Property(p_last, typeof(global::Foo.NamePart).GetProperty("Value")); // last.Value + var expr_3 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PersonDto).GetProperty("FirstName"), expr_1); + var expr_4 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PersonDto).GetProperty("LastName"), expr_2); var expr_5 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_3, expr_4); return global::System.Linq.Expressions.Expression.Lambda>(expr_5, p_first, p_last); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithMultipleEarlyReturns.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithMultipleEarlyReturns.verified.txt index 7c56761..46362bc 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithMultipleEarlyReturns.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithMultipleEarlyReturns.verified.txt @@ -5,12 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_PriorityDto__ctor_P0_int + static partial class Foo_PriorityDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.PriorityDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.PriorityDto).GetProperty("Level"); - // [Expressive] // public PriorityDto(int value) // { @@ -34,10 +30,10 @@ namespace ExpressiveSharp.Generated // // Level = "High"; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_int_Expression() { var p_value = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "value"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.PriorityDto).GetConstructor(new global::System.Type[] { })); var expr_1 = global::System.Linq.Expressions.Expression.Constant("Invalid", typeof(string)); // "Invalid" var expr_3 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_2 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.LessThan, p_value, expr_3); @@ -52,7 +48,7 @@ namespace ExpressiveSharp.Generated var expr_11 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.LessThanOrEqual, p_value, expr_12); var expr_13 = global::System.Linq.Expressions.Expression.Condition(expr_11, expr_10, expr_9, typeof(string)); var expr_14 = global::System.Linq.Expressions.Expression.Constant("High", typeof(string)); // "High" - var expr_15 = global::System.Linq.Expressions.Expression.Bind(_p0, expr_14); + var expr_15 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.PriorityDto).GetProperty("Level"), expr_14); var expr_16 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_15); return global::System.Linq.Expressions.Expression.Lambda>(expr_16, p_value); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithMultipleLocalVariables.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithMultipleLocalVariables.verified.txt index ad593df..2434659 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithMultipleLocalVariables.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithMultipleLocalVariables.verified.txt @@ -5,16 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_AddressDto__ctor_P0_string_P1_string_P2_string + static partial class Foo_AddressDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.AddressDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("Trim", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.AddressDto).GetProperty("Street"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.AddressDto).GetProperty("City"); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::Foo.AddressDto).GetProperty("Full"); - // [Expressive] // public AddressDto(string street, string city, string country) // { @@ -24,27 +16,27 @@ namespace ExpressiveSharp.Generated // City = trimmedCity; // Full = trimmedStreet + ", " + trimmedCity + ", " + country; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_string_P1_string_P2_string_Expression() { var p_street = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "street"); var p_city = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "city"); var p_country = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "country"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.AddressDto).GetConstructor(new global::System.Type[] { })); var expr_1 = global::System.Linq.Expressions.Expression.Variable(typeof(string), "trimmedStreet"); - var expr_2 = global::System.Linq.Expressions.Expression.Call(p_street, _m0, global::System.Array.Empty()); // street.Trim() + var expr_2 = global::System.Linq.Expressions.Expression.Call(p_street, typeof(string).GetMethod("Trim", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null), global::System.Array.Empty()); // street.Trim() var expr_3 = global::System.Linq.Expressions.Expression.Assign(expr_1, expr_2); var expr_4 = global::System.Linq.Expressions.Expression.Variable(typeof(string), "trimmedCity"); - var expr_5 = global::System.Linq.Expressions.Expression.Call(p_city, _m0, global::System.Array.Empty()); // city.Trim() + var expr_5 = global::System.Linq.Expressions.Expression.Call(p_city, typeof(string).GetMethod("Trim", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null), global::System.Array.Empty()); // city.Trim() var expr_6 = global::System.Linq.Expressions.Expression.Assign(expr_4, expr_5); var expr_11 = global::System.Linq.Expressions.Expression.Constant(", ", typeof(string)); // ", " - var expr_10 = global::System.Linq.Expressions.Expression.Call(_m1, expr_1, expr_11); - var expr_9 = global::System.Linq.Expressions.Expression.Call(_m1, expr_10, expr_4); + var expr_10 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_1, expr_11); + var expr_9 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_10, expr_4); var expr_12 = global::System.Linq.Expressions.Expression.Constant(", ", typeof(string)); // ", " - var expr_8 = global::System.Linq.Expressions.Expression.Call(_m1, expr_9, expr_12); - var expr_7 = global::System.Linq.Expressions.Expression.Call(_m1, expr_8, p_country); - var expr_13 = global::System.Linq.Expressions.Expression.Bind(_p0, expr_1); - var expr_14 = global::System.Linq.Expressions.Expression.Bind(_p1, expr_4); - var expr_15 = global::System.Linq.Expressions.Expression.Bind(_p2, expr_7); + var expr_8 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_9, expr_12); + var expr_7 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_8, p_country); + var expr_13 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.AddressDto).GetProperty("Street"), expr_1); + var expr_14 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.AddressDto).GetProperty("City"), expr_4); + var expr_15 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.AddressDto).GetProperty("Full"), expr_7); var expr_16 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_13, expr_14, expr_15); return global::System.Linq.Expressions.Expression.Lambda>(expr_16, p_street, p_city, p_country); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithNestedIfElse.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithNestedIfElse.verified.txt index 990e2c4..4b78488 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithNestedIfElse.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithNestedIfElse.verified.txt @@ -5,12 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_StatusDto__ctor_P0_bool_P1_bool + static partial class Foo_StatusDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.StatusDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.StatusDto).GetProperty("Status"); - // [Expressive] // public StatusDto(bool isActive, bool isPremium) // { @@ -30,17 +26,17 @@ namespace ExpressiveSharp.Generated // Status = "Inactive"; // } // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_bool_P1_bool_Expression() { var p_isActive = global::System.Linq.Expressions.Expression.Parameter(typeof(bool), "isActive"); var p_isPremium = global::System.Linq.Expressions.Expression.Parameter(typeof(bool), "isPremium"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.StatusDto).GetConstructor(new global::System.Type[] { })); var expr_1 = global::System.Linq.Expressions.Expression.Constant("Active Premium", typeof(string)); // "Active Premium" var expr_2 = global::System.Linq.Expressions.Expression.Constant("Active Free", typeof(string)); // "Active Free" var expr_3 = global::System.Linq.Expressions.Expression.Condition(p_isPremium, expr_1, expr_2, typeof(string)); var expr_4 = global::System.Linq.Expressions.Expression.Constant("Inactive", typeof(string)); // "Inactive" var expr_5 = global::System.Linq.Expressions.Expression.Condition(p_isActive, expr_3, expr_4, typeof(string)); - var expr_6 = global::System.Linq.Expressions.Expression.Bind(_p0, expr_5); + var expr_6 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.StatusDto).GetProperty("Status"), expr_5); var expr_7 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_6); return global::System.Linq.Expressions.Expression.Lambda>(expr_7, p_isActive, p_isPremium); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithNullCoalescing.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithNullCoalescing.verified.txt index 5063ae1..54638f9 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithNullCoalescing.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithNullCoalescing.verified.txt @@ -5,31 +5,25 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_ProductDto__ctor_P0_string_P1_string + static partial class Foo_ProductDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.ProductDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.FieldInfo _f0 = typeof(string).GetField("Empty", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.ProductDto).GetProperty("Name"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.ProductDto).GetProperty("Description"); - // [Expressive] // public ProductDto(string name, string description) // { // Name = name ?? "Unnamed"; // Description = description ?? string.Empty; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_string_P1_string_Expression() { var p_name = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "name"); var p_description = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "description"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.ProductDto).GetConstructor(new global::System.Type[] { })); var expr_2 = global::System.Linq.Expressions.Expression.Constant("Unnamed", typeof(string)); // "Unnamed" var expr_1 = global::System.Linq.Expressions.Expression.Coalesce(p_name, expr_2); - var expr_4 = global::System.Linq.Expressions.Expression.Field(null, _f0); // string.Empty + var expr_4 = global::System.Linq.Expressions.Expression.Field(null, typeof(string).GetField("Empty", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static)); // string.Empty var expr_3 = global::System.Linq.Expressions.Expression.Coalesce(p_description, expr_4); - var expr_5 = global::System.Linq.Expressions.Expression.Bind(_p0, expr_1); - var expr_6 = global::System.Linq.Expressions.Expression.Bind(_p1, expr_3); + var expr_5 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.ProductDto).GetProperty("Name"), expr_1); + var expr_6 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.ProductDto).GetProperty("Description"), expr_3); var expr_7 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_5, expr_6); return global::System.Linq.Expressions.Expression.Lambda>(expr_7, p_name, p_description); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithNullableParameter.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithNullableParameter.verified.txt index 1cba29f..7856083 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithNullableParameter.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithNullableParameter.verified.txt @@ -5,30 +5,25 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_MeasurementDto__ctor_P0_double__P1_string + static partial class Foo_MeasurementDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.MeasurementDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.MeasurementDto).GetProperty("Value"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.MeasurementDto).GetProperty("Unit"); - // [Expressive] // public MeasurementDto(double? value, string unit) // { // Value = value ?? 0.0; // Unit = unit ?? "m"; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_double__P1_string_Expression() { var p_value = global::System.Linq.Expressions.Expression.Parameter(typeof(double?), "value"); var p_unit = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "unit"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.MeasurementDto).GetConstructor(new global::System.Type[] { })); var expr_2 = global::System.Linq.Expressions.Expression.Constant(0d, typeof(double)); // 0.0 var expr_1 = global::System.Linq.Expressions.Expression.Coalesce(p_value, expr_2); var expr_4 = global::System.Linq.Expressions.Expression.Constant("m", typeof(string)); // "m" var expr_3 = global::System.Linq.Expressions.Expression.Coalesce(p_unit, expr_4); - var expr_5 = global::System.Linq.Expressions.Expression.Bind(_p0, expr_1); - var expr_6 = global::System.Linq.Expressions.Expression.Bind(_p1, expr_3); + var expr_5 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.MeasurementDto).GetProperty("Value"), expr_1); + var expr_6 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.MeasurementDto).GetProperty("Unit"), expr_3); var expr_7 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_5, expr_6); return global::System.Linq.Expressions.Expression.Lambda>(expr_7, p_value, p_unit); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithSequentialIfs.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithSequentialIfs.verified.txt index 3d31e29..fe3fa07 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithSequentialIfs.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithSequentialIfs.verified.txt @@ -5,14 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_FlagDto__ctor_P0_string_P1_bool + static partial class Foo_FlagDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.FlagDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.FlagDto).GetProperty("Tag"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.FlagDto).GetProperty("IsVerified"); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::Foo.FlagDto).GetProperty("IsAdmin"); - // [Expressive] // public FlagDto(string role, bool verified) // { @@ -27,11 +21,11 @@ namespace ExpressiveSharp.Generated // IsAdmin = true; // } // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_string_P1_bool_Expression() { var p_role = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "role"); var p_verified = global::System.Linq.Expressions.Expression.Parameter(typeof(bool), "verified"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.FlagDto).GetConstructor(new global::System.Type[] { })); var expr_1 = global::System.Linq.Expressions.Expression.Constant(true, typeof(bool)); // true var expr_2 = global::System.Linq.Expressions.Expression.Default(typeof(bool)); var expr_3 = global::System.Linq.Expressions.Expression.Condition(p_verified, expr_1, expr_2, typeof(bool)); @@ -40,9 +34,9 @@ namespace ExpressiveSharp.Generated var expr_5 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Equal, p_role, expr_6); var expr_7 = global::System.Linq.Expressions.Expression.Default(typeof(bool)); var expr_8 = global::System.Linq.Expressions.Expression.Condition(expr_5, expr_4, expr_7, typeof(bool)); - var expr_9 = global::System.Linq.Expressions.Expression.Bind(_p0, p_role); - var expr_10 = global::System.Linq.Expressions.Expression.Bind(_p1, expr_3); - var expr_11 = global::System.Linq.Expressions.Expression.Bind(_p2, expr_8); + var expr_9 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.FlagDto).GetProperty("Tag"), p_role); + var expr_10 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.FlagDto).GetProperty("IsVerified"), expr_3); + var expr_11 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.FlagDto).GetProperty("IsAdmin"), expr_8); var expr_12 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_9, expr_10, expr_11); return global::System.Linq.Expressions.Expression.Lambda>(expr_12, p_role, p_verified); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithSwitchExpression.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithSwitchExpression.verified.txt index 34f31e5..ef791fd 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithSwitchExpression.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithSwitchExpression.verified.txt @@ -5,14 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_SeasonDto__ctor_P0_int + static partial class Foo_SeasonDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.SeasonDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(object), typeof(object) }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.SeasonDto).GetProperty("Name"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.SeasonDto).GetProperty("Description"); - // [Expressive] // public SeasonDto(int month) // { @@ -25,10 +19,10 @@ namespace ExpressiveSharp.Generated // }; // Description = "Month: " + month; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_int_Expression() { var p_month = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "month"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.SeasonDto).GetConstructor(new global::System.Type[] { })); var expr_1 = global::System.Linq.Expressions.Expression.Constant("Autumn", typeof(string)); // "Autumn" var expr_5 = global::System.Linq.Expressions.Expression.Constant(6, typeof(int)); // 6 var expr_4 = global::System.Linq.Expressions.Expression.Equal(p_month, expr_5); @@ -62,9 +56,9 @@ namespace ExpressiveSharp.Generated var expr_31 = global::System.Linq.Expressions.Expression.Condition(expr_22, expr_30, expr_21, typeof(string)); var expr_33 = global::System.Linq.Expressions.Expression.Constant("Month: ", typeof(string)); // "Month: " var expr_34 = global::System.Linq.Expressions.Expression.Convert(p_month, typeof(object)); // month - var expr_32 = global::System.Linq.Expressions.Expression.Call(_m0, expr_33, expr_34); - var expr_35 = global::System.Linq.Expressions.Expression.Bind(_p0, expr_31); - var expr_36 = global::System.Linq.Expressions.Expression.Bind(_p1, expr_32); + var expr_32 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(object), typeof(object) }, null), expr_33, expr_34); + var expr_35 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.SeasonDto).GetProperty("Name"), expr_31); + var expr_36 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.SeasonDto).GetProperty("Description"), expr_32); var expr_37 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_35, expr_36); return global::System.Linq.Expressions.Expression.Lambda>(expr_37, p_month); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithSwitchExpression_AndExtraProperty.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithSwitchExpression_AndExtraProperty.verified.txt index 96f4743..684a87f 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithSwitchExpression_AndExtraProperty.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithSwitchExpression_AndExtraProperty.verified.txt @@ -5,16 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_ShapeDto__ctor_P0_int + static partial class Foo_ShapeDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.ShapeDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.ShapeDto).GetProperty("ShapeType"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(object), typeof(object) }, null); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.ShapeDto).GetProperty("Sides"); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::Foo.ShapeDto).GetProperty("Description"); - // [Expressive] // public ShapeDto(int sides) // { @@ -28,10 +20,10 @@ namespace ExpressiveSharp.Generated // }; // Description = ShapeType + " with " + sides + " sides"; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_int_Expression() { var p_sides = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "sides"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.ShapeDto).GetConstructor(new global::System.Type[] { })); var expr_1 = global::System.Linq.Expressions.Expression.Constant("Polygon", typeof(string)); // "Polygon" var expr_3 = global::System.Linq.Expressions.Expression.Constant(5, typeof(int)); // 5 var expr_2 = global::System.Linq.Expressions.Expression.Equal(p_sides, expr_3); @@ -46,16 +38,16 @@ namespace ExpressiveSharp.Generated var expr_12 = global::System.Linq.Expressions.Expression.Constant("Triangle", typeof(string)); // "Triangle" var expr_13 = global::System.Linq.Expressions.Expression.Condition(expr_10, expr_12, expr_9, typeof(string)); var p___this = global::System.Linq.Expressions.Expression.Parameter(typeof(object), "@this"); // ShapeType - var expr_17 = global::System.Linq.Expressions.Expression.Property(p___this, _p0); + var expr_17 = global::System.Linq.Expressions.Expression.Property(p___this, typeof(global::Foo.ShapeDto).GetProperty("ShapeType")); var expr_18 = global::System.Linq.Expressions.Expression.Constant(" with ", typeof(string)); // " with " - var expr_16 = global::System.Linq.Expressions.Expression.Call(_m0, expr_17, expr_18); + var expr_16 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_17, expr_18); var expr_19 = global::System.Linq.Expressions.Expression.Convert(p_sides, typeof(object)); // sides - var expr_15 = global::System.Linq.Expressions.Expression.Call(_m1, expr_16, expr_19); + var expr_15 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(object), typeof(object) }, null), expr_16, expr_19); var expr_20 = global::System.Linq.Expressions.Expression.Constant(" sides", typeof(string)); // " sides" - var expr_14 = global::System.Linq.Expressions.Expression.Call(_m0, expr_15, expr_20); - var expr_21 = global::System.Linq.Expressions.Expression.Bind(_p1, p_sides); - var expr_22 = global::System.Linq.Expressions.Expression.Bind(_p0, expr_13); - var expr_23 = global::System.Linq.Expressions.Expression.Bind(_p2, expr_14); + var expr_14 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_15, expr_20); + var expr_21 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.ShapeDto).GetProperty("Sides"), p_sides); + var expr_22 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.ShapeDto).GetProperty("ShapeType"), expr_13); + var expr_23 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.ShapeDto).GetProperty("Description"), expr_14); var expr_24 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_21, expr_22, expr_23); return global::System.Linq.Expressions.Expression.Lambda>(expr_24, p_sides); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithTernaryAssignment.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithTernaryAssignment.verified.txt index e6ff06b..ce31911 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithTernaryAssignment.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithTernaryAssignment.verified.txt @@ -5,31 +5,24 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_LabelDto__ctor_P0_string_P1_bool + static partial class Foo_LabelDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.LabelDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("ToUpper", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(string).GetMethod("ToLower", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.LabelDto).GetProperty("Label"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.LabelDto).GetProperty("Display"); - // [Expressive] // public LabelDto(string name, bool uppercase) // { // Label = name; // Display = uppercase ? name.ToUpper() : name.ToLower(); // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_string_P1_bool_Expression() { var p_name = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "name"); var p_uppercase = global::System.Linq.Expressions.Expression.Parameter(typeof(bool), "uppercase"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); - var expr_2 = global::System.Linq.Expressions.Expression.Call(p_name, _m0, global::System.Array.Empty()); // name.ToUpper() - var expr_3 = global::System.Linq.Expressions.Expression.Call(p_name, _m1, global::System.Array.Empty()); // name.ToLower() + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.LabelDto).GetConstructor(new global::System.Type[] { })); + var expr_2 = global::System.Linq.Expressions.Expression.Call(p_name, typeof(string).GetMethod("ToUpper", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null), global::System.Array.Empty()); // name.ToUpper() + var expr_3 = global::System.Linq.Expressions.Expression.Call(p_name, typeof(string).GetMethod("ToLower", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null), global::System.Array.Empty()); // name.ToLower() var expr_1 = global::System.Linq.Expressions.Expression.Condition(p_uppercase, expr_2, expr_3, typeof(string)); - var expr_4 = global::System.Linq.Expressions.Expression.Bind(_p0, p_name); - var expr_5 = global::System.Linq.Expressions.Expression.Bind(_p1, expr_1); + var expr_4 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.LabelDto).GetProperty("Label"), p_name); + var expr_5 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.LabelDto).GetProperty("Display"), expr_1); var expr_6 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_4, expr_5); return global::System.Linq.Expressions.Expression.Lambda>(expr_6, p_name, p_uppercase); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithThisInitializer_AndElseIfInBody.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithThisInitializer_AndElseIfInBody.verified.txt index 8368c72..0e82837 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithThisInitializer_AndElseIfInBody.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ConstructorTests.ProjectableConstructor_WithThisInitializer_AndElseIfInBody.verified.txt @@ -5,12 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_EventDto__ctor_P0_string_P1_string_P2_int + static partial class Foo_EventDto { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::Foo.EventDto).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.EventDto).GetProperty("Priority"); - // [Expressive] // public EventDto(string title, string tag, int urgency) : this(title, tag) // { @@ -27,12 +23,12 @@ namespace ExpressiveSharp.Generated // Priority = "Normal"; // } // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> _ctor_P0_string_P1_string_P2_int_Expression() { var p_title = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "title"); var p_tag = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "tag"); var p_urgency = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "urgency"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::Foo.EventDto).GetConstructor(new global::System.Type[] { })); var expr_1 = global::System.Linq.Expressions.Expression.Constant("Critical", typeof(string)); // "Critical" var expr_2 = global::System.Linq.Expressions.Expression.Constant("High", typeof(string)); // "High" var expr_3 = global::System.Linq.Expressions.Expression.Constant("Normal", typeof(string)); // "Normal" @@ -42,7 +38,7 @@ namespace ExpressiveSharp.Generated var expr_8 = global::System.Linq.Expressions.Expression.Constant(10, typeof(int)); // 10 var expr_7 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThanOrEqual, p_urgency, expr_8); var expr_9 = global::System.Linq.Expressions.Expression.Condition(expr_7, expr_1, expr_6, typeof(string)); - var expr_10 = global::System.Linq.Expressions.Expression.Bind(_p0, expr_9); + var expr_10 = global::System.Linq.Expressions.Expression.Bind(typeof(global::Foo.EventDto).GetProperty("Priority"), expr_9); var expr_11 = global::System.Linq.Expressions.Expression.MemberInit(expr_0, expr_10); return global::System.Linq.Expressions.Expression.Lambda>(expr_11, p_title, p_tag, p_urgency); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsReturningBoolean.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsReturningBoolean.verified.txt index 89f875f..31fee87 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsReturningBoolean.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsReturningBoolean.verified.txt @@ -5,29 +5,25 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Entity_IsStatusApproved + static partial class Foo_Entity { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Entity).GetProperty("Status"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::Foo.EnumExtensions).GetMethod("IsApproved", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.Status) }, null); - // [Expressive] // public bool IsStatusApproved => Status.IsApproved(); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> IsStatusApproved_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Status + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Entity).GetProperty("Status")); // Status var expr_1 = global::System.Linq.Expressions.Expression.Default(typeof(bool)); var expr_2 = global::System.Linq.Expressions.Expression.Constant(global::Foo.Status.Rejected, typeof(global::Foo.Status)); - var expr_3 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { expr_2 }); + var expr_3 = global::System.Linq.Expressions.Expression.Call(typeof(global::Foo.EnumExtensions).GetMethod("IsApproved", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.Status) }, null), new global::System.Linq.Expressions.Expression[] { expr_2 }); var expr_4 = global::System.Linq.Expressions.Expression.Equal(expr_0, expr_2); var expr_5 = global::System.Linq.Expressions.Expression.Condition(expr_4, expr_3, expr_1, typeof(bool)); var expr_6 = global::System.Linq.Expressions.Expression.Constant(global::Foo.Status.Approved, typeof(global::Foo.Status)); - var expr_7 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { expr_6 }); + var expr_7 = global::System.Linq.Expressions.Expression.Call(typeof(global::Foo.EnumExtensions).GetMethod("IsApproved", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.Status) }, null), new global::System.Linq.Expressions.Expression[] { expr_6 }); var expr_8 = global::System.Linq.Expressions.Expression.Equal(expr_0, expr_6); var expr_9 = global::System.Linq.Expressions.Expression.Condition(expr_8, expr_7, expr_5, typeof(bool)); var expr_10 = global::System.Linq.Expressions.Expression.Constant(global::Foo.Status.Pending, typeof(global::Foo.Status)); - var expr_11 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { expr_10 }); + var expr_11 = global::System.Linq.Expressions.Expression.Call(typeof(global::Foo.EnumExtensions).GetMethod("IsApproved", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.Status) }, null), new global::System.Linq.Expressions.Expression[] { expr_10 }); var expr_12 = global::System.Linq.Expressions.Expression.Equal(expr_0, expr_10); var expr_13 = global::System.Linq.Expressions.Expression.Condition(expr_12, expr_11, expr_9, typeof(bool)); return global::System.Linq.Expressions.Expression.Lambda>(expr_13, p__this); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsReturningInteger.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsReturningInteger.verified.txt index ce264a0..e475327 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsReturningInteger.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsReturningInteger.verified.txt @@ -5,29 +5,25 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Entity_PrioritySortOrder + static partial class Foo_Entity { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Entity).GetProperty("Priority"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::Foo.EnumExtensions).GetMethod("GetSortOrder", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.Priority) }, null); - // [Expressive] // public int PrioritySortOrder => Priority.GetSortOrder(); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> PrioritySortOrder_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Priority + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Entity).GetProperty("Priority")); // Priority var expr_1 = global::System.Linq.Expressions.Expression.Default(typeof(int)); var expr_2 = global::System.Linq.Expressions.Expression.Constant(global::Foo.Priority.High, typeof(global::Foo.Priority)); - var expr_3 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { expr_2 }); + var expr_3 = global::System.Linq.Expressions.Expression.Call(typeof(global::Foo.EnumExtensions).GetMethod("GetSortOrder", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.Priority) }, null), new global::System.Linq.Expressions.Expression[] { expr_2 }); var expr_4 = global::System.Linq.Expressions.Expression.Equal(expr_0, expr_2); var expr_5 = global::System.Linq.Expressions.Expression.Condition(expr_4, expr_3, expr_1, typeof(int)); var expr_6 = global::System.Linq.Expressions.Expression.Constant(global::Foo.Priority.Medium, typeof(global::Foo.Priority)); - var expr_7 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { expr_6 }); + var expr_7 = global::System.Linq.Expressions.Expression.Call(typeof(global::Foo.EnumExtensions).GetMethod("GetSortOrder", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.Priority) }, null), new global::System.Linq.Expressions.Expression[] { expr_6 }); var expr_8 = global::System.Linq.Expressions.Expression.Equal(expr_0, expr_6); var expr_9 = global::System.Linq.Expressions.Expression.Condition(expr_8, expr_7, expr_5, typeof(int)); var expr_10 = global::System.Linq.Expressions.Expression.Constant(global::Foo.Priority.Low, typeof(global::Foo.Priority)); - var expr_11 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { expr_10 }); + var expr_11 = global::System.Linq.Expressions.Expression.Call(typeof(global::Foo.EnumExtensions).GetMethod("GetSortOrder", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.Priority) }, null), new global::System.Linq.Expressions.Expression[] { expr_10 }); var expr_12 = global::System.Linq.Expressions.Expression.Equal(expr_0, expr_10); var expr_13 = global::System.Linq.Expressions.Expression.Condition(expr_12, expr_11, expr_9, typeof(int)); return global::System.Linq.Expressions.Expression.Lambda>(expr_13, p__this); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsWithDescriptionAttribute.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsWithDescriptionAttribute.verified.txt index 94ea50e..4b7abf0 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsWithDescriptionAttribute.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsWithDescriptionAttribute.verified.txt @@ -6,29 +6,25 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Entity_StatusDescription + static partial class Foo_Entity { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Entity).GetProperty("Status"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::Foo.EnumExtensions).GetMethod("GetDescription", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.Status) }, null); - // [Expressive] // public string StatusDescription => Status.GetDescription(); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> StatusDescription_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Status + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Entity).GetProperty("Status")); // Status var expr_1 = global::System.Linq.Expressions.Expression.Constant(null, typeof(string)); var expr_2 = global::System.Linq.Expressions.Expression.Constant(global::Foo.Status.Rejected, typeof(global::Foo.Status)); - var expr_3 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { expr_2 }); + var expr_3 = global::System.Linq.Expressions.Expression.Call(typeof(global::Foo.EnumExtensions).GetMethod("GetDescription", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.Status) }, null), new global::System.Linq.Expressions.Expression[] { expr_2 }); var expr_4 = global::System.Linq.Expressions.Expression.Equal(expr_0, expr_2); var expr_5 = global::System.Linq.Expressions.Expression.Condition(expr_4, expr_3, expr_1, typeof(string)); var expr_6 = global::System.Linq.Expressions.Expression.Constant(global::Foo.Status.Approved, typeof(global::Foo.Status)); - var expr_7 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { expr_6 }); + var expr_7 = global::System.Linq.Expressions.Expression.Call(typeof(global::Foo.EnumExtensions).GetMethod("GetDescription", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.Status) }, null), new global::System.Linq.Expressions.Expression[] { expr_6 }); var expr_8 = global::System.Linq.Expressions.Expression.Equal(expr_0, expr_6); var expr_9 = global::System.Linq.Expressions.Expression.Condition(expr_8, expr_7, expr_5, typeof(string)); var expr_10 = global::System.Linq.Expressions.Expression.Constant(global::Foo.Status.Pending, typeof(global::Foo.Status)); - var expr_11 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { expr_10 }); + var expr_11 = global::System.Linq.Expressions.Expression.Call(typeof(global::Foo.EnumExtensions).GetMethod("GetDescription", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.Status) }, null), new global::System.Linq.Expressions.Expression[] { expr_10 }); var expr_12 = global::System.Linq.Expressions.Expression.Equal(expr_0, expr_10); var expr_13 = global::System.Linq.Expressions.Expression.Condition(expr_12, expr_11, expr_9, typeof(string)); return global::System.Linq.Expressions.Expression.Lambda>(expr_13, p__this); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsWithDisplayAttribute.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsWithDisplayAttribute.verified.txt index 712fd16..11687e0 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsWithDisplayAttribute.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsWithDisplayAttribute.verified.txt @@ -6,25 +6,21 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Entity_MyEnumName + static partial class Foo_Entity { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Entity).GetProperty("MyValue"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::Foo.EnumExtensions).GetMethod("GetDisplayName", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.CustomEnum) }, null); - // [Expressive] // public string MyEnumName => MyValue.GetDisplayName(); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> MyEnumName_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // MyValue + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Entity).GetProperty("MyValue")); // MyValue var expr_1 = global::System.Linq.Expressions.Expression.Constant(null, typeof(string)); var expr_2 = global::System.Linq.Expressions.Expression.Constant(global::Foo.CustomEnum.Value2, typeof(global::Foo.CustomEnum)); - var expr_3 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { expr_2 }); + var expr_3 = global::System.Linq.Expressions.Expression.Call(typeof(global::Foo.EnumExtensions).GetMethod("GetDisplayName", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.CustomEnum) }, null), new global::System.Linq.Expressions.Expression[] { expr_2 }); var expr_4 = global::System.Linq.Expressions.Expression.Equal(expr_0, expr_2); var expr_5 = global::System.Linq.Expressions.Expression.Condition(expr_4, expr_3, expr_1, typeof(string)); var expr_6 = global::System.Linq.Expressions.Expression.Constant(global::Foo.CustomEnum.Value1, typeof(global::Foo.CustomEnum)); - var expr_7 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { expr_6 }); + var expr_7 = global::System.Linq.Expressions.Expression.Call(typeof(global::Foo.EnumExtensions).GetMethod("GetDisplayName", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.CustomEnum) }, null), new global::System.Linq.Expressions.Expression[] { expr_6 }); var expr_8 = global::System.Linq.Expressions.Expression.Equal(expr_0, expr_6); var expr_9 = global::System.Linq.Expressions.Expression.Condition(expr_8, expr_7, expr_5, typeof(string)); return global::System.Linq.Expressions.Expression.Lambda>(expr_9, p__this); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsWithNullableEnum.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsWithNullableEnum.verified.txt index d753f7c..d8e1692 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsWithNullableEnum.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsWithNullableEnum.verified.txt @@ -6,30 +6,24 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Entity_MyEnumName + static partial class Foo_Entity { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.CustomEnum?).GetProperty("HasValue"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.Entity).GetProperty("MyValue"); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::Foo.CustomEnum?).GetProperty("Value"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::Foo.EnumExtensions).GetMethod("GetDisplayName", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.CustomEnum) }, null); - // [Expressive] // public string MyEnumName => MyValue.HasValue ? MyValue.Value.GetDisplayName() : null; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> MyEnumName_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "@this"); - var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, _p1); // MyValue - var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_2, _p0); - var expr_4 = global::System.Linq.Expressions.Expression.Property(p__this, _p1); // MyValue - var expr_3 = global::System.Linq.Expressions.Expression.Property(expr_4, _p2); + var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Entity).GetProperty("MyValue")); // MyValue + var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_2, typeof(global::Foo.CustomEnum?).GetProperty("HasValue")); + var expr_4 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Entity).GetProperty("MyValue")); // MyValue + var expr_3 = global::System.Linq.Expressions.Expression.Property(expr_4, typeof(global::Foo.CustomEnum?).GetProperty("Value")); var expr_5 = global::System.Linq.Expressions.Expression.Constant(null, typeof(string)); var expr_6 = global::System.Linq.Expressions.Expression.Constant(global::Foo.CustomEnum.Second, typeof(global::Foo.CustomEnum)); - var expr_7 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { expr_6 }); + var expr_7 = global::System.Linq.Expressions.Expression.Call(typeof(global::Foo.EnumExtensions).GetMethod("GetDisplayName", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.CustomEnum) }, null), new global::System.Linq.Expressions.Expression[] { expr_6 }); var expr_8 = global::System.Linq.Expressions.Expression.Equal(expr_3, expr_6); var expr_9 = global::System.Linq.Expressions.Expression.Condition(expr_8, expr_7, expr_5, typeof(string)); var expr_10 = global::System.Linq.Expressions.Expression.Constant(global::Foo.CustomEnum.First, typeof(global::Foo.CustomEnum)); - var expr_11 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { expr_10 }); + var expr_11 = global::System.Linq.Expressions.Expression.Call(typeof(global::Foo.EnumExtensions).GetMethod("GetDisplayName", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.CustomEnum) }, null), new global::System.Linq.Expressions.Expression[] { expr_10 }); var expr_12 = global::System.Linq.Expressions.Expression.Equal(expr_3, expr_10); var expr_13 = global::System.Linq.Expressions.Expression.Condition(expr_12, expr_11, expr_9, typeof(string)); var expr_15 = global::System.Linq.Expressions.Expression.Constant(null, typeof(object)); // null diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsWithParameter.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsWithParameter.verified.txt index eacfd8f..cbeca9e 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsWithParameter.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/EnumTests.ExpandEnumMethodsWithParameter.verified.txt @@ -5,32 +5,28 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Entity_StatusWithPrefix + static partial class Foo_Entity { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Entity).GetProperty("Status"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::Foo.EnumExtensions).GetMethod("GetDisplayNameWithPrefix", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.Status), typeof(string) }, null); - // [Expressive] // public string StatusWithPrefix => Status.GetDisplayNameWithPrefix("Status: "); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> StatusWithPrefix_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Status + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Entity).GetProperty("Status")); // Status var expr_1 = global::System.Linq.Expressions.Expression.Constant(null, typeof(string)); var expr_2 = global::System.Linq.Expressions.Expression.Constant(global::Foo.Status.Rejected, typeof(global::Foo.Status)); var expr_3 = global::System.Linq.Expressions.Expression.Constant("Status: ", typeof(string)); // "Status: " - var expr_4 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { expr_2, expr_3 }); + var expr_4 = global::System.Linq.Expressions.Expression.Call(typeof(global::Foo.EnumExtensions).GetMethod("GetDisplayNameWithPrefix", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.Status), typeof(string) }, null), new global::System.Linq.Expressions.Expression[] { expr_2, expr_3 }); var expr_5 = global::System.Linq.Expressions.Expression.Equal(expr_0, expr_2); var expr_6 = global::System.Linq.Expressions.Expression.Condition(expr_5, expr_4, expr_1, typeof(string)); var expr_7 = global::System.Linq.Expressions.Expression.Constant(global::Foo.Status.Approved, typeof(global::Foo.Status)); var expr_8 = global::System.Linq.Expressions.Expression.Constant("Status: ", typeof(string)); // "Status: " - var expr_9 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { expr_7, expr_8 }); + var expr_9 = global::System.Linq.Expressions.Expression.Call(typeof(global::Foo.EnumExtensions).GetMethod("GetDisplayNameWithPrefix", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.Status), typeof(string) }, null), new global::System.Linq.Expressions.Expression[] { expr_7, expr_8 }); var expr_10 = global::System.Linq.Expressions.Expression.Equal(expr_0, expr_7); var expr_11 = global::System.Linq.Expressions.Expression.Condition(expr_10, expr_9, expr_6, typeof(string)); var expr_12 = global::System.Linq.Expressions.Expression.Constant(global::Foo.Status.Pending, typeof(global::Foo.Status)); var expr_13 = global::System.Linq.Expressions.Expression.Constant("Status: ", typeof(string)); // "Status: " - var expr_14 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { expr_12, expr_13 }); + var expr_14 = global::System.Linq.Expressions.Expression.Call(typeof(global::Foo.EnumExtensions).GetMethod("GetDisplayNameWithPrefix", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::Foo.Status), typeof(string) }, null), new global::System.Linq.Expressions.Expression[] { expr_12, expr_13 }); var expr_15 = global::System.Linq.Expressions.Expression.Equal(expr_0, expr_12); var expr_16 = global::System.Linq.Expressions.Expression.Condition(expr_15, expr_14, expr_11, typeof(string)); return global::System.Linq.Expressions.Expression.Lambda>(expr_16, p__this); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberMethod.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberMethod.verified.txt index 54ecb3f..75f475e 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberMethod.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberMethod.verified.txt @@ -5,18 +5,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_EntityExtensions_TripleId_P0_Foo_Entity + static partial class Foo_EntityExtensions { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Entity).GetProperty("Id"); - // [Expressive] // public int TripleId() => e.Id * 3; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> TripleId_P0_Foo_Entity_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "@this"); var expr_2 = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "e"); // e - var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_2, _p0); + var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_2, typeof(global::Foo.Entity).GetProperty("Id")); var expr_3 = global::System.Linq.Expressions.Expression.Constant(3, typeof(int)); // 3 var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Multiply, expr_1, expr_3); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberMethodWithParameters.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberMethodWithParameters.verified.txt index c022ca8..daa4bce 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberMethodWithParameters.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberMethodWithParameters.verified.txt @@ -5,19 +5,16 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_EntityExtensions_Multiply_P0_Foo_Entity_P1_int + static partial class Foo_EntityExtensions { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Entity).GetProperty("Id"); - // [Expressive] // public int Multiply(int factor) => e.Id * factor; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Multiply_P0_Foo_Entity_P1_int_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "@this"); var p_factor = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "factor"); var expr_2 = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "e"); // e - var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_2, _p0); + var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_2, typeof(global::Foo.Entity).GetProperty("Id")); var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Multiply, expr_1, p_factor); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this, p_factor); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberOnInterface.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberOnInterface.verified.txt index c7042ca..afd7940 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberOnInterface.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberOnInterface.verified.txt @@ -5,26 +5,20 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_IEntityExtensions_Label + static partial class Foo_IEntityExtensions { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.IEntity).GetProperty("Id"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(object), typeof(object) }, null); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.IEntity).GetProperty("Name"); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null); - // [Expressive] // public string Label => e.Id + ": " + e.Name; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Label_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.IEntity), "@this"); var expr_4 = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.IEntity), "e"); // e - var expr_3 = global::System.Linq.Expressions.Expression.Property(expr_4, _p0); + var expr_3 = global::System.Linq.Expressions.Expression.Property(expr_4, typeof(global::Foo.IEntity).GetProperty("Id")); var expr_2 = global::System.Linq.Expressions.Expression.Convert(expr_3, typeof(object)); var expr_5 = global::System.Linq.Expressions.Expression.Constant(": ", typeof(string)); // ": " - var expr_1 = global::System.Linq.Expressions.Expression.Call(_m0, expr_2, expr_5); - var expr_6 = global::System.Linq.Expressions.Expression.Property(expr_4, _p1); // e.Name - var expr_0 = global::System.Linq.Expressions.Expression.Call(_m1, expr_1, expr_6); + var expr_1 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(object), typeof(object) }, null), expr_2, expr_5); + var expr_6 = global::System.Linq.Expressions.Expression.Property(expr_4, typeof(global::Foo.IEntity).GetProperty("Name")); // e.Name + var expr_0 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_1, expr_6); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberOnPrimitive.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberOnPrimitive.verified.txt index 4703566..3a38daf 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberOnPrimitive.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberOnPrimitive.verified.txt @@ -4,12 +4,11 @@ namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _IntExtensions_Squared + static partial class _IntExtensions { // [Expressive] // public int Squared => i * i; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Squared_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "@this"); var expr_1 = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "i"); // i diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberProperty.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberProperty.verified.txt index 2ffde67..3d8d0f0 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberProperty.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberProperty.verified.txt @@ -5,18 +5,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_EntityExtensions_DoubleId + static partial class Foo_EntityExtensions { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Entity).GetProperty("Id"); - // [Expressive] // public int DoubleId => e.Id * 2; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> DoubleId_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "@this"); var expr_2 = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "e"); // e - var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_2, _p0); + var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_2, typeof(global::Foo.Entity).GetProperty("Id")); var expr_3 = global::System.Linq.Expressions.Expression.Constant(2, typeof(int)); // 2 var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Multiply, expr_1, expr_3); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberWithBlockBody.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberWithBlockBody.verified.txt index b6ecf1f..5350ff7 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberWithBlockBody.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberWithBlockBody.verified.txt @@ -5,12 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_EntityExtensions_GetStatus_P0_Foo_Entity + static partial class Foo_EntityExtensions { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Entity).GetProperty("IsActive"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.Entity).GetProperty("Value"); - // [Expressive(AllowBlockBody = true)] // public string GetStatus() // { @@ -21,12 +17,12 @@ namespace ExpressiveSharp.Generated // // return "Inactive"; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> GetStatus_P0_Foo_Entity_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "@this"); var expr_3 = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "e"); // e - var expr_2 = global::System.Linq.Expressions.Expression.Property(expr_3, _p0); - var expr_5 = global::System.Linq.Expressions.Expression.Property(expr_3, _p1); // e.Value + var expr_2 = global::System.Linq.Expressions.Expression.Property(expr_3, typeof(global::Foo.Entity).GetProperty("IsActive")); + var expr_5 = global::System.Linq.Expressions.Expression.Property(expr_3, typeof(global::Foo.Entity).GetProperty("Value")); // e.Value var expr_6 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_4 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThan, expr_5, expr_6); var expr_1 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.AndAlso, expr_2, expr_4); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberWithIsPatternExpression.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberWithIsPatternExpression.verified.txt index 6f785de..699af39 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberWithIsPatternExpression.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberWithIsPatternExpression.verified.txt @@ -5,18 +5,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_EntityExtensions_IsHighValue + static partial class Foo_EntityExtensions { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Entity).GetProperty("Value"); - // [Expressive] // public bool IsHighValue => e.Value is> 100; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> IsHighValue_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "@this"); var expr_1 = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "e"); // e - var expr_0 = global::System.Linq.Expressions.Expression.Property(expr_1, _p0); + var expr_0 = global::System.Linq.Expressions.Expression.Property(expr_1, typeof(global::Foo.Entity).GetProperty("Value")); var expr_3 = global::System.Linq.Expressions.Expression.Constant(100, typeof(int)); // 100 var expr_2 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThan, expr_0, expr_3); return global::System.Linq.Expressions.Expression.Lambda>(expr_2, p__this); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberWithMemberAccess.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberWithMemberAccess.verified.txt index a93de60..e594130 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberWithMemberAccess.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberWithMemberAccess.verified.txt @@ -5,26 +5,20 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_EntityExtensions_IdAndName + static partial class Foo_EntityExtensions { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Entity).GetProperty("Id"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(object), typeof(object) }, null); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.Entity).GetProperty("Name"); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null); - // [Expressive] // public string IdAndName => e.Id + ": " + e.Name; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> IdAndName_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "@this"); var expr_4 = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "e"); // e - var expr_3 = global::System.Linq.Expressions.Expression.Property(expr_4, _p0); + var expr_3 = global::System.Linq.Expressions.Expression.Property(expr_4, typeof(global::Foo.Entity).GetProperty("Id")); var expr_2 = global::System.Linq.Expressions.Expression.Convert(expr_3, typeof(object)); var expr_5 = global::System.Linq.Expressions.Expression.Constant(": ", typeof(string)); // ": " - var expr_1 = global::System.Linq.Expressions.Expression.Call(_m0, expr_2, expr_5); - var expr_6 = global::System.Linq.Expressions.Expression.Property(expr_4, _p1); // e.Name - var expr_0 = global::System.Linq.Expressions.Expression.Call(_m1, expr_1, expr_6); + var expr_1 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(object), typeof(object) }, null), expr_2, expr_5); + var expr_6 = global::System.Linq.Expressions.Expression.Property(expr_4, typeof(global::Foo.Entity).GetProperty("Name")); // e.Name + var expr_0 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_1, expr_6); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberWithSwitchExpression.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberWithSwitchExpression.verified.txt index e8b31dd..bad9249 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberWithSwitchExpression.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMemberTests.ExtensionMemberWithSwitchExpression.verified.txt @@ -5,11 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_EntityExtensions_GetGrade_P0_Foo_Entity + static partial class Foo_EntityExtensions { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Entity).GetProperty("Score"); - // [Expressive] // public string GetGrade() => e.Score switch // { @@ -18,11 +15,11 @@ namespace ExpressiveSharp.Generated // >= 70 => "C", // _ => "F", // }; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> GetGrade_P0_Foo_Entity_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "@this"); var expr_1 = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "e"); // e - var expr_0 = global::System.Linq.Expressions.Expression.Property(expr_1, _p0); + var expr_0 = global::System.Linq.Expressions.Expression.Property(expr_1, typeof(global::Foo.Entity).GetProperty("Score")); var expr_2 = global::System.Linq.Expressions.Expression.Constant("F", typeof(string)); // "F" var expr_4 = global::System.Linq.Expressions.Expression.Constant(70, typeof(int)); // 70 var expr_3 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThanOrEqual, expr_0, expr_4); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMethodTests.ExpressiveExtensionMethod.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMethodTests.ExpressiveExtensionMethod.verified.txt index 1daa6e9..9aa3a34 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMethodTests.ExpressiveExtensionMethod.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMethodTests.ExpressiveExtensionMethod.verified.txt @@ -5,12 +5,11 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo_P0_Foo_D + static partial class Foo_C { // [Expressive] // public static int Foo(this D d) => 1; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_P0_Foo_D_Expression() { var p_d = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.D), "d"); var expr_0 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMethodTests.ExpressiveExtensionMethod_CallingAnotherExpressive.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMethodTests.ExpressiveExtensionMethod_CallingAnotherExpressive.verified.txt index 18cf453..aebb299 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMethodTests.ExpressiveExtensionMethod_CallingAnotherExpressive.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMethodTests.ExpressiveExtensionMethod_CallingAnotherExpressive.verified.txt @@ -5,12 +5,11 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo1_P0_int + static partial class Foo_C { // [Expressive] // public static int Foo1(this int i) => i; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo1_P0_int_Expression() { var p_i = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "i"); return global::System.Linq.Expressions.Expression.Lambda>(p_i, p_i); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMethodTests.ExpressiveExtensionMethod_OnValueType.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMethodTests.ExpressiveExtensionMethod_OnValueType.verified.txt index cedf8ae..54ecefc 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMethodTests.ExpressiveExtensionMethod_OnValueType.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMethodTests.ExpressiveExtensionMethod_OnValueType.verified.txt @@ -5,12 +5,11 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo_P0_int + static partial class Foo_C { // [Expressive] // public static int Foo(this int i) => i; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_P0_int_Expression() { var p_i = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "i"); return global::System.Linq.Expressions.Expression.Lambda>(p_i, p_i); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMethodTests.ExpressiveExtensionMethod_SelfRecursive.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMethodTests.ExpressiveExtensionMethod_SelfRecursive.verified.txt index cd14f6b..3e448da 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMethodTests.ExpressiveExtensionMethod_SelfRecursive.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ExtensionMethodTests.ExpressiveExtensionMethod_SelfRecursive.verified.txt @@ -5,17 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo1_P0_object + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::Foo.C).GetMethod("Foo1", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(object) }, null); - // [Expressive] // public static object Foo1(this object i) => i.Foo1(); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo1_P0_object_Expression() { var p_i = global::System.Linq.Expressions.Expression.Parameter(typeof(object), "i"); - var expr_0 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { p_i }); // i.Foo1() + var expr_0 = global::System.Linq.Expressions.Expression.Call(typeof(global::Foo.C).GetMethod("Foo1", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(object) }, null), new global::System.Linq.Expressions.Expression[] { p_i }); // i.Foo1() return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p_i); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/GenericTests.GenericClassesWithConstraints_AreRewritten.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/GenericTests.GenericClassesWithConstraints_AreRewritten.verified.txt index 150e072..1f28191 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/GenericTests.GenericClassesWithConstraints_AreRewritten.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/GenericTests.GenericClassesWithConstraints_AreRewritten.verified.txt @@ -5,32 +5,25 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Entity_FullName where T : global::Foo.TypedObject where TEnum : struct, global::System.Enum + static partial class Foo_Entity where T : global::Foo.TypedObject where TEnum : struct, global::System.Enum { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Entity).GetProperty("FirstName"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.Entity).GetProperty("LastName"); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::Foo.TypedObject).GetProperty("SomeProp"); - private static readonly global::System.Reflection.PropertyInfo _p3 = typeof(global::Foo.Entity).GetProperty("SomeSubobject"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null); - // [Expressive] // public string FullName => $"{FirstName} {LastName} {SomeSubobject.SomeProp}"; - static global::System.Linq.Expressions.Expression, string>> Expression() + static global::System.Linq.Expressions.Expression, string>> FullName_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // FirstName + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Entity).GetProperty("FirstName")); // FirstName var expr_1 = global::System.Linq.Expressions.Expression.Constant(" ", typeof(string)); - var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, _p1); // LastName + var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Entity).GetProperty("LastName")); // LastName var expr_3 = global::System.Linq.Expressions.Expression.Constant(" ", typeof(string)); - var expr_5 = global::System.Linq.Expressions.Expression.Property(p__this, _p3); // SomeSubobject - var expr_4 = global::System.Linq.Expressions.Expression.Property(expr_5, _p2); + var expr_5 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Entity).GetProperty("SomeSubobject")); // SomeSubobject + var expr_4 = global::System.Linq.Expressions.Expression.Property(expr_5, typeof(global::Foo.TypedObject).GetProperty("SomeProp")); var expr_6 = global::System.Linq.Expressions.Expression.Convert(expr_4, typeof(object)); var expr_7 = global::System.Linq.Expressions.Expression.Call(expr_6, typeof(object).GetMethod("ToString")); - var expr_8 = global::System.Linq.Expressions.Expression.Call(_m0, expr_0, expr_1); - var expr_9 = global::System.Linq.Expressions.Expression.Call(_m0, expr_8, expr_2); - var expr_10 = global::System.Linq.Expressions.Expression.Call(_m0, expr_9, expr_3); - var expr_11 = global::System.Linq.Expressions.Expression.Call(_m0, expr_10, expr_7); + var expr_8 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_0, expr_1); + var expr_9 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_8, expr_2); + var expr_10 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_9, expr_3); + var expr_11 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_10, expr_7); return global::System.Linq.Expressions.Expression.Lambda, string>>(expr_11, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/GenericTests.GenericClassesWithTypeConstraints_AreRewritten.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/GenericTests.GenericClassesWithTypeConstraints_AreRewritten.verified.txt index c7c7c43..49ca0ae 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/GenericTests.GenericClassesWithTypeConstraints_AreRewritten.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/GenericTests.GenericClassesWithTypeConstraints_AreRewritten.verified.txt @@ -5,30 +5,24 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Entity_FullName + static partial class Foo_Entity { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Entity).GetProperty("FirstName"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.Entity).GetProperty("LastName"); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::Foo.Entity).GetProperty("SomeSubobject"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null); - // [Expressive] // public string FullName => $"{FirstName} {LastName} {SomeSubobject}"; - static global::System.Linq.Expressions.Expression, string>> Expression() + static global::System.Linq.Expressions.Expression, string>> FullName_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // FirstName + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Entity).GetProperty("FirstName")); // FirstName var expr_1 = global::System.Linq.Expressions.Expression.Constant(" ", typeof(string)); - var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, _p1); // LastName + var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Entity).GetProperty("LastName")); // LastName var expr_3 = global::System.Linq.Expressions.Expression.Constant(" ", typeof(string)); - var expr_4 = global::System.Linq.Expressions.Expression.Property(p__this, _p2); // SomeSubobject + var expr_4 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Entity).GetProperty("SomeSubobject")); // SomeSubobject var expr_5 = global::System.Linq.Expressions.Expression.Convert(expr_4, typeof(object)); var expr_6 = global::System.Linq.Expressions.Expression.Call(expr_5, typeof(object).GetMethod("ToString")); - var expr_7 = global::System.Linq.Expressions.Expression.Call(_m0, expr_0, expr_1); - var expr_8 = global::System.Linq.Expressions.Expression.Call(_m0, expr_7, expr_2); - var expr_9 = global::System.Linq.Expressions.Expression.Call(_m0, expr_8, expr_3); - var expr_10 = global::System.Linq.Expressions.Expression.Call(_m0, expr_9, expr_6); + var expr_7 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_0, expr_1); + var expr_8 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_7, expr_2); + var expr_9 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_8, expr_3); + var expr_10 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_9, expr_6); return global::System.Linq.Expressions.Expression.Lambda, string>>(expr_10, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/GenericTests.GenericMethods_AreRewritten.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/GenericTests.GenericMethods_AreRewritten.verified.txt index e03516c..73a0740 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/GenericTests.GenericMethods_AreRewritten.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/GenericTests.GenericMethods_AreRewritten.verified.txt @@ -5,18 +5,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_EntityExtensions_EnforceString_P0_T + static partial class Foo_EntityExtensions { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.ValueType).GetMethod("ToString", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - // [Expressive] // public static string EnforceString(T value) // where T : unmanaged => value.ToString(); - static global::System.Linq.Expressions.Expression> Expression() where T : unmanaged + static global::System.Linq.Expressions.Expression> EnforceString_P0_T_Expression() where T : unmanaged { var p_value = global::System.Linq.Expressions.Expression.Parameter(typeof(T), "value"); - var expr_0 = global::System.Linq.Expressions.Expression.Call(p_value, _m0, global::System.Array.Empty()); // value.ToString() + var expr_0 = global::System.Linq.Expressions.Expression.Call(p_value, typeof(global::System.ValueType).GetMethod("ToString", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null), global::System.Array.Empty()); // value.ToString() return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p_value); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/GenericTests.GenericTypes.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/GenericTests.GenericTypes.verified.txt index 3ed9391..8179b03 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/GenericTests.GenericTypes.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/GenericTests.GenericTypes.verified.txt @@ -4,12 +4,11 @@ namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _EntityBase_GetId + static partial class _EntityBase { // [Expressive] // public static TId GetId() => default; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> GetId_Expression() { var expr_0 = global::System.Linq.Expressions.Expression.Default(typeof(TId)); // default return global::System.Linq.Expressions.Expression.Lambda>(expr_0, global::System.Array.Empty()); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/GenericTests.GenericTypesWithConstraints.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/GenericTests.GenericTypesWithConstraints.verified.txt index 34b62b5..6a53115 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/GenericTests.GenericTypesWithConstraints.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/GenericTests.GenericTypesWithConstraints.verified.txt @@ -4,12 +4,11 @@ namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _EntityBase_GetId where TId : global::System.ICloneable, new() + static partial class _EntityBase where TId : global::System.ICloneable, new() { // [Expressive] // public static TId GetId() => default; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> GetId_Expression() { var expr_0 = global::System.Linq.Expressions.Expression.Default(typeof(TId)); // default return global::System.Linq.Expressions.Expression.Lambda>(expr_0, global::System.Array.Empty()); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/IndexRangeTests.IndexFromEnd_WorksAsExpression.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/IndexRangeTests.IndexFromEnd_WorksAsExpression.verified.txt index 50e5743..2447f08 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/IndexRangeTests.IndexFromEnd_WorksAsExpression.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/IndexRangeTests.IndexFromEnd_WorksAsExpression.verified.txt @@ -5,17 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Last + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Items"); - // [Expressive] // public int Last => Items[^1]; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Last_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Items + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Items")); // Items var expr_3 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 var expr_4 = global::System.Linq.Expressions.Expression.Constant(true); var expr_5 = typeof(global::System.Index).GetConstructor(new global::System.Type[] { typeof(int), typeof(bool) }); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/IndexRangeTests.Range_WorksAsExpression.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/IndexRangeTests.Range_WorksAsExpression.verified.txt index dd0782e..9dca1b3 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/IndexRangeTests.Range_WorksAsExpression.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/IndexRangeTests.Range_WorksAsExpression.verified.txt @@ -5,22 +5,17 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Slice + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Start"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.Index).GetMethod("op_Implicit", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(int) }, null); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.C).GetProperty("End"); - // [Expressive] // public Range Slice => Start..End; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Slice_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Start - var expr_1 = global::System.Linq.Expressions.Expression.Convert(expr_2, typeof(global::System.Index), _m0); - var expr_4 = global::System.Linq.Expressions.Expression.Property(p__this, _p1); // End - var expr_3 = global::System.Linq.Expressions.Expression.Convert(expr_4, typeof(global::System.Index), _m0); + var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Start")); // Start + var expr_1 = global::System.Linq.Expressions.Expression.Convert(expr_2, typeof(global::System.Index), typeof(global::System.Index).GetMethod("op_Implicit", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(int) }, null)); + var expr_4 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("End")); // End + var expr_3 = global::System.Linq.Expressions.Expression.Convert(expr_4, typeof(global::System.Index), typeof(global::System.Index).GetMethod("op_Implicit", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(int) }, null)); var expr_5 = typeof(global::System.Range).GetConstructor(new global::System.Type[] { typeof(global::System.Index), typeof(global::System.Index) }); var expr_0 = global::System.Linq.Expressions.Expression.New(expr_5, expr_1, expr_3); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/InterfaceTests.DefaultInterfaceMember.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/InterfaceTests.DefaultInterfaceMember.verified.txt index eeb269d..68ba8a1 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/InterfaceTests.DefaultInterfaceMember.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/InterfaceTests.DefaultInterfaceMember.verified.txt @@ -4,17 +4,14 @@ namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _IDefaultBase_Default + static partial class _IDefaultBase { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::IBase).GetProperty("ComputedProperty"); - // [Expressive] // int Default => ComputedProperty * 2; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Default_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::IDefaultBase), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // ComputedProperty + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::IBase).GetProperty("ComputedProperty")); // ComputedProperty var expr_2 = global::System.Linq.Expressions.Expression.Constant(2, typeof(int)); // 2 var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Multiply, expr_1, expr_2); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/InterfaceTests.ExplicitInterfaceImplementation.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/InterfaceTests.ExplicitInterfaceImplementation.verified.txt index ba2e396..8bda3e6 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/InterfaceTests.ExplicitInterfaceImplementation.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/InterfaceTests.ExplicitInterfaceImplementation.verified.txt @@ -5,18 +5,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Item_FormattedId + static partial class Foo_Item { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.IStringId).GetProperty("Id"); - // [Expressive] // public string FormattedId => ((IStringId)this).Id; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> FormattedId_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Item), "@this"); var expr_1 = global::System.Linq.Expressions.Expression.Convert(p__this, typeof(global::Foo.IStringId)); // (IStringId)this - var expr_0 = global::System.Linq.Expressions.Expression.Property(expr_1, _p0); + var expr_0 = global::System.Linq.Expressions.Expression.Property(expr_1, typeof(global::Foo.IStringId).GetProperty("Id")); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/InterfaceTests.ExplicitInterfaceMember.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/InterfaceTests.ExplicitInterfaceMember.verified.txt index 8441e01..5a2f9f7 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/InterfaceTests.ExplicitInterfaceMember.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/InterfaceTests.ExplicitInterfaceMember.verified.txt @@ -4,17 +4,14 @@ namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _Concrete_IBase__ComputedProperty + static partial class _Concrete { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Concrete).GetProperty("Id"); - // [Expressive] // int IBase.ComputedProperty => Id + 1; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> IBase__ComputedProperty_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Concrete), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Id + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Concrete).GetProperty("Id")); // Id var expr_2 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_1, expr_2); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ListPatternTests.ListPattern_FixedLength.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ListPatternTests.ListPattern_FixedLength.verified.txt index 96e35b1..75eb102 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ListPatternTests.ListPattern_FixedLength.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ListPatternTests.ListPattern_FixedLength.verified.txt @@ -5,32 +5,27 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_IsOneTwoThree + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Items"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::System.Collections.Generic.List).GetProperty("Count"); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::System.Collections.Generic.List).GetProperty("this[]"); - // [Expressive] // public bool IsOneTwoThree => Items is [1, 2, 3]; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> IsOneTwoThree_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Items - var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_0, _p1); + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Items")); // Items + var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_0, typeof(global::System.Collections.Generic.List).GetProperty("Count")); var expr_2 = global::System.Linq.Expressions.Expression.Constant(3); var expr_3 = global::System.Linq.Expressions.Expression.Equal(expr_1, expr_2); var expr_4 = global::System.Linq.Expressions.Expression.Constant(0); - var expr_5 = global::System.Linq.Expressions.Expression.Property(expr_0, _p2, expr_4); + var expr_5 = global::System.Linq.Expressions.Expression.Property(expr_0, typeof(global::System.Collections.Generic.List).GetProperty("this[]"), expr_4); var expr_7 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 var expr_6 = global::System.Linq.Expressions.Expression.Equal(expr_5, expr_7); var expr_8 = global::System.Linq.Expressions.Expression.Constant(1); - var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_0, _p2, expr_8); + var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_0, typeof(global::System.Collections.Generic.List).GetProperty("this[]"), expr_8); var expr_11 = global::System.Linq.Expressions.Expression.Constant(2, typeof(int)); // 2 var expr_10 = global::System.Linq.Expressions.Expression.Equal(expr_9, expr_11); var expr_12 = global::System.Linq.Expressions.Expression.Constant(2); - var expr_13 = global::System.Linq.Expressions.Expression.Property(expr_0, _p2, expr_12); + var expr_13 = global::System.Linq.Expressions.Expression.Property(expr_0, typeof(global::System.Collections.Generic.List).GetProperty("this[]"), expr_12); var expr_15 = global::System.Linq.Expressions.Expression.Constant(3, typeof(int)); // 3 var expr_14 = global::System.Linq.Expressions.Expression.Equal(expr_13, expr_15); var expr_16 = global::System.Linq.Expressions.Expression.AndAlso(expr_3, expr_6); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ListPatternTests.ListPattern_WithSlice.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ListPatternTests.ListPattern_WithSlice.verified.txt index 3416b0c..e1a8e06 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ListPatternTests.ListPattern_WithSlice.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/ListPatternTests.ListPattern_WithSlice.verified.txt @@ -5,24 +5,19 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_StartsWithOne + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Items"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::System.Collections.Generic.List).GetProperty("Count"); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::System.Collections.Generic.List).GetProperty("this[]"); - // [Expressive] // public bool StartsWithOne => Items is [1, ..]; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> StartsWithOne_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Items - var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_0, _p1); + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Items")); // Items + var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_0, typeof(global::System.Collections.Generic.List).GetProperty("Count")); var expr_2 = global::System.Linq.Expressions.Expression.Constant(1); var expr_3 = global::System.Linq.Expressions.Expression.GreaterThanOrEqual(expr_1, expr_2); var expr_4 = global::System.Linq.Expressions.Expression.Constant(0); - var expr_5 = global::System.Linq.Expressions.Expression.Property(expr_0, _p2, expr_4); + var expr_5 = global::System.Linq.Expressions.Expression.Property(expr_0, typeof(global::System.Collections.Generic.List).GetProperty("this[]"), expr_4); var expr_7 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 var expr_6 = global::System.Linq.Expressions.Expression.Equal(expr_5, expr_7); var expr_8 = global::System.Linq.Expressions.Expression.AndAlso(expr_3, expr_6); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_Aggregate.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_Aggregate.verified.txt index 106654d..af3b681 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_Aggregate.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_Aggregate.verified.txt @@ -5,13 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Product_P0_System_Collections_Generic_List_int_ + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current"); - // [Expressive(AllowBlockBody = true)] // public int Product(List items) // { @@ -23,7 +18,7 @@ namespace ExpressiveSharp.Generated // // return product; // } - static global::System.Linq.Expressions.Expression, int>> Expression() + static global::System.Linq.Expressions.Expression, int>> Product_P0_System_Collections_Generic_List_int__Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_items = global::System.Linq.Expressions.Expression.Parameter(typeof(global::System.Collections.Generic.List), "items"); @@ -32,15 +27,15 @@ namespace ExpressiveSharp.Generated var expr_2 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_1); var expr_4 = global::System.Linq.Expressions.Expression.Variable(typeof(int), "x"); // foreach (var x in items) { product = product * x; } var expr_5 = global::System.Linq.Expressions.Expression.Variable(typeof(global::System.Collections.Generic.IEnumerator), "enumerator"); - var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, _m0); + var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_7 = global::System.Linq.Expressions.Expression.Assign(expr_5, expr_6); var expr_8 = global::System.Linq.Expressions.Expression.Label("break"); - var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, _p0); + var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current")); var expr_10 = global::System.Linq.Expressions.Expression.Assign(expr_4, expr_9); var expr_12 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Multiply, expr_0, expr_4); // product * x var expr_11 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_12); var expr_13 = global::System.Linq.Expressions.Expression.Block(expr_10, expr_11); - var expr_14 = global::System.Linq.Expressions.Expression.Call(expr_5, _m1); + var expr_14 = global::System.Linq.Expressions.Expression.Call(expr_5, typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_15 = global::System.Linq.Expressions.Expression.Break(expr_8); var expr_16 = global::System.Linq.Expressions.Expression.IfThenElse(expr_14, expr_13, expr_15); var expr_17 = global::System.Linq.Expressions.Expression.Loop(expr_16, expr_8); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_All.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_All.verified.txt index ae18449..8cc2b13 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_All.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_All.verified.txt @@ -5,13 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_AllPositive_P0_System_Collections_Generic_List_int_ + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current"); - // [Expressive(AllowBlockBody = true)] // public bool AllPositive(List items) // { @@ -24,7 +19,7 @@ namespace ExpressiveSharp.Generated // // return all; // } - static global::System.Linq.Expressions.Expression, bool>> Expression() + static global::System.Linq.Expressions.Expression, bool>> AllPositive_P0_System_Collections_Generic_List_int__Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_items = global::System.Linq.Expressions.Expression.Parameter(typeof(global::System.Collections.Generic.List), "items"); @@ -33,10 +28,10 @@ namespace ExpressiveSharp.Generated var expr_2 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_1); var expr_4 = global::System.Linq.Expressions.Expression.Variable(typeof(int), "x"); // foreach (var x in items) { if (!(x > 0)) all = false; } var expr_5 = global::System.Linq.Expressions.Expression.Variable(typeof(global::System.Collections.Generic.IEnumerator), "enumerator"); - var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, _m0); + var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_7 = global::System.Linq.Expressions.Expression.Assign(expr_5, expr_6); var expr_8 = global::System.Linq.Expressions.Expression.Label("break"); - var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, _p0); + var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current")); var expr_10 = global::System.Linq.Expressions.Expression.Assign(expr_4, expr_9); var expr_14 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_13 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThan, expr_4, expr_14); @@ -45,7 +40,7 @@ namespace ExpressiveSharp.Generated var expr_15 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_16); var expr_11 = global::System.Linq.Expressions.Expression.IfThen(expr_12, expr_15); var expr_17 = global::System.Linq.Expressions.Expression.Block(expr_10, expr_11); - var expr_18 = global::System.Linq.Expressions.Expression.Call(expr_5, _m1); + var expr_18 = global::System.Linq.Expressions.Expression.Call(expr_5, typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_19 = global::System.Linq.Expressions.Expression.Break(expr_8); var expr_20 = global::System.Linq.Expressions.Expression.IfThenElse(expr_18, expr_17, expr_19); var expr_21 = global::System.Linq.Expressions.Expression.Loop(expr_20, expr_8); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_Any.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_Any.verified.txt index eefbc6b..f1b5ec6 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_Any.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_Any.verified.txt @@ -5,13 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_HasNegative_P0_System_Collections_Generic_List_int_ + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current"); - // [Expressive(AllowBlockBody = true)] // public bool HasNegative(List items) // { @@ -24,7 +19,7 @@ namespace ExpressiveSharp.Generated // // return found; // } - static global::System.Linq.Expressions.Expression, bool>> Expression() + static global::System.Linq.Expressions.Expression, bool>> HasNegative_P0_System_Collections_Generic_List_int__Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_items = global::System.Linq.Expressions.Expression.Parameter(typeof(global::System.Collections.Generic.List), "items"); @@ -33,10 +28,10 @@ namespace ExpressiveSharp.Generated var expr_2 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_1); var expr_4 = global::System.Linq.Expressions.Expression.Variable(typeof(int), "x"); // foreach (var x in items) { if (x < 0) found = true; } var expr_5 = global::System.Linq.Expressions.Expression.Variable(typeof(global::System.Collections.Generic.IEnumerator), "enumerator"); - var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, _m0); + var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_7 = global::System.Linq.Expressions.Expression.Assign(expr_5, expr_6); var expr_8 = global::System.Linq.Expressions.Expression.Label("break"); - var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, _p0); + var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current")); var expr_10 = global::System.Linq.Expressions.Expression.Assign(expr_4, expr_9); var expr_13 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_12 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.LessThan, expr_4, expr_13); @@ -44,7 +39,7 @@ namespace ExpressiveSharp.Generated var expr_14 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_15); var expr_11 = global::System.Linq.Expressions.Expression.IfThen(expr_12, expr_14); var expr_16 = global::System.Linq.Expressions.Expression.Block(expr_10, expr_11); - var expr_17 = global::System.Linq.Expressions.Expression.Call(expr_5, _m1); + var expr_17 = global::System.Linq.Expressions.Expression.Call(expr_5, typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_18 = global::System.Linq.Expressions.Expression.Break(expr_8); var expr_19 = global::System.Linq.Expressions.Expression.IfThenElse(expr_17, expr_16, expr_18); var expr_20 = global::System.Linq.Expressions.Expression.Loop(expr_19, expr_8); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_ConditionalAggregate.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_ConditionalAggregate.verified.txt index efc834d..8e7d6e6 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_ConditionalAggregate.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_ConditionalAggregate.verified.txt @@ -5,13 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_ProductOfPositive_P0_System_Collections_Generic_List_int_ + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current"); - // [Expressive(AllowBlockBody = true)] // public int ProductOfPositive(List items) // { @@ -24,7 +19,7 @@ namespace ExpressiveSharp.Generated // // return product; // } - static global::System.Linq.Expressions.Expression, int>> Expression() + static global::System.Linq.Expressions.Expression, int>> ProductOfPositive_P0_System_Collections_Generic_List_int__Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_items = global::System.Linq.Expressions.Expression.Parameter(typeof(global::System.Collections.Generic.List), "items"); @@ -33,10 +28,10 @@ namespace ExpressiveSharp.Generated var expr_2 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_1); var expr_4 = global::System.Linq.Expressions.Expression.Variable(typeof(int), "x"); // foreach (var x in items) { if (x > 0) product = product *... var expr_5 = global::System.Linq.Expressions.Expression.Variable(typeof(global::System.Collections.Generic.IEnumerator), "enumerator"); - var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, _m0); + var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_7 = global::System.Linq.Expressions.Expression.Assign(expr_5, expr_6); var expr_8 = global::System.Linq.Expressions.Expression.Label("break"); - var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, _p0); + var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current")); var expr_10 = global::System.Linq.Expressions.Expression.Assign(expr_4, expr_9); var expr_13 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_12 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThan, expr_4, expr_13); @@ -44,7 +39,7 @@ namespace ExpressiveSharp.Generated var expr_14 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_15); var expr_11 = global::System.Linq.Expressions.Expression.IfThen(expr_12, expr_14); var expr_16 = global::System.Linq.Expressions.Expression.Block(expr_10, expr_11); - var expr_17 = global::System.Linq.Expressions.Expression.Call(expr_5, _m1); + var expr_17 = global::System.Linq.Expressions.Expression.Call(expr_5, typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_18 = global::System.Linq.Expressions.Expression.Break(expr_8); var expr_19 = global::System.Linq.Expressions.Expression.IfThenElse(expr_17, expr_16, expr_18); var expr_20 = global::System.Linq.Expressions.Expression.Loop(expr_19, expr_8); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_ConditionalMinWithMemberAccess.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_ConditionalMinWithMemberAccess.verified.txt index 81485c3..1d3ed57 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_ConditionalMinWithMemberAccess.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_ConditionalMinWithMemberAccess.verified.txt @@ -5,16 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_MinPositive_P0_System_Collections_Generic_List_global__Foo_Item_ + static partial class Foo_C { - private static readonly global::System.Reflection.FieldInfo _f0 = typeof(int).GetField("MaxValue", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.Item).GetProperty("Value"); - private static readonly global::System.Reflection.MethodInfo _m2 = typeof(global::System.Math).GetMethod("Min", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(int), typeof(int) }, null); - // [Expressive(AllowBlockBody = true)] // public int MinPositive(List items) // { @@ -27,29 +19,29 @@ namespace ExpressiveSharp.Generated // // return min; // } - static global::System.Linq.Expressions.Expression, int>> Expression() + static global::System.Linq.Expressions.Expression, int>> MinPositive_P0_System_Collections_Generic_List_global__Foo_Item__Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_items = global::System.Linq.Expressions.Expression.Parameter(typeof(global::System.Collections.Generic.List), "items"); var expr_0 = global::System.Linq.Expressions.Expression.Variable(typeof(int), "min"); // { var min = int.MaxValue; foreach... - var expr_1 = global::System.Linq.Expressions.Expression.Field(null, _f0); // int.MaxValue + var expr_1 = global::System.Linq.Expressions.Expression.Field(null, typeof(int).GetField("MaxValue", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static)); // int.MaxValue var expr_2 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_1); var expr_4 = global::System.Linq.Expressions.Expression.Variable(typeof(global::Foo.Item), "x"); // foreach (var x in items) { if (x.Value > 0) min = Math.Mi... var expr_5 = global::System.Linq.Expressions.Expression.Variable(typeof(global::System.Collections.Generic.IEnumerator), "enumerator"); - var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, _m0); + var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_7 = global::System.Linq.Expressions.Expression.Assign(expr_5, expr_6); var expr_8 = global::System.Linq.Expressions.Expression.Label("break"); - var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, _p0); + var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current")); var expr_10 = global::System.Linq.Expressions.Expression.Assign(expr_4, expr_9); - var expr_13 = global::System.Linq.Expressions.Expression.Property(expr_4, _p1); // x.Value + var expr_13 = global::System.Linq.Expressions.Expression.Property(expr_4, typeof(global::Foo.Item).GetProperty("Value")); // x.Value var expr_14 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_12 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThan, expr_13, expr_14); - var expr_17 = global::System.Linq.Expressions.Expression.Property(expr_4, _p1); // x.Value - var expr_16 = global::System.Linq.Expressions.Expression.Call(_m2, new global::System.Linq.Expressions.Expression[] { expr_0, expr_17 }); + var expr_17 = global::System.Linq.Expressions.Expression.Property(expr_4, typeof(global::Foo.Item).GetProperty("Value")); // x.Value + var expr_16 = global::System.Linq.Expressions.Expression.Call(typeof(global::System.Math).GetMethod("Min", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(int), typeof(int) }, null), new global::System.Linq.Expressions.Expression[] { expr_0, expr_17 }); var expr_15 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_16); var expr_11 = global::System.Linq.Expressions.Expression.IfThen(expr_12, expr_15); var expr_18 = global::System.Linq.Expressions.Expression.Block(expr_10, expr_11); - var expr_19 = global::System.Linq.Expressions.Expression.Call(expr_5, _m1); + var expr_19 = global::System.Linq.Expressions.Expression.Call(expr_5, typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_20 = global::System.Linq.Expressions.Expression.Break(expr_8); var expr_21 = global::System.Linq.Expressions.Expression.IfThenElse(expr_19, expr_18, expr_20); var expr_22 = global::System.Linq.Expressions.Expression.Loop(expr_21, expr_8); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_ConditionalSelectWithMethodCall.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_ConditionalSelectWithMethodCall.verified.txt index c633d54..f4ad168 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_ConditionalSelectWithMethodCall.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_ConditionalSelectWithMethodCall.verified.txt @@ -5,17 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_NamesOfExpensive_P0_System_Collections_Generic_List_global__Foo_Item_ + static partial class Foo_C { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::System.Collections.Generic.List).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.Item).GetProperty("Value"); - private static readonly global::System.Reflection.MethodInfo _m2 = typeof(global::System.Collections.Generic.List).GetMethod("Add", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(string) }, null); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::Foo.Item).GetProperty("Name"); - // [Expressive(AllowBlockBody = true)] // public List NamesOfExpensive(List items) // { @@ -28,28 +19,28 @@ namespace ExpressiveSharp.Generated // // return result; // } - static global::System.Linq.Expressions.Expression, global::System.Collections.Generic.List>> Expression() + static global::System.Linq.Expressions.Expression, global::System.Collections.Generic.List>> NamesOfExpensive_P0_System_Collections_Generic_List_global__Foo_Item__Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_items = global::System.Linq.Expressions.Expression.Parameter(typeof(global::System.Collections.Generic.List), "items"); var expr_0 = global::System.Linq.Expressions.Expression.Variable(typeof(global::System.Collections.Generic.List), "result"); // { var result = new List(); ... - var expr_1 = global::System.Linq.Expressions.Expression.New(_c0); // new List() + var expr_1 = global::System.Linq.Expressions.Expression.New(typeof(global::System.Collections.Generic.List).GetConstructor(new global::System.Type[] { })); // new List() var expr_2 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_1); var expr_4 = global::System.Linq.Expressions.Expression.Variable(typeof(global::Foo.Item), "x"); // foreach (var x in items) { if (x.Value > 100) result.Add(... var expr_5 = global::System.Linq.Expressions.Expression.Variable(typeof(global::System.Collections.Generic.IEnumerator), "enumerator"); - var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, _m0); + var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_7 = global::System.Linq.Expressions.Expression.Assign(expr_5, expr_6); var expr_8 = global::System.Linq.Expressions.Expression.Label("break"); - var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, _p0); + var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current")); var expr_10 = global::System.Linq.Expressions.Expression.Assign(expr_4, expr_9); - var expr_13 = global::System.Linq.Expressions.Expression.Property(expr_4, _p1); // x.Value + var expr_13 = global::System.Linq.Expressions.Expression.Property(expr_4, typeof(global::Foo.Item).GetProperty("Value")); // x.Value var expr_14 = global::System.Linq.Expressions.Expression.Constant(100, typeof(int)); // 100 var expr_12 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThan, expr_13, expr_14); - var expr_16 = global::System.Linq.Expressions.Expression.Property(expr_4, _p2); // x.Name - var expr_15 = global::System.Linq.Expressions.Expression.Call(expr_0, _m2, new global::System.Linq.Expressions.Expression[] { expr_16 }); + var expr_16 = global::System.Linq.Expressions.Expression.Property(expr_4, typeof(global::Foo.Item).GetProperty("Name")); // x.Name + var expr_15 = global::System.Linq.Expressions.Expression.Call(expr_0, typeof(global::System.Collections.Generic.List).GetMethod("Add", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(string) }, null), new global::System.Linq.Expressions.Expression[] { expr_16 }); var expr_11 = global::System.Linq.Expressions.Expression.IfThen(expr_12, expr_15); var expr_17 = global::System.Linq.Expressions.Expression.Block(expr_10, expr_11); - var expr_18 = global::System.Linq.Expressions.Expression.Call(expr_5, _m1); + var expr_18 = global::System.Linq.Expressions.Expression.Call(expr_5, typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_19 = global::System.Linq.Expressions.Expression.Break(expr_8); var expr_20 = global::System.Linq.Expressions.Expression.IfThenElse(expr_18, expr_17, expr_19); var expr_21 = global::System.Linq.Expressions.Expression.Loop(expr_20, expr_8); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_ConditionalSum.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_ConditionalSum.verified.txt index e9bae25..84d5075 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_ConditionalSum.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_ConditionalSum.verified.txt @@ -5,13 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_SumEven_P0_System_Collections_Generic_List_int_ + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current"); - // [Expressive(AllowBlockBody = true)] // public int SumEven(List items) // { @@ -26,7 +21,7 @@ namespace ExpressiveSharp.Generated // // return sum; // } - static global::System.Linq.Expressions.Expression, int>> Expression() + static global::System.Linq.Expressions.Expression, int>> SumEven_P0_System_Collections_Generic_List_int__Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_items = global::System.Linq.Expressions.Expression.Parameter(typeof(global::System.Collections.Generic.List), "items"); @@ -35,10 +30,10 @@ namespace ExpressiveSharp.Generated var expr_2 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_1); var expr_4 = global::System.Linq.Expressions.Expression.Variable(typeof(int), "i"); // foreach (var i in items) { if (i % 2 == 0) { sum += i; } } var expr_5 = global::System.Linq.Expressions.Expression.Variable(typeof(global::System.Collections.Generic.IEnumerator), "enumerator"); - var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, _m0); + var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_7 = global::System.Linq.Expressions.Expression.Assign(expr_5, expr_6); var expr_8 = global::System.Linq.Expressions.Expression.Label("break"); - var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, _p0); + var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current")); var expr_10 = global::System.Linq.Expressions.Expression.Assign(expr_4, expr_9); var expr_14 = global::System.Linq.Expressions.Expression.Constant(2, typeof(int)); // 2 var expr_13 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Modulo, expr_4, expr_14); @@ -48,7 +43,7 @@ namespace ExpressiveSharp.Generated var expr_16 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_17); var expr_11 = global::System.Linq.Expressions.Expression.IfThen(expr_12, expr_16); var expr_18 = global::System.Linq.Expressions.Expression.Block(expr_10, expr_11); - var expr_19 = global::System.Linq.Expressions.Expression.Call(expr_5, _m1); + var expr_19 = global::System.Linq.Expressions.Expression.Call(expr_5, typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_20 = global::System.Linq.Expressions.Expression.Break(expr_8); var expr_21 = global::System.Linq.Expressions.Expression.IfThenElse(expr_19, expr_18, expr_20); var expr_22 = global::System.Linq.Expressions.Expression.Loop(expr_21, expr_8); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_CountAll.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_CountAll.verified.txt index bc8ed94..c23f5f0 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_CountAll.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_CountAll.verified.txt @@ -5,13 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_CountAll_P0_System_Collections_Generic_List_int_ + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current"); - // [Expressive(AllowBlockBody = true)] // public int CountAll(List items) // { @@ -23,7 +18,7 @@ namespace ExpressiveSharp.Generated // // return count; // } - static global::System.Linq.Expressions.Expression, int>> Expression() + static global::System.Linq.Expressions.Expression, int>> CountAll_P0_System_Collections_Generic_List_int__Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_items = global::System.Linq.Expressions.Expression.Parameter(typeof(global::System.Collections.Generic.List), "items"); @@ -32,16 +27,16 @@ namespace ExpressiveSharp.Generated var expr_2 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_1); var expr_4 = global::System.Linq.Expressions.Expression.Variable(typeof(int), "x"); // foreach (var x in items) { count++; } var expr_5 = global::System.Linq.Expressions.Expression.Variable(typeof(global::System.Collections.Generic.IEnumerator), "enumerator"); - var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, _m0); + var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_7 = global::System.Linq.Expressions.Expression.Assign(expr_5, expr_6); var expr_8 = global::System.Linq.Expressions.Expression.Label("break"); - var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, _p0); + var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current")); var expr_10 = global::System.Linq.Expressions.Expression.Assign(expr_4, expr_9); var expr_12 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // count++ var expr_13 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_0, expr_12); var expr_11 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_13); var expr_14 = global::System.Linq.Expressions.Expression.Block(expr_10, expr_11); - var expr_15 = global::System.Linq.Expressions.Expression.Call(expr_5, _m1); + var expr_15 = global::System.Linq.Expressions.Expression.Call(expr_5, typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_16 = global::System.Linq.Expressions.Expression.Break(expr_8); var expr_17 = global::System.Linq.Expressions.Expression.IfThenElse(expr_15, expr_14, expr_16); var expr_18 = global::System.Linq.Expressions.Expression.Loop(expr_17, expr_8); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_CountWithPredicate.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_CountWithPredicate.verified.txt index 192d0ae..7bfb371 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_CountWithPredicate.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_CountWithPredicate.verified.txt @@ -5,13 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_CountPositive_P0_System_Collections_Generic_List_int_ + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current"); - // [Expressive(AllowBlockBody = true)] // public int CountPositive(List items) // { @@ -24,7 +19,7 @@ namespace ExpressiveSharp.Generated // // return count; // } - static global::System.Linq.Expressions.Expression, int>> Expression() + static global::System.Linq.Expressions.Expression, int>> CountPositive_P0_System_Collections_Generic_List_int__Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_items = global::System.Linq.Expressions.Expression.Parameter(typeof(global::System.Collections.Generic.List), "items"); @@ -33,10 +28,10 @@ namespace ExpressiveSharp.Generated var expr_2 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_1); var expr_4 = global::System.Linq.Expressions.Expression.Variable(typeof(int), "x"); // foreach (var x in items) { if (x > 0) count++; } var expr_5 = global::System.Linq.Expressions.Expression.Variable(typeof(global::System.Collections.Generic.IEnumerator), "enumerator"); - var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, _m0); + var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_7 = global::System.Linq.Expressions.Expression.Assign(expr_5, expr_6); var expr_8 = global::System.Linq.Expressions.Expression.Label("break"); - var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, _p0); + var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current")); var expr_10 = global::System.Linq.Expressions.Expression.Assign(expr_4, expr_9); var expr_13 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_12 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThan, expr_4, expr_13); @@ -45,7 +40,7 @@ namespace ExpressiveSharp.Generated var expr_14 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_16); var expr_11 = global::System.Linq.Expressions.Expression.IfThen(expr_12, expr_14); var expr_17 = global::System.Linq.Expressions.Expression.Block(expr_10, expr_11); - var expr_18 = global::System.Linq.Expressions.Expression.Call(expr_5, _m1); + var expr_18 = global::System.Linq.Expressions.Expression.Call(expr_5, typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_19 = global::System.Linq.Expressions.Expression.Break(expr_8); var expr_20 = global::System.Linq.Expressions.Expression.IfThenElse(expr_18, expr_17, expr_19); var expr_21 = global::System.Linq.Expressions.Expression.Loop(expr_20, expr_8); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_InstanceMethodInBody.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_InstanceMethodInBody.verified.txt index 04db692..7aee637 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_InstanceMethodInBody.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_InstanceMethodInBody.verified.txt @@ -5,14 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_WeightedSum_P0_System_Collections_Generic_List_int_ + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.C).GetProperty("Multiplier"); - // [Expressive(AllowBlockBody = true)] // public int WeightedSum(List items) // { @@ -24,7 +18,7 @@ namespace ExpressiveSharp.Generated // // return sum; // } - static global::System.Linq.Expressions.Expression, int>> Expression() + static global::System.Linq.Expressions.Expression, int>> WeightedSum_P0_System_Collections_Generic_List_int__Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_items = global::System.Linq.Expressions.Expression.Parameter(typeof(global::System.Collections.Generic.List), "items"); @@ -33,17 +27,17 @@ namespace ExpressiveSharp.Generated var expr_2 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_1); var expr_4 = global::System.Linq.Expressions.Expression.Variable(typeof(int), "x"); // foreach (var x in items) { sum += x * Multiplier; } var expr_5 = global::System.Linq.Expressions.Expression.Variable(typeof(global::System.Collections.Generic.IEnumerator), "enumerator"); - var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, _m0); + var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_7 = global::System.Linq.Expressions.Expression.Assign(expr_5, expr_6); var expr_8 = global::System.Linq.Expressions.Expression.Label("break"); - var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, _p0); + var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current")); var expr_10 = global::System.Linq.Expressions.Expression.Assign(expr_4, expr_9); - var expr_13 = global::System.Linq.Expressions.Expression.Property(p__this, _p1); // Multiplier + var expr_13 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Multiplier")); // Multiplier var expr_12 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Multiply, expr_4, expr_13); var expr_14 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_0, expr_12); var expr_11 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_14); var expr_15 = global::System.Linq.Expressions.Expression.Block(expr_10, expr_11); - var expr_16 = global::System.Linq.Expressions.Expression.Call(expr_5, _m1); + var expr_16 = global::System.Linq.Expressions.Expression.Call(expr_5, typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_17 = global::System.Linq.Expressions.Expression.Break(expr_8); var expr_18 = global::System.Linq.Expressions.Expression.IfThenElse(expr_16, expr_15, expr_17); var expr_19 = global::System.Linq.Expressions.Expression.Loop(expr_18, expr_8); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_Min.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_Min.verified.txt index 2655ba6..c444678 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_Min.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_Min.verified.txt @@ -5,15 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_FindMin_P0_System_Collections_Generic_List_int_ + static partial class Foo_C { - private static readonly global::System.Reflection.FieldInfo _f0 = typeof(int).GetField("MaxValue", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current"); - private static readonly global::System.Reflection.MethodInfo _m2 = typeof(global::System.Math).GetMethod("Min", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(int), typeof(int) }, null); - // [Expressive(AllowBlockBody = true)] // public int FindMin(List items) // { @@ -25,24 +18,24 @@ namespace ExpressiveSharp.Generated // // return min; // } - static global::System.Linq.Expressions.Expression, int>> Expression() + static global::System.Linq.Expressions.Expression, int>> FindMin_P0_System_Collections_Generic_List_int__Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_items = global::System.Linq.Expressions.Expression.Parameter(typeof(global::System.Collections.Generic.List), "items"); var expr_0 = global::System.Linq.Expressions.Expression.Variable(typeof(int), "min"); // { var min = int.MaxValue; foreach... - var expr_1 = global::System.Linq.Expressions.Expression.Field(null, _f0); // int.MaxValue + var expr_1 = global::System.Linq.Expressions.Expression.Field(null, typeof(int).GetField("MaxValue", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static)); // int.MaxValue var expr_2 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_1); var expr_4 = global::System.Linq.Expressions.Expression.Variable(typeof(int), "x"); // foreach (var x in items) { min = Math.Min(min, x); } var expr_5 = global::System.Linq.Expressions.Expression.Variable(typeof(global::System.Collections.Generic.IEnumerator), "enumerator"); - var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, _m0); + var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_7 = global::System.Linq.Expressions.Expression.Assign(expr_5, expr_6); var expr_8 = global::System.Linq.Expressions.Expression.Label("break"); - var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, _p0); + var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current")); var expr_10 = global::System.Linq.Expressions.Expression.Assign(expr_4, expr_9); - var expr_12 = global::System.Linq.Expressions.Expression.Call(_m2, new global::System.Linq.Expressions.Expression[] { expr_0, expr_4 }); // Math.Min(min, x) + var expr_12 = global::System.Linq.Expressions.Expression.Call(typeof(global::System.Math).GetMethod("Min", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(int), typeof(int) }, null), new global::System.Linq.Expressions.Expression[] { expr_0, expr_4 }); // Math.Min(min, x) var expr_11 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_12); var expr_13 = global::System.Linq.Expressions.Expression.Block(expr_10, expr_11); - var expr_14 = global::System.Linq.Expressions.Expression.Call(expr_5, _m1); + var expr_14 = global::System.Linq.Expressions.Expression.Call(expr_5, typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_15 = global::System.Linq.Expressions.Expression.Break(expr_8); var expr_16 = global::System.Linq.Expressions.Expression.IfThenElse(expr_14, expr_13, expr_15); var expr_17 = global::System.Linq.Expressions.Expression.Loop(expr_16, expr_8); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_SelectWithMethodCall.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_SelectWithMethodCall.verified.txt index 59c0285..4077f1b 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_SelectWithMethodCall.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_SelectWithMethodCall.verified.txt @@ -5,16 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Names_P0_System_Collections_Generic_List_int_ + static partial class Foo_C { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::System.Collections.Generic.List).GetConstructor(new global::System.Type[] { }); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current"); - private static readonly global::System.Reflection.MethodInfo _m2 = typeof(global::System.Collections.Generic.List).GetMethod("Add", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(string) }, null); - private static readonly global::System.Reflection.MethodInfo _m3 = typeof(int).GetMethod("ToString", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - // [Expressive(AllowBlockBody = true)] // public List Names(List items) // { @@ -26,24 +18,24 @@ namespace ExpressiveSharp.Generated // // return result; // } - static global::System.Linq.Expressions.Expression, global::System.Collections.Generic.List>> Expression() + static global::System.Linq.Expressions.Expression, global::System.Collections.Generic.List>> Names_P0_System_Collections_Generic_List_int__Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_items = global::System.Linq.Expressions.Expression.Parameter(typeof(global::System.Collections.Generic.List), "items"); var expr_0 = global::System.Linq.Expressions.Expression.Variable(typeof(global::System.Collections.Generic.List), "result"); // { var result = new List(); ... - var expr_1 = global::System.Linq.Expressions.Expression.New(_c0); // new List() + var expr_1 = global::System.Linq.Expressions.Expression.New(typeof(global::System.Collections.Generic.List).GetConstructor(new global::System.Type[] { })); // new List() var expr_2 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_1); var expr_4 = global::System.Linq.Expressions.Expression.Variable(typeof(int), "x"); // foreach (var x in items) { result.Add(x.ToString()); } var expr_5 = global::System.Linq.Expressions.Expression.Variable(typeof(global::System.Collections.Generic.IEnumerator), "enumerator"); - var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, _m0); + var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_7 = global::System.Linq.Expressions.Expression.Assign(expr_5, expr_6); var expr_8 = global::System.Linq.Expressions.Expression.Label("break"); - var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, _p0); + var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current")); var expr_10 = global::System.Linq.Expressions.Expression.Assign(expr_4, expr_9); - var expr_12 = global::System.Linq.Expressions.Expression.Call(expr_4, _m3, global::System.Array.Empty()); // x.ToString() - var expr_11 = global::System.Linq.Expressions.Expression.Call(expr_0, _m2, new global::System.Linq.Expressions.Expression[] { expr_12 }); + var expr_12 = global::System.Linq.Expressions.Expression.Call(expr_4, typeof(int).GetMethod("ToString", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null), global::System.Array.Empty()); // x.ToString() + var expr_11 = global::System.Linq.Expressions.Expression.Call(expr_0, typeof(global::System.Collections.Generic.List).GetMethod("Add", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(string) }, null), new global::System.Linq.Expressions.Expression[] { expr_12 }); var expr_13 = global::System.Linq.Expressions.Expression.Block(expr_10, expr_11); - var expr_14 = global::System.Linq.Expressions.Expression.Call(expr_5, _m1); + var expr_14 = global::System.Linq.Expressions.Expression.Call(expr_5, typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_15 = global::System.Linq.Expressions.Expression.Break(expr_8); var expr_16 = global::System.Linq.Expressions.Expression.IfThenElse(expr_14, expr_13, expr_15); var expr_17 = global::System.Linq.Expressions.Expression.Loop(expr_16, expr_8); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_Sum.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_Sum.verified.txt index a848322..cc5b530 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_Sum.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_Sum.verified.txt @@ -5,13 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Sum_P0_System_Collections_Generic_List_int_ + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current"); - // [Expressive(AllowBlockBody = true)] // public int Sum(List items) // { @@ -23,7 +18,7 @@ namespace ExpressiveSharp.Generated // // return sum; // } - static global::System.Linq.Expressions.Expression, int>> Expression() + static global::System.Linq.Expressions.Expression, int>> Sum_P0_System_Collections_Generic_List_int__Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_items = global::System.Linq.Expressions.Expression.Parameter(typeof(global::System.Collections.Generic.List), "items"); @@ -32,15 +27,15 @@ namespace ExpressiveSharp.Generated var expr_2 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_1); var expr_4 = global::System.Linq.Expressions.Expression.Variable(typeof(int), "x"); // foreach (var x in items) { sum += x; } var expr_5 = global::System.Linq.Expressions.Expression.Variable(typeof(global::System.Collections.Generic.IEnumerator), "enumerator"); - var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, _m0); + var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_7 = global::System.Linq.Expressions.Expression.Assign(expr_5, expr_6); var expr_8 = global::System.Linq.Expressions.Expression.Label("break"); - var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, _p0); + var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current")); var expr_10 = global::System.Linq.Expressions.Expression.Assign(expr_4, expr_9); var expr_12 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_0, expr_4); // sum += x var expr_11 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_12); var expr_13 = global::System.Linq.Expressions.Expression.Block(expr_10, expr_11); - var expr_14 = global::System.Linq.Expressions.Expression.Call(expr_5, _m1); + var expr_14 = global::System.Linq.Expressions.Expression.Call(expr_5, typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_15 = global::System.Linq.Expressions.Expression.Break(expr_8); var expr_16 = global::System.Linq.Expressions.Expression.IfThenElse(expr_14, expr_13, expr_15); var expr_17 = global::System.Linq.Expressions.Expression.Loop(expr_16, expr_8); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_SumWithChainedMemberAccess.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_SumWithChainedMemberAccess.verified.txt index 8469d0d..20fa6b6 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_SumWithChainedMemberAccess.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_SumWithChainedMemberAccess.verified.txt @@ -5,15 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Sum_P0_System_Collections_Generic_List_global__Foo_Outer_ + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.Inner).GetProperty("Score"); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::Foo.Outer).GetProperty("Inner"); - // [Expressive(AllowBlockBody = true)] // public int Sum(List items) // { @@ -25,7 +18,7 @@ namespace ExpressiveSharp.Generated // // return sum; // } - static global::System.Linq.Expressions.Expression, int>> Expression() + static global::System.Linq.Expressions.Expression, int>> Sum_P0_System_Collections_Generic_List_global__Foo_Outer__Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_items = global::System.Linq.Expressions.Expression.Parameter(typeof(global::System.Collections.Generic.List), "items"); @@ -34,17 +27,17 @@ namespace ExpressiveSharp.Generated var expr_2 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_1); var expr_4 = global::System.Linq.Expressions.Expression.Variable(typeof(global::Foo.Outer), "x"); // foreach (var x in items) { sum += x.Inner.Score; } var expr_5 = global::System.Linq.Expressions.Expression.Variable(typeof(global::System.Collections.Generic.IEnumerator), "enumerator"); - var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, _m0); + var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_7 = global::System.Linq.Expressions.Expression.Assign(expr_5, expr_6); var expr_8 = global::System.Linq.Expressions.Expression.Label("break"); - var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, _p0); + var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current")); var expr_10 = global::System.Linq.Expressions.Expression.Assign(expr_4, expr_9); - var expr_13 = global::System.Linq.Expressions.Expression.Property(expr_4, _p2); // x.Inner - var expr_12 = global::System.Linq.Expressions.Expression.Property(expr_13, _p1); + var expr_13 = global::System.Linq.Expressions.Expression.Property(expr_4, typeof(global::Foo.Outer).GetProperty("Inner")); // x.Inner + var expr_12 = global::System.Linq.Expressions.Expression.Property(expr_13, typeof(global::Foo.Inner).GetProperty("Score")); var expr_14 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_0, expr_12); var expr_11 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_14); var expr_15 = global::System.Linq.Expressions.Expression.Block(expr_10, expr_11); - var expr_16 = global::System.Linq.Expressions.Expression.Call(expr_5, _m1); + var expr_16 = global::System.Linq.Expressions.Expression.Call(expr_5, typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_17 = global::System.Linq.Expressions.Expression.Break(expr_8); var expr_18 = global::System.Linq.Expressions.Expression.IfThenElse(expr_16, expr_15, expr_17); var expr_19 = global::System.Linq.Expressions.Expression.Loop(expr_18, expr_8); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_SumWithMethodCall.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_SumWithMethodCall.verified.txt index 84b7783..91edde2 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_SumWithMethodCall.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_SumWithMethodCall.verified.txt @@ -5,14 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_SumOfSquares_P0_System_Collections_Generic_List_int_ + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current"); - private static readonly global::System.Reflection.MethodInfo _m2 = typeof(global::Foo.C).GetMethod("Transform", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(int) }, null); - // [Expressive(AllowBlockBody = true)] // public int SumOfSquares(List items) // { @@ -24,7 +18,7 @@ namespace ExpressiveSharp.Generated // // return sum; // } - static global::System.Linq.Expressions.Expression, int>> Expression() + static global::System.Linq.Expressions.Expression, int>> SumOfSquares_P0_System_Collections_Generic_List_int__Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_items = global::System.Linq.Expressions.Expression.Parameter(typeof(global::System.Collections.Generic.List), "items"); @@ -33,16 +27,16 @@ namespace ExpressiveSharp.Generated var expr_2 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_1); var expr_4 = global::System.Linq.Expressions.Expression.Variable(typeof(int), "x"); // foreach (var x in items) { sum += Transform(x); } var expr_5 = global::System.Linq.Expressions.Expression.Variable(typeof(global::System.Collections.Generic.IEnumerator), "enumerator"); - var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, _m0); + var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_7 = global::System.Linq.Expressions.Expression.Assign(expr_5, expr_6); var expr_8 = global::System.Linq.Expressions.Expression.Label("break"); - var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, _p0); + var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current")); var expr_10 = global::System.Linq.Expressions.Expression.Assign(expr_4, expr_9); - var expr_12 = global::System.Linq.Expressions.Expression.Call(_m2, new global::System.Linq.Expressions.Expression[] { expr_4 }); // Transform(x) + var expr_12 = global::System.Linq.Expressions.Expression.Call(typeof(global::Foo.C).GetMethod("Transform", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(int) }, null), new global::System.Linq.Expressions.Expression[] { expr_4 }); // Transform(x) var expr_13 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_0, expr_12); var expr_11 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_13); var expr_14 = global::System.Linq.Expressions.Expression.Block(expr_10, expr_11); - var expr_15 = global::System.Linq.Expressions.Expression.Call(expr_5, _m1); + var expr_15 = global::System.Linq.Expressions.Expression.Call(expr_5, typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_16 = global::System.Linq.Expressions.Expression.Break(expr_8); var expr_17 = global::System.Linq.Expressions.Expression.IfThenElse(expr_15, expr_14, expr_16); var expr_18 = global::System.Linq.Expressions.Expression.Loop(expr_17, expr_8); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_SumWithSelector.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_SumWithSelector.verified.txt index 40d19ed..178db7e 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_SumWithSelector.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_SumWithSelector.verified.txt @@ -5,14 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Sum_P0_System_Collections_Generic_List_global__Foo_Item_ + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.Item).GetProperty("Value"); - // [Expressive(AllowBlockBody = true)] // public int Sum(List items) // { @@ -24,7 +18,7 @@ namespace ExpressiveSharp.Generated // // return sum; // } - static global::System.Linq.Expressions.Expression, int>> Expression() + static global::System.Linq.Expressions.Expression, int>> Sum_P0_System_Collections_Generic_List_global__Foo_Item__Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_items = global::System.Linq.Expressions.Expression.Parameter(typeof(global::System.Collections.Generic.List), "items"); @@ -33,16 +27,16 @@ namespace ExpressiveSharp.Generated var expr_2 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_1); var expr_4 = global::System.Linq.Expressions.Expression.Variable(typeof(global::Foo.Item), "x"); // foreach (var x in items) { sum += x.Value; } var expr_5 = global::System.Linq.Expressions.Expression.Variable(typeof(global::System.Collections.Generic.IEnumerator), "enumerator"); - var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, _m0); + var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_7 = global::System.Linq.Expressions.Expression.Assign(expr_5, expr_6); var expr_8 = global::System.Linq.Expressions.Expression.Label("break"); - var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, _p0); + var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current")); var expr_10 = global::System.Linq.Expressions.Expression.Assign(expr_4, expr_9); - var expr_12 = global::System.Linq.Expressions.Expression.Property(expr_4, _p1); // x.Value + var expr_12 = global::System.Linq.Expressions.Expression.Property(expr_4, typeof(global::Foo.Item).GetProperty("Value")); // x.Value var expr_13 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_0, expr_12); var expr_11 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_13); var expr_14 = global::System.Linq.Expressions.Expression.Block(expr_10, expr_11); - var expr_15 = global::System.Linq.Expressions.Expression.Call(expr_5, _m1); + var expr_15 = global::System.Linq.Expressions.Expression.Call(expr_5, typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_16 = global::System.Linq.Expressions.Expression.Break(expr_8); var expr_17 = global::System.Linq.Expressions.Expression.IfThenElse(expr_15, expr_14, expr_16); var expr_18 = global::System.Linq.Expressions.Expression.Loop(expr_17, expr_8); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_WithLoopDisableFlag_StillEmitsLoop.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_WithLoopDisableFlag_StillEmitsLoop.verified.txt index a848322..cc5b530 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_WithLoopDisableFlag_StillEmitsLoop.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForEach_WithLoopDisableFlag_StillEmitsLoop.verified.txt @@ -5,13 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Sum_P0_System_Collections_Generic_List_int_ + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current"); - // [Expressive(AllowBlockBody = true)] // public int Sum(List items) // { @@ -23,7 +18,7 @@ namespace ExpressiveSharp.Generated // // return sum; // } - static global::System.Linq.Expressions.Expression, int>> Expression() + static global::System.Linq.Expressions.Expression, int>> Sum_P0_System_Collections_Generic_List_int__Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_items = global::System.Linq.Expressions.Expression.Parameter(typeof(global::System.Collections.Generic.List), "items"); @@ -32,15 +27,15 @@ namespace ExpressiveSharp.Generated var expr_2 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_1); var expr_4 = global::System.Linq.Expressions.Expression.Variable(typeof(int), "x"); // foreach (var x in items) { sum += x; } var expr_5 = global::System.Linq.Expressions.Expression.Variable(typeof(global::System.Collections.Generic.IEnumerator), "enumerator"); - var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, _m0); + var expr_6 = global::System.Linq.Expressions.Expression.Call(p_items, typeof(global::System.Collections.Generic.IEnumerable).GetMethod("GetEnumerator", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_7 = global::System.Linq.Expressions.Expression.Assign(expr_5, expr_6); var expr_8 = global::System.Linq.Expressions.Expression.Label("break"); - var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, _p0); + var expr_9 = global::System.Linq.Expressions.Expression.Property(expr_5, typeof(global::System.Collections.Generic.IEnumerator).GetProperty("Current")); var expr_10 = global::System.Linq.Expressions.Expression.Assign(expr_4, expr_9); var expr_12 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_0, expr_4); // sum += x var expr_11 = global::System.Linq.Expressions.Expression.Assign(expr_0, expr_12); var expr_13 = global::System.Linq.Expressions.Expression.Block(expr_10, expr_11); - var expr_14 = global::System.Linq.Expressions.Expression.Call(expr_5, _m1); + var expr_14 = global::System.Linq.Expressions.Expression.Call(expr_5, typeof(global::System.Collections.IEnumerator).GetMethod("MoveNext", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_15 = global::System.Linq.Expressions.Expression.Break(expr_8); var expr_16 = global::System.Linq.Expressions.Expression.IfThenElse(expr_14, expr_13, expr_15); var expr_17 = global::System.Linq.Expressions.Expression.Loop(expr_16, expr_8); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForLoop_ArraySum.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForLoop_ArraySum.verified.txt index 7772230..588c459 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForLoop_ArraySum.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.ForLoop_ArraySum.verified.txt @@ -5,11 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Sum_P0_int__ + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::System.Array).GetProperty("Length"); - // [Expressive(AllowBlockBody = true)] // public int Sum(int[] arr) // { @@ -21,7 +18,7 @@ namespace ExpressiveSharp.Generated // // return sum; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Sum_P0_int___Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_arr = global::System.Linq.Expressions.Expression.Parameter(typeof(int[]), "arr"); @@ -32,7 +29,7 @@ namespace ExpressiveSharp.Generated var expr_5 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_6 = global::System.Linq.Expressions.Expression.Assign(expr_4, expr_5); var expr_7 = global::System.Linq.Expressions.Expression.Label("break"); - var expr_9 = global::System.Linq.Expressions.Expression.Property(p_arr, _p0); // arr.Length + var expr_9 = global::System.Linq.Expressions.Expression.Property(p_arr, typeof(global::System.Array).GetProperty("Length")); // arr.Length var expr_8 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.LessThan, expr_4, expr_9); var expr_11 = global::System.Linq.Expressions.Expression.ArrayIndex(p_arr, expr_4); // arr[i] var expr_12 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_0, expr_11); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.WhileLoop_EmitsBlockExpression.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.WhileLoop_EmitsBlockExpression.verified.txt index 5d3bfdb..1ee1e55 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.WhileLoop_EmitsBlockExpression.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/LoopTests.WhileLoop_EmitsBlockExpression.verified.txt @@ -5,8 +5,7 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Countdown_P0_int + static partial class Foo_C { // [Expressive(AllowBlockBody = true)] // public int Countdown(int n) @@ -20,7 +19,7 @@ namespace ExpressiveSharp.Generated // // return result; // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Countdown_P0_int_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_n = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "n"); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.BaseMemberExplicitReference.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.BaseMemberExplicitReference.verified.txt index 0d214d9..8db8dd2 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.BaseMemberExplicitReference.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.BaseMemberExplicitReference.verified.txt @@ -5,17 +5,14 @@ using Projectables.Repro; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Projectables_Repro_Derived_Bar + static partial class Projectables_Repro_Derived { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Projectables.Repro.Base).GetProperty("Foo"); - // [Expressive] // public string Bar => base.Foo; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Bar_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Projectables.Repro.Derived), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // base.Foo + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Projectables.Repro.Base).GetProperty("Foo")); // base.Foo return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.BaseMemberImplicitReference.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.BaseMemberImplicitReference.verified.txt index 523521e..fa9e98a 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.BaseMemberImplicitReference.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.BaseMemberImplicitReference.verified.txt @@ -5,17 +5,14 @@ using Projectables.Repro; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Projectables_Repro_Derived_Bar + static partial class Projectables_Repro_Derived { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Projectables.Repro.Base).GetProperty("Foo"); - // [Expressive] // public string Bar => Foo; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Bar_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Projectables.Repro.Derived), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Foo + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Projectables.Repro.Base).GetProperty("Foo")); // Foo return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.BaseMethodExplicitReference.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.BaseMethodExplicitReference.verified.txt index 548e782..12b9b30 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.BaseMethodExplicitReference.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.BaseMethodExplicitReference.verified.txt @@ -5,17 +5,14 @@ using Projectables.Repro; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Projectables_Repro_Derived_Bar + static partial class Projectables_Repro_Derived { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::Projectables.Repro.Base).GetMethod("Foo", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - // [Expressive] // public string Bar => base.Foo(); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Bar_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Projectables.Repro.Derived), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Call(p__this, _m0, global::System.Array.Empty()); // base.Foo() + var expr_0 = global::System.Linq.Expressions.Expression.Call(p__this, typeof(global::Projectables.Repro.Base).GetMethod("Foo", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null), global::System.Array.Empty()); // base.Foo() return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.Cast.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.Cast.verified.txt index a33d55a..26fd625 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.Cast.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.Cast.verified.txt @@ -5,18 +5,15 @@ using Projectables.Repro; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Projectables_Repro_SomeExtensions_AsSomeResult_P0_Projectables_Repro_SomeEntity + static partial class Projectables_Repro_SomeExtensions { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Projectables.Repro.SuperEntity).GetProperty("Superpower"); - // [Expressive] // public static string AsSomeResult(this SomeEntity e) => ((SuperEntity)e).Superpower; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> AsSomeResult_P0_Projectables_Repro_SomeEntity_Expression() { var p_e = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Projectables.Repro.SomeEntity), "e"); var expr_1 = global::System.Linq.Expressions.Expression.Convert(p_e, typeof(global::Projectables.Repro.SuperEntity)); // (SuperEntity)e - var expr_0 = global::System.Linq.Expressions.Expression.Property(expr_1, _p0); + var expr_0 = global::System.Linq.Expressions.Expression.Property(expr_1, typeof(global::Projectables.Repro.SuperEntity).GetProperty("Superpower")); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p_e); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.ConstMember.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.ConstMember.verified.txt index d36e298..59c9e1e 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.ConstMember.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.ConstMember.verified.txt @@ -5,19 +5,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Foo_IdWithBar + static partial class Foo_Foo { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Foo).GetProperty("Id"); - private static readonly global::System.Reflection.FieldInfo _f0 = typeof(global::Foo.Foo).GetField("Bar", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static); - // [Expressive] // public int IdWithBar() => Id + Bar; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> IdWithBar_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Foo), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Id - var expr_2 = global::System.Linq.Expressions.Expression.Field(null, _f0); // Bar + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Foo).GetProperty("Id")); // Id + var expr_2 = global::System.Linq.Expressions.Expression.Field(null, typeof(global::Foo.Foo).GetField("Bar", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static)); // Bar var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_1, expr_2); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.DeclarationTypeNamesAreGettingFullyQualified.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.DeclarationTypeNamesAreGettingFullyQualified.verified.txt index 807f6bd..1e048d6 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.DeclarationTypeNamesAreGettingFullyQualified.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.DeclarationTypeNamesAreGettingFullyQualified.verified.txt @@ -5,12 +5,11 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_EntityExtensions_Entity_Something_P0_Foo_EntityExtensions_Entity + static partial class Foo_EntityExtensions_Entity { // [Expressive] // public static Entity Something(Entity entity) => entity; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Something_P0_Foo_EntityExtensions_Entity_Expression() { var p_entity = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.EntityExtensions.Entity), "entity"); return global::System.Linq.Expressions.Expression.Lambda>(p_entity, p_entity); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.DefaultValuesGetRemoved.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.DefaultValuesGetRemoved.verified.txt index b22fac4..b2c8461 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.DefaultValuesGetRemoved.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.DefaultValuesGetRemoved.verified.txt @@ -4,12 +4,11 @@ namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _Foo_Calculate_P0_int + static partial class _Foo { // [Expressive] // public int Calculate(int i = 0) => i; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Calculate_P0_int_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo), "@this"); var p_i = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "i"); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.ExpressiveComputedMethodWithMultipleArguments.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.ExpressiveComputedMethodWithMultipleArguments.verified.txt index 10b1469..81c6414 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.ExpressiveComputedMethodWithMultipleArguments.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.ExpressiveComputedMethodWithMultipleArguments.verified.txt @@ -5,12 +5,11 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo_P0_int_P1_string_P2_object + static partial class Foo_C { // [Expressive] // public int Foo(int a, string b, object d) => a; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_P0_int_P1_string_P2_object_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_a = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "a"); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.ExpressiveComputedMethodWithSingleArgument.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.ExpressiveComputedMethodWithSingleArgument.verified.txt index 85359a4..b129dca 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.ExpressiveComputedMethodWithSingleArgument.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.ExpressiveComputedMethodWithSingleArgument.verified.txt @@ -5,12 +5,11 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo_P0_int + static partial class Foo_C { // [Expressive] // public int Foo(int i) => i; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_P0_int_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_i = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "i"); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.InheritedMembers.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.InheritedMembers.verified.txt index 1b5a8e0..5600f1c 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.InheritedMembers.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.InheritedMembers.verified.txt @@ -5,17 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Bar_ProjectedId + static partial class Foo_Bar { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Foo).GetProperty("Id"); - // [Expressive] // public int ProjectedId => Id; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> ProjectedId_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Bar), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Id + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Foo).GetProperty("Id")); // Id return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.IsOperator.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.IsOperator.verified.txt index b5a72c4..49e0a7e 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.IsOperator.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.IsOperator.verified.txt @@ -5,12 +5,11 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_A_IsB + static partial class Foo_A { // [Expressive] // public bool IsB => this is B; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> IsB_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.A), "@this"); var expr_0 = global::System.Linq.Expressions.Expression.TypeIs(p__this, typeof(global::Foo.B)); // this is B diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.MethodOverloads_WithDifferentParameterCounts.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.MethodOverloads_WithDifferentParameterCounts.verified.txt index 050a005..911d273 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.MethodOverloads_WithDifferentParameterCounts.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.MethodOverloads_WithDifferentParameterCounts.verified.txt @@ -6,12 +6,11 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Method_P0_int + static partial class Foo_C { // [Expressive] // public int Method(int x) => x; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Method_P0_int_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_x = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "x"); @@ -28,12 +27,11 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Method_P0_int_P1_int + static partial class Foo_C { // [Expressive] // public int Method(int x, int y) => x + y; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Method_P0_int_P1_int_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_x = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "x"); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.MethodOverloads_WithDifferentParameterTypes.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.MethodOverloads_WithDifferentParameterTypes.verified.txt index f4d8120..9f5073d 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.MethodOverloads_WithDifferentParameterTypes.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.MethodOverloads_WithDifferentParameterTypes.verified.txt @@ -6,12 +6,11 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Method_P0_int + static partial class Foo_C { // [Expressive] // public int Method(int x) => x; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Method_P0_int_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_x = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "x"); @@ -28,18 +27,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Method_P0_string + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(string).GetProperty("Length"); - // [Expressive] // public int Method(string s) => s.Length; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Method_P0_string_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_s = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "s"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p_s, _p0); // s.Length + var expr_0 = global::System.Linq.Expressions.Expression.Property(p_s, typeof(string).GetProperty("Length")); // s.Length return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this, p_s); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.ParamsModifierGetsRemoved.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.ParamsModifierGetsRemoved.verified.txt index a5fe9ce..c4f887a 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.ParamsModifierGetsRemoved.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.ParamsModifierGetsRemoved.verified.txt @@ -4,12 +4,11 @@ namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _Foo_First_P0_int__ + static partial class _Foo { // [Expressive] // public int First(params int[] all) => all[0]; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> First_P0_int___Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo), "@this"); var p_all = global::System.Linq.Expressions.Expression.Parameter(typeof(int[]), "all"); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.RequiredNamespace.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.RequiredNamespace.verified.txt index 97e225e..1c43f91 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.RequiredNamespace.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.RequiredNamespace.verified.txt @@ -5,18 +5,15 @@ using One.Two; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class One_Two_Bar_Method + static partial class One_Two_Bar { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::One.IntExtensions).GetMethod("AddOne", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(int) }, null); - // [Expressive] // public int Method() => 1.AddOne(); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Method_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::One.Two.Bar), "@this"); var expr_1 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 - var expr_0 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { expr_1 }); + var expr_0 = global::System.Linq.Expressions.Expression.Call(typeof(global::One.IntExtensions).GetMethod("AddOne", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(int) }, null), new global::System.Linq.Expressions.Expression[] { expr_1 }); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.SimpleExpressiveMethod.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.SimpleExpressiveMethod.verified.txt index 9bdf642..ad9f789 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.SimpleExpressiveMethod.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.SimpleExpressiveMethod.verified.txt @@ -5,12 +5,11 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { // [Expressive] // public int Foo() => 1; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var expr_0 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StaticMembers.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StaticMembers.verified.txt index d71f2e4..db8718f 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StaticMembers.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StaticMembers.verified.txt @@ -5,19 +5,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Foo_IdWithBar + static partial class Foo_Foo { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Foo).GetProperty("Id"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.Foo).GetProperty("Bar"); - // [Expressive] // public int IdWithBar() => Id + Bar; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> IdWithBar_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Foo), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Id - var expr_2 = global::System.Linq.Expressions.Expression.Property(null, _p1); // Bar + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Foo).GetProperty("Id")); // Id + var expr_2 = global::System.Linq.Expressions.Expression.Property(null, typeof(global::Foo.Foo).GetProperty("Bar")); // Bar var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_1, expr_2); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StaticMembers2.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StaticMembers2.verified.txt index 98e3d77..1802288 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StaticMembers2.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StaticMembers2.verified.txt @@ -5,19 +5,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Foo_IdWithBar + static partial class Foo_Foo { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Foo).GetProperty("Id"); - private static readonly global::System.Reflection.FieldInfo _f0 = typeof(global::Foo.Constants).GetField("Bar", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static); - // [Expressive] // public int IdWithBar() => Id + Constants.Bar; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> IdWithBar_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Foo), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Id - var expr_2 = global::System.Linq.Expressions.Expression.Field(null, _f0); // Constants.Bar + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Foo).GetProperty("Id")); // Id + var expr_2 = global::System.Linq.Expressions.Expression.Field(null, typeof(global::Foo.Constants).GetField("Bar", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static)); // Constants.Bar var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_1, expr_2); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StaticMethodWithNoParameters.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StaticMethodWithNoParameters.verified.txt index f851e3e..a200d9b 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StaticMethodWithNoParameters.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StaticMethodWithNoParameters.verified.txt @@ -4,12 +4,11 @@ namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _Foo_Zero + static partial class _Foo { // [Expressive] // public static int Zero() => 0; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Zero_Expression() { var expr_0 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 return global::System.Linq.Expressions.Expression.Lambda>(expr_0, global::System.Array.Empty()); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StaticMethodWithParameters.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StaticMethodWithParameters.verified.txt index 069e1ec..8d31734 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StaticMethodWithParameters.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StaticMethodWithParameters.verified.txt @@ -4,12 +4,11 @@ namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _Foo_Zero_P0_int + static partial class _Foo { // [Expressive] // public static int Zero(int x) => 0; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Zero_P0_int_Expression() { var p_x = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "x"); var expr_0 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StringInterpolationWithStaticCall_IsBeingRewritten.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StringInterpolationWithStaticCall_IsBeingRewritten.verified.txt index b7a4dba..8a95d68 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StringInterpolationWithStaticCall_IsBeingRewritten.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StringInterpolationWithStaticCall_IsBeingRewritten.verified.txt @@ -5,31 +5,24 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Status + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("ValidationDate"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::System.DateTime).GetMethod("op_Inequality", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::System.DateTime), typeof(global::System.DateTime) }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(global::Foo.MyExtensions).GetMethod("ToDateString", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::System.DateTime) }, null); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::System.DateTime?).GetProperty("Value"); - private static readonly global::System.Reflection.MethodInfo _m2 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null); - // [Expressive] // public string Status => ValidationDate != null ? $"Validation date : ({ValidationDate.Value.ToDateString()})" : ""; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Status_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // ValidationDate + var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("ValidationDate")); // ValidationDate var expr_4 = global::System.Linq.Expressions.Expression.Constant(null, typeof(object)); // null var expr_3 = global::System.Linq.Expressions.Expression.Convert(expr_4, typeof(global::System.DateTime?)); - var expr_1 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.NotEqual, expr_2, expr_3, false, _m0); + var expr_1 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.NotEqual, expr_2, expr_3, false, typeof(global::System.DateTime).GetMethod("op_Inequality", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::System.DateTime), typeof(global::System.DateTime) }, null)); var expr_5 = global::System.Linq.Expressions.Expression.Constant("Validation date : (", typeof(string)); // $"Validation date : ({ValidationDate.Value.ToDateString()})" - var expr_8 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // ValidationDate - var expr_7 = global::System.Linq.Expressions.Expression.Property(expr_8, _p1); - var expr_6 = global::System.Linq.Expressions.Expression.Call(_m1, new global::System.Linq.Expressions.Expression[] { expr_7 }); + var expr_8 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("ValidationDate")); // ValidationDate + var expr_7 = global::System.Linq.Expressions.Expression.Property(expr_8, typeof(global::System.DateTime?).GetProperty("Value")); + var expr_6 = global::System.Linq.Expressions.Expression.Call(typeof(global::Foo.MyExtensions).GetMethod("ToDateString", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(global::System.DateTime) }, null), new global::System.Linq.Expressions.Expression[] { expr_7 }); var expr_9 = global::System.Linq.Expressions.Expression.Constant(")", typeof(string)); - var expr_10 = global::System.Linq.Expressions.Expression.Call(_m2, expr_5, expr_6); - var expr_11 = global::System.Linq.Expressions.Expression.Call(_m2, expr_10, expr_9); + var expr_10 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_5, expr_6); + var expr_11 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_10, expr_9); var expr_12 = global::System.Linq.Expressions.Expression.Constant("", typeof(string)); // "" var expr_0 = global::System.Linq.Expressions.Expression.Condition(expr_1, expr_11, expr_12, typeof(string)); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StringInterpolation_FormatSpecifier.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StringInterpolation_FormatSpecifier.verified.txt index 504dbc8..d620f9f 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StringInterpolation_FormatSpecifier.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StringInterpolation_FormatSpecifier.verified.txt @@ -5,20 +5,16 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_FormattedPrice + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Price"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(double).GetMethod("ToString", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(string) }, null); - // [Expressive] // public string FormattedPrice => $"{Price:F2}"; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> FormattedPrice_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Price + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Price")); // Price var expr_1 = global::System.Linq.Expressions.Expression.Constant("F2", typeof(string)); - var expr_2 = global::System.Linq.Expressions.Expression.Call(expr_0, _m0, expr_1); + var expr_2 = global::System.Linq.Expressions.Expression.Call(expr_0, typeof(double).GetMethod("ToString", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(string) }, null), expr_1); return global::System.Linq.Expressions.Expression.Lambda>(expr_2, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StringInterpolation_LiteralOnly.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StringInterpolation_LiteralOnly.verified.txt index 14d2c44..14bdb13 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StringInterpolation_LiteralOnly.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StringInterpolation_LiteralOnly.verified.txt @@ -5,12 +5,11 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Greeting + static partial class Foo_C { // [Expressive] // public string Greeting => $"hello"; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Greeting_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var expr_0 = global::System.Linq.Expressions.Expression.Constant("hello", typeof(string)); // $"hello" diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StringInterpolation_MultiplePartsWithNullCoalescing.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StringInterpolation_MultiplePartsWithNullCoalescing.verified.txt index 4c54ead..e9884a3 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StringInterpolation_MultiplePartsWithNullCoalescing.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StringInterpolation_MultiplePartsWithNullCoalescing.verified.txt @@ -5,29 +5,23 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Summary + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Id"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(int).GetMethod("ToString", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.C).GetProperty("Tag"); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null); - // [Expressive] // public string Summary => $"#{Id}: {Tag ?? "N/A"}"; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Summary_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var expr_0 = global::System.Linq.Expressions.Expression.Constant("#", typeof(string)); // $"#{Id}: {Tag ?? "N/A"}" - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Id - var expr_2 = global::System.Linq.Expressions.Expression.Call(expr_1, _m0); + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Id")); // Id + var expr_2 = global::System.Linq.Expressions.Expression.Call(expr_1, typeof(int).GetMethod("ToString", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_3 = global::System.Linq.Expressions.Expression.Constant(": ", typeof(string)); - var expr_5 = global::System.Linq.Expressions.Expression.Property(p__this, _p1); // Tag + var expr_5 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Tag")); // Tag var expr_6 = global::System.Linq.Expressions.Expression.Constant("N/A", typeof(string)); // "N/A" var expr_4 = global::System.Linq.Expressions.Expression.Coalesce(expr_5, expr_6); - var expr_7 = global::System.Linq.Expressions.Expression.Call(_m1, expr_0, expr_2); - var expr_8 = global::System.Linq.Expressions.Expression.Call(_m1, expr_7, expr_3); - var expr_9 = global::System.Linq.Expressions.Expression.Call(_m1, expr_8, expr_4); + var expr_7 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_0, expr_2); + var expr_8 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_7, expr_3); + var expr_9 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_8, expr_4); return global::System.Linq.Expressions.Expression.Lambda>(expr_9, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StringInterpolation_SimpleIntProperty.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StringInterpolation_SimpleIntProperty.verified.txt index b28c541..180c72e 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StringInterpolation_SimpleIntProperty.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.StringInterpolation_SimpleIntProperty.verified.txt @@ -5,22 +5,17 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Label + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Id"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(int).GetMethod("ToString", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null); - // [Expressive] // public string Label => $"Id: {Id}"; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Label_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var expr_0 = global::System.Linq.Expressions.Expression.Constant("Id: ", typeof(string)); // $"Id: {Id}" - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Id - var expr_2 = global::System.Linq.Expressions.Expression.Call(expr_1, _m0); - var expr_3 = global::System.Linq.Expressions.Expression.Call(_m1, expr_0, expr_2); + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Id")); // Id + var expr_2 = global::System.Linq.Expressions.Expression.Call(expr_1, typeof(int).GetMethod("ToString", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); + var expr_3 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_0, expr_2); return global::System.Linq.Expressions.Expression.Lambda>(expr_3, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.TypesInBodyGetsFullyQualified.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.TypesInBodyGetsFullyQualified.verified.txt index 9c83ca9..864cbce 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.TypesInBodyGetsFullyQualified.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/MethodTests.TypesInBodyGetsFullyQualified.verified.txt @@ -5,22 +5,17 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "Count" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 1)).MakeGenericMethod(typeof(global::Foo.D)); - private static readonly global::System.Reflection.MethodInfo _m1 = global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "OfType" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 1)).MakeGenericMethod(typeof(global::Foo.D)); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Dees"); - // [Expressive] // public int Foo => Dees.OfType().Count(); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_3 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Dees + var expr_3 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Dees")); // Dees var expr_2 = global::System.Linq.Expressions.Expression.Convert(expr_3, typeof(global::System.Collections.IEnumerable)); - var expr_1 = global::System.Linq.Expressions.Expression.Call(_m1, new global::System.Linq.Expressions.Expression[] { expr_2 }); - var expr_0 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { expr_1 }); + var expr_1 = global::System.Linq.Expressions.Expression.Call(global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "OfType" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 1)).MakeGenericMethod(typeof(global::Foo.D)), new global::System.Linq.Expressions.Expression[] { expr_2 }); + var expr_0 = global::System.Linq.Expressions.Expression.Call(global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "Count" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 1)).MakeGenericMethod(typeof(global::Foo.D)), new global::System.Linq.Expressions.Expression[] { expr_1 }); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.BooleanSimpleTernary_WithRewriteSupport_IsBeingRewritten.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.BooleanSimpleTernary_WithRewriteSupport_IsBeingRewritten.verified.txt index 084ae07..abd40d8 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.BooleanSimpleTernary_WithRewriteSupport_IsBeingRewritten.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.BooleanSimpleTernary_WithRewriteSupport_IsBeingRewritten.verified.txt @@ -5,19 +5,16 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Test_P0_object + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(object).GetMethod("Equals", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(object) }, null); - // [Expressive] // public static bool Test(this object? x) => x?.Equals(4) == false; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Test_P0_object_Expression() { var p_x = global::System.Linq.Expressions.Expression.Parameter(typeof(object), "x"); var expr_3 = global::System.Linq.Expressions.Expression.Constant(4, typeof(int)); // 4 var expr_2 = global::System.Linq.Expressions.Expression.Convert(expr_3, typeof(object)); - var expr_1 = global::System.Linq.Expressions.Expression.Call(p_x, _m0, new global::System.Linq.Expressions.Expression[] { expr_2 }); + var expr_1 = global::System.Linq.Expressions.Expression.Call(p_x, typeof(object).GetMethod("Equals", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(object) }, null), new global::System.Linq.Expressions.Expression[] { expr_2 }); var expr_4 = global::System.Linq.Expressions.Expression.Convert(expr_1, typeof(bool?)); var expr_6 = global::System.Linq.Expressions.Expression.Constant(null, typeof(object)); var expr_7 = global::System.Linq.Expressions.Expression.NotEqual(p_x, expr_6); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.GenericNullableReferenceTypesAreBeingEliminated.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.GenericNullableReferenceTypesAreBeingEliminated.verified.txt index 62c42fd..f3c57ef 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.GenericNullableReferenceTypesAreBeingEliminated.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.GenericNullableReferenceTypesAreBeingEliminated.verified.txt @@ -5,12 +5,11 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_NextFoo_P0_System_Collections_Generic_List_object__P1_System_Collections_Generic_List_int__ + static partial class Foo_C { // [Expressive] // public static List NextFoo(this List input, List nullablePrimitiveArgument) => input; - static global::System.Linq.Expressions.Expression, global::System.Collections.Generic.List, global::System.Collections.Generic.List>> Expression() + static global::System.Linq.Expressions.Expression, global::System.Collections.Generic.List, global::System.Collections.Generic.List>> NextFoo_P0_System_Collections_Generic_List_object__P1_System_Collections_Generic_List_int___Expression() { var p_input = global::System.Linq.Expressions.Expression.Parameter(typeof(global::System.Collections.Generic.List), "input"); var p_nullablePrimitiveArgument = global::System.Linq.Expressions.Expression.Parameter(typeof(global::System.Collections.Generic.List), "nullablePrimitiveArgument"); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullConditionalNullCoalesceTypeConversion.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullConditionalNullCoalesceTypeConversion.verified.txt index 94e24d5..f86a949 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullConditionalNullCoalesceTypeConversion.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullConditionalNullCoalesceTypeConversion.verified.txt @@ -4,17 +4,14 @@ namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _Foo_SomeNumber_P0_Foo + static partial class _Foo { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo).GetProperty("FancyNumber"); - // [Expressive] // public static int SomeNumber(Foo fancyClass) => fancyClass?.FancyNumber ?? 3; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> SomeNumber_P0_Foo_Expression() { var p_fancyClass = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo), "fancyClass"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p_fancyClass, _p0); // .FancyNumber + var expr_1 = global::System.Linq.Expressions.Expression.Property(p_fancyClass, typeof(global::Foo).GetProperty("FancyNumber")); // .FancyNumber var expr_3 = global::System.Linq.Expressions.Expression.Constant(null, typeof(global::Foo)); var expr_4 = global::System.Linq.Expressions.Expression.NotEqual(p_fancyClass, expr_3); var expr_5 = global::System.Linq.Expressions.Expression.Default(typeof(int?)); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableElementAndMemberBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableElementAndMemberBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt index e21aa3b..c87d20b 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableElementAndMemberBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableElementAndMemberBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt @@ -5,19 +5,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_EntityExtensions_GetFirstRelatedIgnoreNulls_P0_Foo_EntityExtensions_Entity + static partial class Foo_EntityExtensions { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.EntityExtensions.Entity).GetProperty("RelatedEntities"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::System.Collections.Generic.List).GetProperty("this[]"); - // [Expressive] // public static Entity GetFirstRelatedIgnoreNulls(this Entity entity) => entity?.RelatedEntities?[0]; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> GetFirstRelatedIgnoreNulls_P0_Foo_EntityExtensions_Entity_Expression() { var p_entity = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.EntityExtensions.Entity), "entity"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p_entity, _p0); // .RelatedEntities - var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_0, _p1); // [0] + var expr_0 = global::System.Linq.Expressions.Expression.Property(p_entity, typeof(global::Foo.EntityExtensions.Entity).GetProperty("RelatedEntities")); // .RelatedEntities + var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_0, typeof(global::System.Collections.Generic.List).GetProperty("this[]")); // [0] var expr_3 = global::System.Linq.Expressions.Expression.Constant(null, typeof(global::System.Collections.Generic.List)); var expr_4 = global::System.Linq.Expressions.Expression.NotEqual(expr_0, expr_3); var expr_5 = global::System.Linq.Expressions.Expression.Default(typeof(global::Foo.EntityExtensions.Entity)); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableElementAndMemberBinding_WithRewriteSupport_IsBeingRewritten.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableElementAndMemberBinding_WithRewriteSupport_IsBeingRewritten.verified.txt index e21aa3b..c87d20b 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableElementAndMemberBinding_WithRewriteSupport_IsBeingRewritten.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableElementAndMemberBinding_WithRewriteSupport_IsBeingRewritten.verified.txt @@ -5,19 +5,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_EntityExtensions_GetFirstRelatedIgnoreNulls_P0_Foo_EntityExtensions_Entity + static partial class Foo_EntityExtensions { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.EntityExtensions.Entity).GetProperty("RelatedEntities"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::System.Collections.Generic.List).GetProperty("this[]"); - // [Expressive] // public static Entity GetFirstRelatedIgnoreNulls(this Entity entity) => entity?.RelatedEntities?[0]; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> GetFirstRelatedIgnoreNulls_P0_Foo_EntityExtensions_Entity_Expression() { var p_entity = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.EntityExtensions.Entity), "entity"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p_entity, _p0); // .RelatedEntities - var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_0, _p1); // [0] + var expr_0 = global::System.Linq.Expressions.Expression.Property(p_entity, typeof(global::Foo.EntityExtensions.Entity).GetProperty("RelatedEntities")); // .RelatedEntities + var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_0, typeof(global::System.Collections.Generic.List).GetProperty("this[]")); // [0] var expr_3 = global::System.Linq.Expressions.Expression.Constant(null, typeof(global::System.Collections.Generic.List)); var expr_4 = global::System.Linq.Expressions.Expression.NotEqual(expr_0, expr_3); var expr_5 = global::System.Linq.Expressions.Expression.Default(typeof(global::Foo.EntityExtensions.Entity)); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableElementBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableElementBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt index ff7e9ba..f97f878 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableElementBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableElementBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt @@ -5,19 +5,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_GetFirst_P0_string + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(char).GetMethod("ToString", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(string).GetProperty("this[]"); - // [Expressive] // public static string? GetFirst(this string input) => input?[0].ToString(); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> GetFirst_P0_string_Expression() { var p_input = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "input"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p_input, _p0); // [0] - var expr_0 = global::System.Linq.Expressions.Expression.Call(expr_1, _m0, global::System.Array.Empty()); + var expr_1 = global::System.Linq.Expressions.Expression.Property(p_input, typeof(string).GetProperty("this[]")); // [0] + var expr_0 = global::System.Linq.Expressions.Expression.Call(expr_1, typeof(char).GetMethod("ToString", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null), global::System.Array.Empty()); var expr_3 = global::System.Linq.Expressions.Expression.Constant(null, typeof(string)); var expr_4 = global::System.Linq.Expressions.Expression.NotEqual(p_input, expr_3); var expr_5 = global::System.Linq.Expressions.Expression.Default(typeof(string)); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableElementBinding_WithRewriteSupport_IsBeingRewritten.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableElementBinding_WithRewriteSupport_IsBeingRewritten.verified.txt index ff7e9ba..f97f878 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableElementBinding_WithRewriteSupport_IsBeingRewritten.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableElementBinding_WithRewriteSupport_IsBeingRewritten.verified.txt @@ -5,19 +5,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_GetFirst_P0_string + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(char).GetMethod("ToString", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(string).GetProperty("this[]"); - // [Expressive] // public static string? GetFirst(this string input) => input?[0].ToString(); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> GetFirst_P0_string_Expression() { var p_input = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "input"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p_input, _p0); // [0] - var expr_0 = global::System.Linq.Expressions.Expression.Call(expr_1, _m0, global::System.Array.Empty()); + var expr_1 = global::System.Linq.Expressions.Expression.Property(p_input, typeof(string).GetProperty("this[]")); // [0] + var expr_0 = global::System.Linq.Expressions.Expression.Call(expr_1, typeof(char).GetMethod("ToString", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null), global::System.Array.Empty()); var expr_3 = global::System.Linq.Expressions.Expression.Constant(null, typeof(string)); var expr_4 = global::System.Linq.Expressions.Expression.NotEqual(p_input, expr_3); var expr_5 = global::System.Linq.Expressions.Expression.Default(typeof(string)); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableMemberBinding_WithDisableFlag_StillGenerates.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableMemberBinding_WithDisableFlag_StillGenerates.verified.txt index 86e6218..83400de 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableMemberBinding_WithDisableFlag_StillGenerates.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableMemberBinding_WithDisableFlag_StillGenerates.verified.txt @@ -5,17 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_GetLength_P0_string + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(string).GetProperty("Length"); - // [Expressive] // public static int? GetLength(this string input) => input?.Length; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> GetLength_P0_string_Expression() { var p_input = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "input"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p_input, _p0); // .Length + var expr_0 = global::System.Linq.Expressions.Expression.Property(p_input, typeof(string).GetProperty("Length")); // .Length var expr_1 = global::System.Linq.Expressions.Expression.Convert(expr_0, typeof(int?)); var expr_3 = global::System.Linq.Expressions.Expression.Constant(null, typeof(string)); var expr_4 = global::System.Linq.Expressions.Expression.NotEqual(p_input, expr_3); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableMemberBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableMemberBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt index 86e6218..83400de 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableMemberBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableMemberBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt @@ -5,17 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_GetLength_P0_string + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(string).GetProperty("Length"); - // [Expressive] // public static int? GetLength(this string input) => input?.Length; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> GetLength_P0_string_Expression() { var p_input = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "input"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p_input, _p0); // .Length + var expr_0 = global::System.Linq.Expressions.Expression.Property(p_input, typeof(string).GetProperty("Length")); // .Length var expr_1 = global::System.Linq.Expressions.Expression.Convert(expr_0, typeof(int?)); var expr_3 = global::System.Linq.Expressions.Expression.Constant(null, typeof(string)); var expr_4 = global::System.Linq.Expressions.Expression.NotEqual(p_input, expr_3); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableMemberBinding_WithRewriteSupport_IsBeingRewritten.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableMemberBinding_WithRewriteSupport_IsBeingRewritten.verified.txt index 86e6218..83400de 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableMemberBinding_WithRewriteSupport_IsBeingRewritten.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableMemberBinding_WithRewriteSupport_IsBeingRewritten.verified.txt @@ -5,17 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_GetLength_P0_string + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(string).GetProperty("Length"); - // [Expressive] // public static int? GetLength(this string input) => input?.Length; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> GetLength_P0_string_Expression() { var p_input = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "input"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p_input, _p0); // .Length + var expr_0 = global::System.Linq.Expressions.Expression.Property(p_input, typeof(string).GetProperty("Length")); // .Length var expr_1 = global::System.Linq.Expressions.Expression.Convert(expr_0, typeof(int?)); var expr_3 = global::System.Linq.Expressions.Expression.Constant(null, typeof(string)); var expr_4 = global::System.Linq.Expressions.Expression.NotEqual(p_input, expr_3); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableParameters_WithRewriteSupport_IsBeingRewritten.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableParameters_WithRewriteSupport_IsBeingRewritten.verified.txt index 6325bba..9628324 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableParameters_WithRewriteSupport_IsBeingRewritten.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableParameters_WithRewriteSupport_IsBeingRewritten.verified.txt @@ -5,22 +5,17 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_EntityExtensions_GetFirstName_P0_Foo_EntityExtensions_Entity + static partial class Foo_EntityExtensions { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.EntityExtensions.Entity).GetProperty("FullName"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("Substring", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int) }, null); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(string).GetMethod("IndexOf", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(char) }, null); - // [Expressive] // public static string GetFirstName(this Entity entity) => entity.FullName?.Substring(entity.FullName?.IndexOf(' ') ?? 0); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> GetFirstName_P0_Foo_EntityExtensions_Entity_Expression() { var p_entity = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.EntityExtensions.Entity), "entity"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p_entity, _p0); // entity.FullName - var expr_3 = global::System.Linq.Expressions.Expression.Property(p_entity, _p0); // entity.FullName + var expr_0 = global::System.Linq.Expressions.Expression.Property(p_entity, typeof(global::Foo.EntityExtensions.Entity).GetProperty("FullName")); // entity.FullName + var expr_3 = global::System.Linq.Expressions.Expression.Property(p_entity, typeof(global::Foo.EntityExtensions.Entity).GetProperty("FullName")); // entity.FullName var expr_5 = global::System.Linq.Expressions.Expression.Constant(' ', typeof(char)); // ' ' - var expr_4 = global::System.Linq.Expressions.Expression.Call(expr_3, _m1, new global::System.Linq.Expressions.Expression[] { expr_5 }); + var expr_4 = global::System.Linq.Expressions.Expression.Call(expr_3, typeof(string).GetMethod("IndexOf", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(char) }, null), new global::System.Linq.Expressions.Expression[] { expr_5 }); var expr_6 = global::System.Linq.Expressions.Expression.Convert(expr_4, typeof(int?)); var expr_8 = global::System.Linq.Expressions.Expression.Constant(null, typeof(string)); var expr_9 = global::System.Linq.Expressions.Expression.NotEqual(expr_3, expr_8); @@ -28,7 +23,7 @@ namespace ExpressiveSharp.Generated var expr_7 = global::System.Linq.Expressions.Expression.Condition(expr_9, expr_6, expr_10, typeof(int?)); var expr_11 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_2 = global::System.Linq.Expressions.Expression.Coalesce(expr_7, expr_11); - var expr_1 = global::System.Linq.Expressions.Expression.Call(expr_0, _m0, new global::System.Linq.Expressions.Expression[] { expr_2 }); + var expr_1 = global::System.Linq.Expressions.Expression.Call(expr_0, typeof(string).GetMethod("Substring", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { typeof(int) }, null), new global::System.Linq.Expressions.Expression[] { expr_2 }); var expr_13 = global::System.Linq.Expressions.Expression.Constant(null, typeof(string)); var expr_14 = global::System.Linq.Expressions.Expression.NotEqual(expr_0, expr_13); var expr_15 = global::System.Linq.Expressions.Expression.Default(typeof(string)); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableReferenceTypeCastOperatorGetsEliminated.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableReferenceTypeCastOperatorGetsEliminated.verified.txt index d0f9d5a..e4e0846 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableReferenceTypeCastOperatorGetsEliminated.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableReferenceTypeCastOperatorGetsEliminated.verified.txt @@ -5,12 +5,11 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_NullableReferenceType_P0_object + static partial class Foo_C { // [Expressive] // public static string? NullableReferenceType(object? input) => (string? )input; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> NullableReferenceType_P0_object_Expression() { var p_input = global::System.Linq.Expressions.Expression.Parameter(typeof(object), "input"); var expr_0 = global::System.Linq.Expressions.Expression.Convert(p_input, typeof(string)); // (string?)input diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableReferenceTypesAreBeingEliminated.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableReferenceTypesAreBeingEliminated.verified.txt index 48611bf..ac561ba 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableReferenceTypesAreBeingEliminated.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableReferenceTypesAreBeingEliminated.verified.txt @@ -5,12 +5,11 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_NextFoo_P0_object_P1_int_ + static partial class Foo_C { // [Expressive] // public static object? NextFoo(this object? unusedArgument, int? nullablePrimitiveArgument) => null; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> NextFoo_P0_object_P1_int__Expression() { var p_unusedArgument = global::System.Linq.Expressions.Expression.Parameter(typeof(object), "unusedArgument"); var p_nullablePrimitiveArgument = global::System.Linq.Expressions.Expression.Parameter(typeof(int?), "nullablePrimitiveArgument"); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableSimpleElementBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableSimpleElementBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt index 852833c..96f2566 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableSimpleElementBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableSimpleElementBinding_WithIgnoreSupport_IsBeingRewritten.verified.txt @@ -5,17 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_GetFirst_P0_string + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(string).GetProperty("this[]"); - // [Expressive] // public static char? GetFirst(this string input) => input?[0]; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> GetFirst_P0_string_Expression() { var p_input = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "input"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p_input, _p0); // [0] + var expr_0 = global::System.Linq.Expressions.Expression.Property(p_input, typeof(string).GetProperty("this[]")); // [0] var expr_1 = global::System.Linq.Expressions.Expression.Convert(expr_0, typeof(char?)); var expr_3 = global::System.Linq.Expressions.Expression.Constant(null, typeof(string)); var expr_4 = global::System.Linq.Expressions.Expression.NotEqual(p_input, expr_3); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableSimpleElementBinding_WithRewriteSupport_IsBeingRewritten.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableSimpleElementBinding_WithRewriteSupport_IsBeingRewritten.verified.txt index 852833c..96f2566 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableSimpleElementBinding_WithRewriteSupport_IsBeingRewritten.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableSimpleElementBinding_WithRewriteSupport_IsBeingRewritten.verified.txt @@ -5,17 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_GetFirst_P0_string + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(string).GetProperty("this[]"); - // [Expressive] // public static char? GetFirst(this string input) => input?[0]; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> GetFirst_P0_string_Expression() { var p_input = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "input"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p_input, _p0); // [0] + var expr_0 = global::System.Linq.Expressions.Expression.Property(p_input, typeof(string).GetProperty("this[]")); // [0] var expr_1 = global::System.Linq.Expressions.Expression.Convert(expr_0, typeof(char?)); var expr_3 = global::System.Linq.Expressions.Expression.Constant(null, typeof(string)); var expr_4 = global::System.Linq.Expressions.Expression.NotEqual(p_input, expr_3); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableValueCastOperatorsPersist.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableValueCastOperatorsPersist.verified.txt index 8076dba..340df0b 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableValueCastOperatorsPersist.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableValueCastOperatorsPersist.verified.txt @@ -5,12 +5,11 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_NullableValueType_P0_object + static partial class Foo_C { // [Expressive] // public static int? NullableValueType(object? input) => (int? )input; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> NullableValueType_P0_object_Expression() { var p_input = global::System.Linq.Expressions.Expression.Parameter(typeof(object), "input"); var expr_0 = global::System.Linq.Expressions.Expression.Convert(p_input, typeof(int?)); // (int?)input diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableValueType_MemberAccessWithCoalesce_WithRewriteSupport_IsBeingRewritten.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableValueType_MemberAccessWithCoalesce_WithRewriteSupport_IsBeingRewritten.verified.txt index d8a581a..a32eb0e 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableValueType_MemberAccessWithCoalesce_WithRewriteSupport_IsBeingRewritten.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableValueType_MemberAccessWithCoalesce_WithRewriteSupport_IsBeingRewritten.verified.txt @@ -5,18 +5,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_GetX_P0_Foo_Point_ + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Point).GetProperty("X"); - // [Expressive] // public static double GetX(this Point? point) => point?.X ?? 0.0; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> GetX_P0_Foo_Point__Expression() { var p_point = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Point?), "point"); var expr_1 = global::System.Linq.Expressions.Expression.Property(p_point, typeof(global::Foo.Point?).GetProperty("Value")); // point?.X - var expr_2 = global::System.Linq.Expressions.Expression.Property(expr_1, _p0); // .X + var expr_2 = global::System.Linq.Expressions.Expression.Property(expr_1, typeof(global::Foo.Point).GetProperty("X")); // .X var expr_3 = global::System.Linq.Expressions.Expression.Convert(expr_2, typeof(double?)); var expr_5 = global::System.Linq.Expressions.Expression.Constant(null, typeof(global::Foo.Point?)); var expr_6 = global::System.Linq.Expressions.Expression.NotEqual(p_point, expr_5); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableValueType_MemberAccess_WithIgnoreSupport_IsBeingRewritten.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableValueType_MemberAccess_WithIgnoreSupport_IsBeingRewritten.verified.txt index 7bbb680..2968c16 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableValueType_MemberAccess_WithIgnoreSupport_IsBeingRewritten.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableValueType_MemberAccess_WithIgnoreSupport_IsBeingRewritten.verified.txt @@ -5,18 +5,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_GetX_P0_Foo_Point_ + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Point).GetProperty("X"); - // [Expressive] // public static double? GetX(this Point? point) => point?.X; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> GetX_P0_Foo_Point__Expression() { var p_point = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Point?), "point"); var expr_0 = global::System.Linq.Expressions.Expression.Property(p_point, typeof(global::Foo.Point?).GetProperty("Value")); // point?.X - var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_0, _p0); // .X + var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_0, typeof(global::Foo.Point).GetProperty("X")); // .X var expr_2 = global::System.Linq.Expressions.Expression.Convert(expr_1, typeof(double?)); var expr_4 = global::System.Linq.Expressions.Expression.Constant(null, typeof(global::Foo.Point?)); var expr_5 = global::System.Linq.Expressions.Expression.NotEqual(p_point, expr_4); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableValueType_MemberAccess_WithRewriteSupport_IsBeingRewritten.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableValueType_MemberAccess_WithRewriteSupport_IsBeingRewritten.verified.txt index 7bbb680..2968c16 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableValueType_MemberAccess_WithRewriteSupport_IsBeingRewritten.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/NullableTests.NullableValueType_MemberAccess_WithRewriteSupport_IsBeingRewritten.verified.txt @@ -5,18 +5,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_GetX_P0_Foo_Point_ + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Point).GetProperty("X"); - // [Expressive] // public static double? GetX(this Point? point) => point?.X; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> GetX_P0_Foo_Point__Expression() { var p_point = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Point?), "point"); var expr_0 = global::System.Linq.Expressions.Expression.Property(p_point, typeof(global::Foo.Point?).GetProperty("Value")); // point?.X - var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_0, _p0); // .X + var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_0, typeof(global::Foo.Point).GetProperty("X")); // .X var expr_2 = global::System.Linq.Expressions.Expression.Convert(expr_1, typeof(double?)); var expr_4 = global::System.Linq.Expressions.Expression.Constant(null, typeof(global::Foo.Point?)); var expr_5 = global::System.Linq.Expressions.Expression.NotEqual(p_point, expr_4); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PositionalPatternTests.IsExpression_PositionalPatternWithRelationalSubPatterns.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PositionalPatternTests.IsExpression_PositionalPatternWithRelationalSubPatterns.verified.txt index c375a25..b0d2f14 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PositionalPatternTests.IsExpression_PositionalPatternWithRelationalSubPatterns.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PositionalPatternTests.IsExpression_PositionalPatternWithRelationalSubPatterns.verified.txt @@ -4,24 +4,20 @@ namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _Foo_IsInFirstQuadrant_P0_Point + static partial class _Foo { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Point).GetProperty("X"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Point).GetProperty("Y"); - // [Expressive] // public bool IsInFirstQuadrant(Point point) => point is Point (> 0, > 0); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> IsInFirstQuadrant_P0_Point_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo), "@this"); var p_point = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Point), "point"); var expr_1 = global::System.Linq.Expressions.Expression.Constant(null, typeof(global::Point)); // point is Point(> 0, > 0) var expr_0 = global::System.Linq.Expressions.Expression.NotEqual(p_point, expr_1); - var expr_2 = global::System.Linq.Expressions.Expression.Property(p_point, _p0); + var expr_2 = global::System.Linq.Expressions.Expression.Property(p_point, typeof(global::Point).GetProperty("X")); var expr_4 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_3 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThan, expr_2, expr_4); - var expr_5 = global::System.Linq.Expressions.Expression.Property(p_point, _p1); + var expr_5 = global::System.Linq.Expressions.Expression.Property(p_point, typeof(global::Point).GetProperty("Y")); var expr_7 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_6 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThan, expr_5, expr_7); var expr_8 = global::System.Linq.Expressions.Expression.AndAlso(expr_0, expr_3); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PositionalPatternTests.IsExpression_RecordPositionalPattern.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PositionalPatternTests.IsExpression_RecordPositionalPattern.verified.txt index ef33cc0..7a298fa 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PositionalPatternTests.IsExpression_RecordPositionalPattern.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PositionalPatternTests.IsExpression_RecordPositionalPattern.verified.txt @@ -4,24 +4,20 @@ namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _Foo_IsOrigin_P0_Point + static partial class _Foo { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Point).GetProperty("X"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Point).GetProperty("Y"); - // [Expressive] // public bool IsOrigin(Point point) => point is Point (0, 0); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> IsOrigin_P0_Point_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo), "@this"); var p_point = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Point), "point"); var expr_1 = global::System.Linq.Expressions.Expression.Constant(null, typeof(global::Point)); // point is Point(0, 0) var expr_0 = global::System.Linq.Expressions.Expression.NotEqual(p_point, expr_1); - var expr_2 = global::System.Linq.Expressions.Expression.Property(p_point, _p0); + var expr_2 = global::System.Linq.Expressions.Expression.Property(p_point, typeof(global::Point).GetProperty("X")); var expr_4 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_3 = global::System.Linq.Expressions.Expression.Equal(expr_2, expr_4); - var expr_5 = global::System.Linq.Expressions.Expression.Property(p_point, _p1); + var expr_5 = global::System.Linq.Expressions.Expression.Property(p_point, typeof(global::Point).GetProperty("Y")); var expr_7 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_6 = global::System.Linq.Expressions.Expression.Equal(expr_5, expr_7); var expr_8 = global::System.Linq.Expressions.Expression.AndAlso(expr_0, expr_3); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PositionalPatternTests.IsExpression_RecordStructPositionalPattern.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PositionalPatternTests.IsExpression_RecordStructPositionalPattern.verified.txt index a5ee50e..f99971b 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PositionalPatternTests.IsExpression_RecordStructPositionalPattern.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PositionalPatternTests.IsExpression_RecordStructPositionalPattern.verified.txt @@ -4,22 +4,18 @@ namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _Foo_IsOrigin_P0_Point + static partial class _Foo { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Point).GetProperty("X"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Point).GetProperty("Y"); - // [Expressive] // public bool IsOrigin(Point point) => point is Point (0, 0); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> IsOrigin_P0_Point_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo), "@this"); var p_point = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Point), "point"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p_point, _p0); // point is Point(0, 0) + var expr_0 = global::System.Linq.Expressions.Expression.Property(p_point, typeof(global::Point).GetProperty("X")); // point is Point(0, 0) var expr_2 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_1 = global::System.Linq.Expressions.Expression.Equal(expr_0, expr_2); - var expr_3 = global::System.Linq.Expressions.Expression.Property(p_point, _p1); + var expr_3 = global::System.Linq.Expressions.Expression.Property(p_point, typeof(global::Point).GetProperty("Y")); var expr_5 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_4 = global::System.Linq.Expressions.Expression.Equal(expr_3, expr_5); var expr_6 = global::System.Linq.Expressions.Expression.AndAlso(expr_1, expr_4); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PositionalPatternTests.SwitchExpression_RecordPositionalPattern.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PositionalPatternTests.SwitchExpression_RecordPositionalPattern.verified.txt index 4ab182a..0212b3b 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PositionalPatternTests.SwitchExpression_RecordPositionalPattern.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PositionalPatternTests.SwitchExpression_RecordPositionalPattern.verified.txt @@ -4,12 +4,8 @@ namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _PointExtensions_Describe_P0_Point + static partial class _PointExtensions { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Point).GetProperty("X"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Point).GetProperty("Y"); - // [Expressive] // public static string Describe(this Point point) => point switch // { @@ -18,13 +14,13 @@ namespace ExpressiveSharp.Generated // Point (0, _) => "y-axis", // _ => "other", // }; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Describe_P0_Point_Expression() { var p_point = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Point), "point"); var expr_0 = global::System.Linq.Expressions.Expression.Constant("other", typeof(string)); // "other" var expr_2 = global::System.Linq.Expressions.Expression.Constant(null, typeof(global::Point)); var expr_1 = global::System.Linq.Expressions.Expression.NotEqual(p_point, expr_2); - var expr_3 = global::System.Linq.Expressions.Expression.Property(p_point, _p0); + var expr_3 = global::System.Linq.Expressions.Expression.Property(p_point, typeof(global::Point).GetProperty("X")); var expr_5 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_4 = global::System.Linq.Expressions.Expression.Equal(expr_3, expr_5); var expr_6 = global::System.Linq.Expressions.Expression.AndAlso(expr_1, expr_4); @@ -32,7 +28,7 @@ namespace ExpressiveSharp.Generated var expr_8 = global::System.Linq.Expressions.Expression.Condition(expr_6, expr_7, expr_0, typeof(string)); var expr_10 = global::System.Linq.Expressions.Expression.Constant(null, typeof(global::Point)); var expr_9 = global::System.Linq.Expressions.Expression.NotEqual(p_point, expr_10); - var expr_11 = global::System.Linq.Expressions.Expression.Property(p_point, _p1); + var expr_11 = global::System.Linq.Expressions.Expression.Property(p_point, typeof(global::Point).GetProperty("Y")); var expr_13 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_12 = global::System.Linq.Expressions.Expression.Equal(expr_11, expr_13); var expr_14 = global::System.Linq.Expressions.Expression.AndAlso(expr_9, expr_12); @@ -40,10 +36,10 @@ namespace ExpressiveSharp.Generated var expr_16 = global::System.Linq.Expressions.Expression.Condition(expr_14, expr_15, expr_8, typeof(string)); var expr_18 = global::System.Linq.Expressions.Expression.Constant(null, typeof(global::Point)); var expr_17 = global::System.Linq.Expressions.Expression.NotEqual(p_point, expr_18); - var expr_19 = global::System.Linq.Expressions.Expression.Property(p_point, _p0); + var expr_19 = global::System.Linq.Expressions.Expression.Property(p_point, typeof(global::Point).GetProperty("X")); var expr_21 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_20 = global::System.Linq.Expressions.Expression.Equal(expr_19, expr_21); - var expr_22 = global::System.Linq.Expressions.Expression.Property(p_point, _p1); + var expr_22 = global::System.Linq.Expressions.Expression.Property(p_point, typeof(global::Point).GetProperty("Y")); var expr_24 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_23 = global::System.Linq.Expressions.Expression.Equal(expr_22, expr_24); var expr_25 = global::System.Linq.Expressions.Expression.AndAlso(expr_17, expr_20); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressiveComputedPropertyMethod.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressiveComputedPropertyMethod.verified.txt index 3698c5b..f2d83a7 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressiveComputedPropertyMethod.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressiveComputedPropertyMethod.verified.txt @@ -5,17 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::Foo.C).GetMethod("Bar", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - // [Expressive] // public int Foo => Bar(); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Call(p__this, _m0, global::System.Array.Empty()); // Bar() + var expr_0 = global::System.Linq.Expressions.Expression.Call(p__this, typeof(global::Foo.C).GetMethod("Bar", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null), global::System.Array.Empty()); // Bar() return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressiveComputedPropertyUsingThis.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressiveComputedPropertyUsingThis.verified.txt index a0be031..60e52fd 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressiveComputedPropertyUsingThis.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressiveComputedPropertyUsingThis.verified.txt @@ -5,17 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Bar"); - // [Expressive] // public int Foo => this.Bar; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // this.Bar + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Bar")); // this.Bar return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressiveComputedPropertyWithExplicitBlockGetter.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressiveComputedPropertyWithExplicitBlockGetter.verified.txt index 23c6a36..42a03d7 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressiveComputedPropertyWithExplicitBlockGetter.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressiveComputedPropertyWithExplicitBlockGetter.verified.txt @@ -5,11 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Bar"); - // [Expressive(AllowBlockBody = true)] // public int Foo // { @@ -18,10 +15,10 @@ namespace ExpressiveSharp.Generated // return Bar + 1; // } // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Bar + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Bar")); // Bar var expr_2 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_1, expr_2); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressiveComputedPropertyWithExplicitExpressionGetter.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressiveComputedPropertyWithExplicitExpressionGetter.verified.txt index 1582904..3e93f65 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressiveComputedPropertyWithExplicitExpressionGetter.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressiveComputedPropertyWithExplicitExpressionGetter.verified.txt @@ -5,17 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Bar"); - // [Expressive] // public int Foo { get => Bar + 1; } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Bar + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Bar")); // Bar var expr_2 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_1, expr_2); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressivePropertyToNavigationalProperty.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressivePropertyToNavigationalProperty.verified.txt index 65dffed..3555308 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressivePropertyToNavigationalProperty.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressivePropertyToNavigationalProperty.verified.txt @@ -5,20 +5,16 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "First" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 1)).MakeGenericMethod(typeof(global::Foo.D)); - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Dees"); - // [Expressive] // public D Foo => Dees.First(); - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Dees + var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Dees")); // Dees var expr_1 = global::System.Linq.Expressions.Expression.Convert(expr_2, typeof(global::System.Collections.Generic.IEnumerable)); - var expr_0 = global::System.Linq.Expressions.Expression.Call(_m0, new global::System.Linq.Expressions.Expression[] { expr_1 }); + var expr_0 = global::System.Linq.Expressions.Expression.Call(global::System.Linq.Enumerable.First(global::System.Linq.Enumerable.Where(typeof(global::System.Linq.Enumerable).GetMethods(global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static), m => m.Name == "First" && m.IsGenericMethodDefinition && m.GetGenericArguments().Length == 1 && m.GetParameters().Length == 1)).MakeGenericMethod(typeof(global::Foo.D)), new global::System.Linq.Expressions.Expression[] { expr_1 }); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressivePropertyWithExplicitBlockGetter.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressivePropertyWithExplicitBlockGetter.verified.txt index fe62f08..699fdd8 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressivePropertyWithExplicitBlockGetter.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressivePropertyWithExplicitBlockGetter.verified.txt @@ -5,8 +5,7 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { // [Expressive(AllowBlockBody = true)] // public int Foo @@ -16,7 +15,7 @@ namespace ExpressiveSharp.Generated // return 1; // } // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var expr_0 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressivePropertyWithExplicitBlockGetterAndMethodCall.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressivePropertyWithExplicitBlockGetterAndMethodCall.verified.txt index 1e73561..c3c0590 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressivePropertyWithExplicitBlockGetterAndMethodCall.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressivePropertyWithExplicitBlockGetterAndMethodCall.verified.txt @@ -5,11 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::Foo.C).GetMethod("Bar", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - // [Expressive(AllowBlockBody = true)] // public int Foo // { @@ -18,10 +15,10 @@ namespace ExpressiveSharp.Generated // return Bar(); // } // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Call(p__this, _m0, global::System.Array.Empty()); // Bar() + var expr_0 = global::System.Linq.Expressions.Expression.Call(p__this, typeof(global::Foo.C).GetMethod("Bar", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null), global::System.Array.Empty()); // Bar() return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressivePropertyWithExplicitBlockGetterUsingThis.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressivePropertyWithExplicitBlockGetterUsingThis.verified.txt index dbf086f..ff940ae 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressivePropertyWithExplicitBlockGetterUsingThis.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressivePropertyWithExplicitBlockGetterUsingThis.verified.txt @@ -5,11 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Bar"); - // [Expressive(AllowBlockBody = true)] // public int Foo // { @@ -18,10 +15,10 @@ namespace ExpressiveSharp.Generated // return this.Bar; // } // } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // this.Bar + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Bar")); // this.Bar return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressivePropertyWithExplicitExpressionGetter.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressivePropertyWithExplicitExpressionGetter.verified.txt index 9db0015..222adf5 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressivePropertyWithExplicitExpressionGetter.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.ExpressivePropertyWithExplicitExpressionGetter.verified.txt @@ -5,12 +5,11 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { // [Expressive] // public int Foo { get => 1; } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var expr_0 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.FooOrBar.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.FooOrBar.verified.txt index 9210fd9..431c4a1 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.FooOrBar.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.FooOrBar.verified.txt @@ -5,23 +5,19 @@ using Projectables.Repro; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Projectables_Repro_SomeEntity_FooOrBar + static partial class Projectables_Repro_SomeEntity { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Projectables.Repro.SomeEntity).GetProperty("Foo"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Projectables.Repro.SomeEntity).GetProperty("Bar"); - // [Expressive] // public string FooOrBar => Foo != null ? Foo : Bar; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> FooOrBar_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Projectables.Repro.SomeEntity), "@this"); - var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Foo + var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Projectables.Repro.SomeEntity).GetProperty("Foo")); // Foo var expr_4 = global::System.Linq.Expressions.Expression.Constant(null, typeof(object)); // null var expr_3 = global::System.Linq.Expressions.Expression.Convert(expr_4, typeof(string)); var expr_1 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.NotEqual, expr_2, expr_3); - var expr_5 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Foo - var expr_6 = global::System.Linq.Expressions.Expression.Property(p__this, _p1); // Bar + var expr_5 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Projectables.Repro.SomeEntity).GetProperty("Foo")); // Foo + var expr_6 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Projectables.Repro.SomeEntity).GetProperty("Bar")); // Bar var expr_0 = global::System.Linq.Expressions.Expression.Condition(expr_1, expr_5, expr_6, typeof(string)); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.MinimalExpressiveComputedProperty.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.MinimalExpressiveComputedProperty.verified.txt index 6f8b145..60cb0e1 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.MinimalExpressiveComputedProperty.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.MinimalExpressiveComputedProperty.verified.txt @@ -5,17 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Bar"); - // [Expressive] // public int Foo => Bar; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Bar + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Bar")); // Bar return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.MoreComplexExpressiveComputedProperty.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.MoreComplexExpressiveComputedProperty.verified.txt index b9f7373..f428994 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.MoreComplexExpressiveComputedProperty.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.MoreComplexExpressiveComputedProperty.verified.txt @@ -5,20 +5,17 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Bar"); - // [Expressive] // public int Foo => Bar + this.Bar + Bar; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Bar - var expr_3 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // this.Bar + var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Bar")); // Bar + var expr_3 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Bar")); // this.Bar var expr_1 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_2, expr_3); - var expr_4 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Bar + var expr_4 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Bar")); // Bar var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_1, expr_4); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.NavigationProperties.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.NavigationProperties.verified.txt index c4dd269..b5a9aaa 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.NavigationProperties.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.NavigationProperties.verified.txt @@ -5,26 +5,21 @@ using Projectables.Repro; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Projectables_Repro_SomeEntity_RootChildren + static partial class Projectables_Repro_SomeEntity { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Projectables.Repro.SomeEntity).GetProperty("Parent"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Projectables.Repro.SomeEntity).GetProperty("RootChildren"); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::Projectables.Repro.SomeEntity).GetProperty("Children"); - // [Expressive] // public ICollection RootChildren => Parent != null ? Parent.RootChildren : Children; - static global::System.Linq.Expressions.Expression>> Expression() + static global::System.Linq.Expressions.Expression>> RootChildren_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Projectables.Repro.SomeEntity), "@this"); - var expr_3 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Parent + var expr_3 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Projectables.Repro.SomeEntity).GetProperty("Parent")); // Parent var expr_2 = global::System.Linq.Expressions.Expression.Convert(expr_3, typeof(object)); var expr_5 = global::System.Linq.Expressions.Expression.Constant(null, typeof(object)); // null var expr_4 = global::System.Linq.Expressions.Expression.Convert(expr_5, typeof(object)); var expr_1 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.NotEqual, expr_2, expr_4); - var expr_7 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Parent - var expr_6 = global::System.Linq.Expressions.Expression.Property(expr_7, _p1); - var expr_8 = global::System.Linq.Expressions.Expression.Property(p__this, _p2); // Children + var expr_7 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Projectables.Repro.SomeEntity).GetProperty("Parent")); // Parent + var expr_6 = global::System.Linq.Expressions.Expression.Property(expr_7, typeof(global::Projectables.Repro.SomeEntity).GetProperty("RootChildren")); + var expr_8 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Projectables.Repro.SomeEntity).GetProperty("Children")); // Children var expr_0 = global::System.Linq.Expressions.Expression.Condition(expr_1, expr_6, expr_8, typeof(global::System.Collections.Generic.ICollection)); return global::System.Linq.Expressions.Expression.Lambda>>(expr_0, p__this); } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.PropertyWithCustomTransformers.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.PropertyWithCustomTransformers.verified.txt index ea1c91b..cfdfee7 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.PropertyWithCustomTransformers.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.PropertyWithCustomTransformers.verified.txt @@ -5,19 +5,15 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Bar"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(string).GetProperty("Length"); - // [Expressive(Transformers = [typeof(ExpressiveSharp.Transformers.RemoveNullConditionalPatterns)])] // public int? Foo => Bar?.Length; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Bar - var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_0, _p1); // .Length + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Bar")); // Bar + var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_0, typeof(string).GetProperty("Length")); // .Length var expr_2 = global::System.Linq.Expressions.Expression.Convert(expr_1, typeof(int?)); var expr_4 = global::System.Linq.Expressions.Expression.Constant(null, typeof(string)); var expr_5 = global::System.Linq.Expressions.Expression.NotEqual(expr_0, expr_4); @@ -26,6 +22,6 @@ namespace ExpressiveSharp.Generated return global::System.Linq.Expressions.Expression.Lambda>(expr_3, p__this); } - static global::ExpressiveSharp.IExpressionTreeTransformer[] Transformers() => [new global::ExpressiveSharp.Transformers.RemoveNullConditionalPatterns()]; + static global::ExpressiveSharp.IExpressionTreeTransformer[] Foo_Transformers() => [new global::ExpressiveSharp.Transformers.RemoveNullConditionalPatterns()]; } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.RelationalProperty.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.RelationalProperty.verified.txt index 6b84942..16c220e 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.RelationalProperty.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.RelationalProperty.verified.txt @@ -5,19 +5,15 @@ using Foos; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foos_Bar_FooId + static partial class Foos_Bar { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foos.Foo).GetProperty("Id"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foos.Bar).GetProperty("Foo"); - // [Expressive] // public int FooId => Foo.Id; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> FooId_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foos.Bar), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p1); // Foo - var expr_0 = global::System.Linq.Expressions.Expression.Property(expr_1, _p0); + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foos.Bar).GetProperty("Foo")); // Foo + var expr_0 = global::System.Linq.Expressions.Expression.Property(expr_1, typeof(global::Foos.Foo).GetProperty("Id")); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.SimpleExpressiveComputedInNestedClassProperty.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.SimpleExpressiveComputedInNestedClassProperty.verified.txt index 0549fa0..b169323 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.SimpleExpressiveComputedInNestedClassProperty.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.SimpleExpressiveComputedInNestedClassProperty.verified.txt @@ -5,17 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_D_Foo + static partial class Foo_C_D { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C.D).GetProperty("Bar"); - // [Expressive] // public int Foo => Bar + 1; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C.D), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Bar + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C.D).GetProperty("Bar")); // Bar var expr_2 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_1, expr_2); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.SimpleExpressiveComputedProperty.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.SimpleExpressiveComputedProperty.verified.txt index 16ba0c1..90529f9 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.SimpleExpressiveComputedProperty.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.SimpleExpressiveComputedProperty.verified.txt @@ -5,17 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Bar"); - // [Expressive] // public int Foo => Bar + 1; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Bar + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Bar")); // Bar var expr_2 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_1, expr_2); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.SimpleExpressiveComputedPropertyWithSetter.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.SimpleExpressiveComputedPropertyWithSetter.verified.txt index 6e31bab..79ed2a1 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.SimpleExpressiveComputedPropertyWithSetter.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.SimpleExpressiveComputedPropertyWithSetter.verified.txt @@ -5,17 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Bar"); - // [Expressive] // public int Foo { get => Bar; set => Bar = value; } - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Bar + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Bar")); // Bar return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.SimpleExpressiveProperty.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.SimpleExpressiveProperty.verified.txt index 8967dc5..b683a67 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.SimpleExpressiveProperty.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/PropertyTests.SimpleExpressiveProperty.verified.txt @@ -5,12 +5,11 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Foo + static partial class Foo_C { // [Expressive] // public int Foo => 1; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Foo_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var expr_0 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.MethodOverloads_BothRegistered.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.MethodOverloads_BothRegistered.verified.txt index 1c607ba..b1c7712 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.MethodOverloads_BothRegistered.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.MethodOverloads_BothRegistered.verified.txt @@ -16,8 +16,8 @@ namespace ExpressiveSharp.Generated const BindingFlags allFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; var map = new Dictionary(); - Register(map, typeof(global::Foo.C).GetMethod("Add", allFlags, null, new global::System.Type[] { typeof(int) }, null), "ExpressiveSharp.Generated.Foo_C_Add_P0_int"); - Register(map, typeof(global::Foo.C).GetMethod("Add", allFlags, null, new global::System.Type[] { typeof(long) }, null), "ExpressiveSharp.Generated.Foo_C_Add_P0_long"); + Register(map, typeof(global::Foo.C).GetMethod("Add", allFlags, null, new global::System.Type[] { typeof(int) }, null), "ExpressiveSharp.Generated.Foo_C", "Add_P0_int_Expression"); + Register(map, typeof(global::Foo.C).GetMethod("Add", allFlags, null, new global::System.Type[] { typeof(long) }, null), "ExpressiveSharp.Generated.Foo_C", "Add_P0_long_Expression"); return map; } @@ -37,16 +37,17 @@ namespace ExpressiveSharp.Generated return handle.HasValue && _map.TryGetValue(handle.Value, out var expr) ? expr : null; } - private static void Register(Dictionary map, MethodBase m, string exprClass) + private static void Register(Dictionary map, MethodBase m, string exprClass, string exprMethodName) { if (m is null) return; var exprType = m.DeclaringType?.Assembly.GetType(exprClass); - var exprMethod = exprType?.GetMethod("Expression", BindingFlags.Static | BindingFlags.NonPublic); + var exprMethod = exprType?.GetMethod(exprMethodName, BindingFlags.Static | BindingFlags.NonPublic); if (exprMethod is null) return; var expr = (LambdaExpression)exprMethod.Invoke(null, null)!; // Apply declared transformers from the generated class (if any) - var transformersMethod = exprType.GetMethod("Transformers", BindingFlags.Static | BindingFlags.NonPublic); + var transformersSuffix = exprMethodName.Substring(0, exprMethodName.Length - "_Expression".Length) + "_Transformers"; + var transformersMethod = exprType.GetMethod(transformersSuffix, BindingFlags.Static | BindingFlags.NonPublic); if (transformersMethod?.Invoke(null, null) is global::ExpressiveSharp.IExpressionTreeTransformer[] transformers) { Expression transformed = expr; diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.MultipleExpressives_AllRegistered.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.MultipleExpressives_AllRegistered.verified.txt index f091c33..fd0d51c 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.MultipleExpressives_AllRegistered.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.MultipleExpressives_AllRegistered.verified.txt @@ -16,8 +16,8 @@ namespace ExpressiveSharp.Generated const BindingFlags allFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; var map = new Dictionary(); - Register(map, typeof(global::Foo.C).GetProperty("IdPlus1", allFlags)?.GetMethod, "ExpressiveSharp.Generated.Foo_C_IdPlus1"); - Register(map, typeof(global::Foo.C).GetMethod("AddDelta", allFlags, null, new global::System.Type[] { typeof(int) }, null), "ExpressiveSharp.Generated.Foo_C_AddDelta_P0_int"); + Register(map, typeof(global::Foo.C).GetProperty("IdPlus1", allFlags)?.GetMethod, "ExpressiveSharp.Generated.Foo_C", "IdPlus1_Expression"); + Register(map, typeof(global::Foo.C).GetMethod("AddDelta", allFlags, null, new global::System.Type[] { typeof(int) }, null), "ExpressiveSharp.Generated.Foo_C", "AddDelta_P0_int_Expression"); return map; } @@ -37,16 +37,17 @@ namespace ExpressiveSharp.Generated return handle.HasValue && _map.TryGetValue(handle.Value, out var expr) ? expr : null; } - private static void Register(Dictionary map, MethodBase m, string exprClass) + private static void Register(Dictionary map, MethodBase m, string exprClass, string exprMethodName) { if (m is null) return; var exprType = m.DeclaringType?.Assembly.GetType(exprClass); - var exprMethod = exprType?.GetMethod("Expression", BindingFlags.Static | BindingFlags.NonPublic); + var exprMethod = exprType?.GetMethod(exprMethodName, BindingFlags.Static | BindingFlags.NonPublic); if (exprMethod is null) return; var expr = (LambdaExpression)exprMethod.Invoke(null, null)!; // Apply declared transformers from the generated class (if any) - var transformersMethod = exprType.GetMethod("Transformers", BindingFlags.Static | BindingFlags.NonPublic); + var transformersSuffix = exprMethodName.Substring(0, exprMethodName.Length - "_Expression".Length) + "_Transformers"; + var transformersMethod = exprType.GetMethod(transformersSuffix, BindingFlags.Static | BindingFlags.NonPublic); if (transformersMethod?.Invoke(null, null) is global::ExpressiveSharp.IExpressionTreeTransformer[] transformers) { Expression transformed = expr; diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.SingleMethod_RegistryContainsEntry.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.SingleMethod_RegistryContainsEntry.verified.txt index ed064d2..0ad4c50 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.SingleMethod_RegistryContainsEntry.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.SingleMethod_RegistryContainsEntry.verified.txt @@ -16,7 +16,7 @@ namespace ExpressiveSharp.Generated const BindingFlags allFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; var map = new Dictionary(); - Register(map, typeof(global::Foo.C).GetMethod("AddDelta", allFlags, null, new global::System.Type[] { typeof(int) }, null), "ExpressiveSharp.Generated.Foo_C_AddDelta_P0_int"); + Register(map, typeof(global::Foo.C).GetMethod("AddDelta", allFlags, null, new global::System.Type[] { typeof(int) }, null), "ExpressiveSharp.Generated.Foo_C", "AddDelta_P0_int_Expression"); return map; } @@ -36,16 +36,17 @@ namespace ExpressiveSharp.Generated return handle.HasValue && _map.TryGetValue(handle.Value, out var expr) ? expr : null; } - private static void Register(Dictionary map, MethodBase m, string exprClass) + private static void Register(Dictionary map, MethodBase m, string exprClass, string exprMethodName) { if (m is null) return; var exprType = m.DeclaringType?.Assembly.GetType(exprClass); - var exprMethod = exprType?.GetMethod("Expression", BindingFlags.Static | BindingFlags.NonPublic); + var exprMethod = exprType?.GetMethod(exprMethodName, BindingFlags.Static | BindingFlags.NonPublic); if (exprMethod is null) return; var expr = (LambdaExpression)exprMethod.Invoke(null, null)!; // Apply declared transformers from the generated class (if any) - var transformersMethod = exprType.GetMethod("Transformers", BindingFlags.Static | BindingFlags.NonPublic); + var transformersSuffix = exprMethodName.Substring(0, exprMethodName.Length - "_Expression".Length) + "_Transformers"; + var transformersMethod = exprType.GetMethod(transformersSuffix, BindingFlags.Static | BindingFlags.NonPublic); if (transformersMethod?.Invoke(null, null) is global::ExpressiveSharp.IExpressionTreeTransformer[] transformers) { Expression transformed = expr; diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.SingleProperty_RegistryContainsEntry.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.SingleProperty_RegistryContainsEntry.verified.txt index c6feaf1..2a9889f 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.SingleProperty_RegistryContainsEntry.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.SingleProperty_RegistryContainsEntry.verified.txt @@ -16,7 +16,7 @@ namespace ExpressiveSharp.Generated const BindingFlags allFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; var map = new Dictionary(); - Register(map, typeof(global::Foo.C).GetProperty("IdPlus1", allFlags)?.GetMethod, "ExpressiveSharp.Generated.Foo_C_IdPlus1"); + Register(map, typeof(global::Foo.C).GetProperty("IdPlus1", allFlags)?.GetMethod, "ExpressiveSharp.Generated.Foo_C", "IdPlus1_Expression"); return map; } @@ -36,16 +36,17 @@ namespace ExpressiveSharp.Generated return handle.HasValue && _map.TryGetValue(handle.Value, out var expr) ? expr : null; } - private static void Register(Dictionary map, MethodBase m, string exprClass) + private static void Register(Dictionary map, MethodBase m, string exprClass, string exprMethodName) { if (m is null) return; var exprType = m.DeclaringType?.Assembly.GetType(exprClass); - var exprMethod = exprType?.GetMethod("Expression", BindingFlags.Static | BindingFlags.NonPublic); + var exprMethod = exprType?.GetMethod(exprMethodName, BindingFlags.Static | BindingFlags.NonPublic); if (exprMethod is null) return; var expr = (LambdaExpression)exprMethod.Invoke(null, null)!; // Apply declared transformers from the generated class (if any) - var transformersMethod = exprType.GetMethod("Transformers", BindingFlags.Static | BindingFlags.NonPublic); + var transformersSuffix = exprMethodName.Substring(0, exprMethodName.Length - "_Expression".Length) + "_Transformers"; + var transformersMethod = exprType.GetMethod(transformersSuffix, BindingFlags.Static | BindingFlags.NonPublic); if (transformersMethod?.Invoke(null, null) is global::ExpressiveSharp.IExpressionTreeTransformer[] transformers) { Expression transformed = expr; diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/StringConcatenationTests.IntPlusString.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/StringConcatenationTests.IntPlusString.verified.txt index e06f538..09f99da 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/StringConcatenationTests.IntPlusString.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/StringConcatenationTests.IntPlusString.verified.txt @@ -5,25 +5,19 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Label + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Id"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(object), typeof(object) }, null); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.C).GetProperty("Name"); - private static readonly global::System.Reflection.MethodInfo _m1 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null); - // [Expressive] // public string Label => Id + ": " + Name; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Label_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_3 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Id + var expr_3 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Id")); // Id var expr_2 = global::System.Linq.Expressions.Expression.Convert(expr_3, typeof(object)); var expr_4 = global::System.Linq.Expressions.Expression.Constant(": ", typeof(string)); // ": " - var expr_1 = global::System.Linq.Expressions.Expression.Call(_m0, expr_2, expr_4); - var expr_5 = global::System.Linq.Expressions.Expression.Property(p__this, _p1); // Name - var expr_0 = global::System.Linq.Expressions.Expression.Call(_m1, expr_1, expr_5); + var expr_1 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(object), typeof(object) }, null), expr_2, expr_4); + var expr_5 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Name")); // Name + var expr_0 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_1, expr_5); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/StringConcatenationTests.SingleStringConcat.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/StringConcatenationTests.SingleStringConcat.verified.txt index 7ac3fe3..c1608d4 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/StringConcatenationTests.SingleStringConcat.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/StringConcatenationTests.SingleStringConcat.verified.txt @@ -5,21 +5,16 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Joined + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("A"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.C).GetProperty("B"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null); - // [Expressive] // public string Joined => A + B; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Joined_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // A - var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, _p1); // B - var expr_0 = global::System.Linq.Expressions.Expression.Call(_m0, expr_1, expr_2); + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("A")); // A + var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("B")); // B + var expr_0 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_1, expr_2); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/StringConcatenationTests.StringPlusString.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/StringConcatenationTests.StringPlusString.verified.txt index 53be3aa..c8dec18 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/StringConcatenationTests.StringPlusString.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/StringConcatenationTests.StringPlusString.verified.txt @@ -5,23 +5,18 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_FullName + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("First"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.C).GetProperty("Last"); - // [Expressive] // public string FullName => First + " " + Last; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> FullName_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // First + var expr_2 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("First")); // First var expr_3 = global::System.Linq.Expressions.Expression.Constant(" ", typeof(string)); // " " - var expr_1 = global::System.Linq.Expressions.Expression.Call(_m0, expr_2, expr_3); - var expr_4 = global::System.Linq.Expressions.Expression.Property(p__this, _p1); // Last - var expr_0 = global::System.Linq.Expressions.Expression.Call(_m0, expr_1, expr_4); + var expr_1 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_2, expr_3); + var expr_4 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Last")); // Last + var expr_0 = global::System.Linq.Expressions.Expression.Call(typeof(string).GetMethod("Concat", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Static, null, new global::System.Type[] { typeof(string), typeof(string) }, null), expr_1, expr_4); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.ExpressionBodied_IsPattern_WithAndPattern.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.ExpressionBodied_IsPattern_WithAndPattern.verified.txt index f926740..9d049b1 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.ExpressionBodied_IsPattern_WithAndPattern.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.ExpressionBodied_IsPattern_WithAndPattern.verified.txt @@ -5,17 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Entity_IsInRange + static partial class Foo_Entity { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Entity).GetProperty("Value"); - // [Expressive] // public bool IsInRange => Value is >= 1 and <= 100; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> IsInRange_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Value + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Entity).GetProperty("Value")); // Value var expr_3 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 var expr_2 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThanOrEqual, expr_0, expr_3); var expr_5 = global::System.Linq.Expressions.Expression.Constant(100, typeof(int)); // 100 diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.ExpressionBodied_IsPattern_WithNotNullPattern.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.ExpressionBodied_IsPattern_WithNotNullPattern.verified.txt index 734799e..663642e 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.ExpressionBodied_IsPattern_WithNotNullPattern.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.ExpressionBodied_IsPattern_WithNotNullPattern.verified.txt @@ -5,17 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Entity_HasName + static partial class Foo_Entity { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Entity).GetProperty("Name"); - // [Expressive] // public bool HasName => Name is not null; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> HasName_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Name + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Entity).GetProperty("Name")); // Name var expr_4 = global::System.Linq.Expressions.Expression.Constant(null, typeof(object)); // null var expr_3 = global::System.Linq.Expressions.Expression.Convert(expr_4, typeof(string)); var expr_2 = global::System.Linq.Expressions.Expression.Equal(expr_0, expr_3); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.ExpressionBodied_IsPattern_WithOrPattern.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.ExpressionBodied_IsPattern_WithOrPattern.verified.txt index 6caede0..889f8a0 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.ExpressionBodied_IsPattern_WithOrPattern.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.ExpressionBodied_IsPattern_WithOrPattern.verified.txt @@ -5,17 +5,14 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Entity_IsOutOfRange + static partial class Foo_Entity { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Entity).GetProperty("Value"); - // [Expressive] // public bool IsOutOfRange => Value is 0 or > 100; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> IsOutOfRange_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Value + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Entity).GetProperty("Value")); // Value var expr_3 = global::System.Linq.Expressions.Expression.Constant(0, typeof(int)); // 0 var expr_2 = global::System.Linq.Expressions.Expression.Equal(expr_0, expr_3); var expr_5 = global::System.Linq.Expressions.Expression.Constant(100, typeof(int)); // 100 diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.SwitchExpressionWithConstantPattern.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.SwitchExpressionWithConstantPattern.verified.txt index 7ea0f2b..d97adfe 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.SwitchExpressionWithConstantPattern.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.SwitchExpressionWithConstantPattern.verified.txt @@ -4,11 +4,8 @@ namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _Foo_SomeNumber_P0_int + static partial class _Foo { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo).GetProperty("FancyNumber"); - // [Expressive] // public int SomeNumber(int input) => input switch // { @@ -17,14 +14,14 @@ namespace ExpressiveSharp.Generated // 4 when FancyNumber == 12 => 48, // _ => 1000, // }; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> SomeNumber_P0_int_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo), "@this"); var p_input = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "input"); var expr_0 = global::System.Linq.Expressions.Expression.Constant(1000, typeof(int)); // 1000 var expr_2 = global::System.Linq.Expressions.Expression.Constant(4, typeof(int)); // 4 var expr_1 = global::System.Linq.Expressions.Expression.Equal(p_input, expr_2); - var expr_4 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // FancyNumber + var expr_4 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo).GetProperty("FancyNumber")); // FancyNumber var expr_6 = global::System.Linq.Expressions.Expression.Constant(12, typeof(int)); // 12 var expr_5 = global::System.Linq.Expressions.Expression.Convert(expr_6, typeof(int?)); var expr_3 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Equal, expr_4, expr_5); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.SwitchExpressionWithTypePattern.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.SwitchExpressionWithTypePattern.verified.txt index e681056..dba6722 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.SwitchExpressionWithTypePattern.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.SwitchExpressionWithTypePattern.verified.txt @@ -4,16 +4,8 @@ namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class _ItemMapper_ToData_P0_Item + static partial class _ItemMapper { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Item).GetProperty("Id"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Item).GetProperty("Name"); - private static readonly global::System.Reflection.PropertyInfo _p2 = typeof(global::DocumentItem).GetProperty("Priority"); - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::DocumentData).GetConstructor(new global::System.Type[] { typeof(int), typeof(string), typeof(int) }); - private static readonly global::System.Reflection.PropertyInfo _p3 = typeof(global::GroupItem).GetProperty("Description"); - private static readonly global::System.Reflection.ConstructorInfo _c1 = typeof(global::GroupData).GetConstructor(new global::System.Type[] { typeof(int), typeof(string), typeof(string) }); - // [Expressive] // public static ItemData ToData(this Item item) => item switch // { @@ -21,25 +13,25 @@ namespace ExpressiveSharp.Generated // DocumentItem documentItem => new DocumentData(documentItem.Id, documentItem.Name, documentItem.Priority), // _ => null ! // }; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> ToData_P0_Item_Expression() { var p_item = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Item), "item"); var expr_1 = global::System.Linq.Expressions.Expression.Constant(null, typeof(object)); // null var expr_0 = global::System.Linq.Expressions.Expression.Convert(expr_1, typeof(global::ItemData)); var expr_2 = global::System.Linq.Expressions.Expression.TypeIs(p_item, typeof(global::DocumentItem)); var expr_6 = global::System.Linq.Expressions.Expression.Variable(typeof(global::DocumentItem), "documentItem"); // documentItem - var expr_5 = global::System.Linq.Expressions.Expression.Property(expr_6, _p0); - var expr_7 = global::System.Linq.Expressions.Expression.Property(expr_6, _p1); // documentItem.Name - var expr_8 = global::System.Linq.Expressions.Expression.Property(expr_6, _p2); // documentItem.Priority - var expr_4 = global::System.Linq.Expressions.Expression.New(_c0, expr_5, expr_7, expr_8); + var expr_5 = global::System.Linq.Expressions.Expression.Property(expr_6, typeof(global::Item).GetProperty("Id")); + var expr_7 = global::System.Linq.Expressions.Expression.Property(expr_6, typeof(global::Item).GetProperty("Name")); // documentItem.Name + var expr_8 = global::System.Linq.Expressions.Expression.Property(expr_6, typeof(global::DocumentItem).GetProperty("Priority")); // documentItem.Priority + var expr_4 = global::System.Linq.Expressions.Expression.New(typeof(global::DocumentData).GetConstructor(new global::System.Type[] { typeof(int), typeof(string), typeof(int) }), expr_5, expr_7, expr_8); var expr_3 = global::System.Linq.Expressions.Expression.Convert(expr_4, typeof(global::ItemData)); var expr_9 = global::System.Linq.Expressions.Expression.Condition(expr_2, expr_3, expr_0, typeof(global::ItemData)); var expr_10 = global::System.Linq.Expressions.Expression.TypeIs(p_item, typeof(global::GroupItem)); var expr_14 = global::System.Linq.Expressions.Expression.Variable(typeof(global::GroupItem), "groupItem"); // groupItem - var expr_13 = global::System.Linq.Expressions.Expression.Property(expr_14, _p0); - var expr_15 = global::System.Linq.Expressions.Expression.Property(expr_14, _p1); // groupItem.Name - var expr_16 = global::System.Linq.Expressions.Expression.Property(expr_14, _p3); // groupItem.Description - var expr_12 = global::System.Linq.Expressions.Expression.New(_c1, expr_13, expr_15, expr_16); + var expr_13 = global::System.Linq.Expressions.Expression.Property(expr_14, typeof(global::Item).GetProperty("Id")); + var expr_15 = global::System.Linq.Expressions.Expression.Property(expr_14, typeof(global::Item).GetProperty("Name")); // groupItem.Name + var expr_16 = global::System.Linq.Expressions.Expression.Property(expr_14, typeof(global::GroupItem).GetProperty("Description")); // groupItem.Description + var expr_12 = global::System.Linq.Expressions.Expression.New(typeof(global::GroupData).GetConstructor(new global::System.Type[] { typeof(int), typeof(string), typeof(string) }), expr_13, expr_15, expr_16); var expr_11 = global::System.Linq.Expressions.Expression.Convert(expr_12, typeof(global::ItemData)); var expr_17 = global::System.Linq.Expressions.Expression.Condition(expr_10, expr_11, expr_9, typeof(global::ItemData)); return global::System.Linq.Expressions.Expression.Lambda>(expr_17, p_item); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.SwitchExpression_WithRelationalPattern.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.SwitchExpression_WithRelationalPattern.verified.txt index 11e13fd..1bb7692 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.SwitchExpression_WithRelationalPattern.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.SwitchExpression_WithRelationalPattern.verified.txt @@ -5,11 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_Entity_GetGrade + static partial class Foo_Entity { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Entity).GetProperty("Score"); - // [Expressive] // public string GetGrade() => Score switch // { @@ -18,10 +15,10 @@ namespace ExpressiveSharp.Generated // >= 70 => "C", // _ => "F", // }; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> GetGrade_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Entity), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Score + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.Entity).GetProperty("Score")); // Score var expr_1 = global::System.Linq.Expressions.Expression.Constant("F", typeof(string)); // "F" var expr_3 = global::System.Linq.Expressions.Expression.Constant(70, typeof(int)); // 70 var expr_2 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.GreaterThanOrEqual, expr_0, expr_3); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.SwitchExpression_WithRelationalPattern_OnExtensionMethod.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.SwitchExpression_WithRelationalPattern_OnExtensionMethod.verified.txt index 9e4ab20..147c5c4 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.SwitchExpression_WithRelationalPattern_OnExtensionMethod.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/SwitchPatternTests.SwitchExpression_WithRelationalPattern_OnExtensionMethod.verified.txt @@ -5,11 +5,8 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_OrderExtensions_GetTier_P0_Foo_Order + static partial class Foo_OrderExtensions { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.Order).GetProperty("Amount"); - // [Expressive] // public static string GetTier(this Order order) => order.Amount switch // { @@ -18,10 +15,10 @@ namespace ExpressiveSharp.Generated // >= 100 => "Silver", // _ => "Bronze", // }; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> GetTier_P0_Foo_Order_Expression() { var p_order = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.Order), "order"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p_order, _p0); // order.Amount + var expr_0 = global::System.Linq.Expressions.Expression.Property(p_order, typeof(global::Foo.Order).GetProperty("Amount")); // order.Amount var expr_1 = global::System.Linq.Expressions.Expression.Constant("Bronze", typeof(string)); // "Bronze" var expr_4 = global::System.Linq.Expressions.Expression.Constant(100, typeof(int)); // 100 var expr_3 = global::System.Linq.Expressions.Expression.Convert(expr_4, typeof(decimal)); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.NestedTupleLiteral.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.NestedTupleLiteral.verified.txt index fcaaebf..813d3fa 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.NestedTupleLiteral.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.NestedTupleLiteral.verified.txt @@ -5,22 +5,18 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_GetNested_P0_int_P1_string_P2_bool + static partial class Foo_C { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof((string, bool)).GetConstructor(new global::System.Type[] { typeof(string), typeof(bool) }); - private static readonly global::System.Reflection.ConstructorInfo _c1 = typeof((int, (string b, bool c))).GetConstructor(new global::System.Type[] { typeof(int), typeof((string b, bool c)) }); - // [Expressive] // public (int, (string, bool)) GetNested(int a, string b, bool c) => (a, (b, c)); - static global::System.Linq.Expressions.Expression>>> Expression() + static global::System.Linq.Expressions.Expression>>> GetNested_P0_int_P1_string_P2_bool_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_a = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "a"); var p_b = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "b"); var p_c = global::System.Linq.Expressions.Expression.Parameter(typeof(bool), "c"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0, p_b, p_c); // (b, c) - var expr_1 = global::System.Linq.Expressions.Expression.New(_c1, p_a, expr_0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof((string, bool)).GetConstructor(new global::System.Type[] { typeof(string), typeof(bool) }), p_b, p_c); // (b, c) + var expr_1 = global::System.Linq.Expressions.Expression.New(typeof((int, (string b, bool c))).GetConstructor(new global::System.Type[] { typeof(int), typeof((string b, bool c)) }), p_a, expr_0); return global::System.Linq.Expressions.Expression.Lambda>>>(expr_1, p__this, p_a, p_b, p_c); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleBinary_Equality.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleBinary_Equality.verified.txt index 3bb4777..f40e268 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleBinary_Equality.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleBinary_Equality.verified.txt @@ -5,26 +5,20 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Same + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("A"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.C).GetProperty("B"); - private static readonly global::System.Reflection.FieldInfo _f0 = typeof((int, int)).GetField("Item1", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance); - private static readonly global::System.Reflection.FieldInfo _f1 = typeof((int, int)).GetField("Item2", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance); - // [Expressive] // public bool Same => A == B; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Same_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // A - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p1); // B - var expr_2 = global::System.Linq.Expressions.Expression.Field(expr_0, _f0); - var expr_3 = global::System.Linq.Expressions.Expression.Field(expr_1, _f0); + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("A")); // A + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("B")); // B + var expr_2 = global::System.Linq.Expressions.Expression.Field(expr_0, typeof((int, int)).GetField("Item1", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance)); + var expr_3 = global::System.Linq.Expressions.Expression.Field(expr_1, typeof((int, int)).GetField("Item1", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance)); var expr_4 = global::System.Linq.Expressions.Expression.Equal(expr_2, expr_3); - var expr_5 = global::System.Linq.Expressions.Expression.Field(expr_0, _f1); - var expr_6 = global::System.Linq.Expressions.Expression.Field(expr_1, _f1); + var expr_5 = global::System.Linq.Expressions.Expression.Field(expr_0, typeof((int, int)).GetField("Item2", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance)); + var expr_6 = global::System.Linq.Expressions.Expression.Field(expr_1, typeof((int, int)).GetField("Item2", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance)); var expr_7 = global::System.Linq.Expressions.Expression.Equal(expr_5, expr_6); var expr_8 = global::System.Linq.Expressions.Expression.AndAlso(expr_4, expr_7); return global::System.Linq.Expressions.Expression.Lambda>(expr_8, p__this); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleBinary_Inequality.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleBinary_Inequality.verified.txt index 8280029..6257b40 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleBinary_Inequality.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleBinary_Inequality.verified.txt @@ -5,26 +5,20 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Different + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("A"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.C).GetProperty("B"); - private static readonly global::System.Reflection.FieldInfo _f0 = typeof((int, int)).GetField("Item1", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance); - private static readonly global::System.Reflection.FieldInfo _f1 = typeof((int, int)).GetField("Item2", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance); - // [Expressive] // public bool Different => A != B; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Different_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // A - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p1); // B - var expr_2 = global::System.Linq.Expressions.Expression.Field(expr_0, _f0); - var expr_3 = global::System.Linq.Expressions.Expression.Field(expr_1, _f0); + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("A")); // A + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("B")); // B + var expr_2 = global::System.Linq.Expressions.Expression.Field(expr_0, typeof((int, int)).GetField("Item1", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance)); + var expr_3 = global::System.Linq.Expressions.Expression.Field(expr_1, typeof((int, int)).GetField("Item1", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance)); var expr_4 = global::System.Linq.Expressions.Expression.Equal(expr_2, expr_3); - var expr_5 = global::System.Linq.Expressions.Expression.Field(expr_0, _f1); - var expr_6 = global::System.Linq.Expressions.Expression.Field(expr_1, _f1); + var expr_5 = global::System.Linq.Expressions.Expression.Field(expr_0, typeof((int, int)).GetField("Item2", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance)); + var expr_6 = global::System.Linq.Expressions.Expression.Field(expr_1, typeof((int, int)).GetField("Item2", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance)); var expr_7 = global::System.Linq.Expressions.Expression.Equal(expr_5, expr_6); var expr_8 = global::System.Linq.Expressions.Expression.AndAlso(expr_4, expr_7); var expr_9 = global::System.Linq.Expressions.Expression.Not(expr_8); diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleLiteralInMethod.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleLiteralInMethod.verified.txt index c355d71..beae52f 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleLiteralInMethod.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleLiteralInMethod.verified.txt @@ -5,21 +5,16 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_GetTuple + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Id"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.C).GetProperty("Name"); - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof((int, string)).GetConstructor(new global::System.Type[] { typeof(int), typeof(string) }); - // [Expressive] // public (int, string) GetTuple() => (Id, Name); - static global::System.Linq.Expressions.Expression>> Expression() + static global::System.Linq.Expressions.Expression>> GetTuple_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Id - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p1); // Name - var expr_2 = global::System.Linq.Expressions.Expression.New(_c0, expr_0, expr_1); + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Id")); // Id + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Name")); // Name + var expr_2 = global::System.Linq.Expressions.Expression.New(typeof((int, string)).GetConstructor(new global::System.Type[] { typeof(int), typeof(string) }), expr_0, expr_1); return global::System.Linq.Expressions.Expression.Lambda>>(expr_2, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleLiteralWith8Elements.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleLiteralWith8Elements.verified.txt index 6729e6a..661d933 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleLiteralWith8Elements.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleLiteralWith8Elements.verified.txt @@ -5,15 +5,11 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_GetLarge_P0_int_P1_int_P2_int_P3_int_P4_int_P5_int_P6_int_P7_int + static partial class Foo_C { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof(global::System.ValueTuple).GetConstructor(new global::System.Type[] { typeof(int) }); - private static readonly global::System.Reflection.ConstructorInfo _c1 = typeof((int, int, int, int, int, int, int, int)).GetConstructor(new global::System.Type[] { typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(global::System.ValueTuple) }); - // [Expressive] // public (int, int, int, int, int, int, int, int) GetLarge(int a, int b, int c, int d, int e, int f, int g, int h) => (a, b, c, d, e, f, g, h); - static global::System.Linq.Expressions.Expression>>> Expression() + static global::System.Linq.Expressions.Expression>>> GetLarge_P0_int_P1_int_P2_int_P3_int_P4_int_P5_int_P6_int_P7_int_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_a = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "a"); @@ -24,8 +20,8 @@ namespace ExpressiveSharp.Generated var p_f = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "f"); var p_g = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "g"); var p_h = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "h"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0, p_h); // (a, b, c, d, e, f, g, h) - var expr_1 = global::System.Linq.Expressions.Expression.New(_c1, p_a, p_b, p_c, p_d, p_e, p_f, p_g, expr_0); + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof(global::System.ValueTuple).GetConstructor(new global::System.Type[] { typeof(int) }), p_h); // (a, b, c, d, e, f, g, h) + var expr_1 = global::System.Linq.Expressions.Expression.New(typeof((int, int, int, int, int, int, int, int)).GetConstructor(new global::System.Type[] { typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(global::System.ValueTuple) }), p_a, p_b, p_c, p_d, p_e, p_f, p_g, expr_0); return global::System.Linq.Expressions.Expression.Lambda>>>(expr_1, p__this, p_a, p_b, p_c, p_d, p_e, p_f, p_g, p_h); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleLiteralWithNamedElements.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleLiteralWithNamedElements.verified.txt index cc8e4f0..6a042d4 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleLiteralWithNamedElements.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleLiteralWithNamedElements.verified.txt @@ -5,21 +5,16 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_GetTuple + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("Id"); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.C).GetProperty("Name"); - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof((int, string)).GetConstructor(new global::System.Type[] { typeof(int), typeof(string) }); - // [Expressive] // public (int Id, string Name) GetTuple() => (Id: Id, Name: Name); - static global::System.Linq.Expressions.Expression>> Expression() + static global::System.Linq.Expressions.Expression>> GetTuple_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // Id - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p1); // Name - var expr_2 = global::System.Linq.Expressions.Expression.New(_c0, expr_0, expr_1); + var expr_0 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Id")); // Id + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("Name")); // Name + var expr_2 = global::System.Linq.Expressions.Expression.New(typeof((int, string)).GetConstructor(new global::System.Type[] { typeof(int), typeof(string) }), expr_0, expr_1); return global::System.Linq.Expressions.Expression.Lambda>>(expr_2, p__this); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleLiteralWithParameters.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleLiteralWithParameters.verified.txt index 8e93489..71c0adc 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleLiteralWithParameters.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/TupleTests.TupleLiteralWithParameters.verified.txt @@ -5,19 +5,16 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_MakeTuple_P0_int_P1_string + static partial class Foo_C { - private static readonly global::System.Reflection.ConstructorInfo _c0 = typeof((int, string)).GetConstructor(new global::System.Type[] { typeof(int), typeof(string) }); - // [Expressive] // public (int, string) MakeTuple(int id, string name) => (id, name); - static global::System.Linq.Expressions.Expression>> Expression() + static global::System.Linq.Expressions.Expression>> MakeTuple_P0_int_P1_string_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); var p_id = global::System.Linq.Expressions.Expression.Parameter(typeof(int), "id"); var p_name = global::System.Linq.Expressions.Expression.Parameter(typeof(string), "name"); - var expr_0 = global::System.Linq.Expressions.Expression.New(_c0, p_id, p_name); // (id, name) + var expr_0 = global::System.Linq.Expressions.Expression.New(typeof((int, string)).GetConstructor(new global::System.Type[] { typeof(int), typeof(string) }), p_id, p_name); // (id, name) return global::System.Linq.Expressions.Expression.Lambda>>(expr_0, p__this, p_id, p_name); } } diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/WithExpressionTests.WithExpression_OnRecord.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/WithExpressionTests.WithExpression_OnRecord.verified.txt index 75fefa6..64d5503 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/WithExpressionTests.WithExpression_OnRecord.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/WithExpressionTests.WithExpression_OnRecord.verified.txt @@ -5,31 +5,26 @@ using Foo; namespace ExpressiveSharp.Generated { - [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - static class Foo_C_Shifted + static partial class Foo_C { - private static readonly global::System.Reflection.PropertyInfo _p0 = typeof(global::Foo.C).GetProperty("P"); - private static readonly global::System.Reflection.MethodInfo _m0 = typeof(global::Foo.Point).GetMethod("$", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null); - private static readonly global::System.Reflection.PropertyInfo _p1 = typeof(global::Foo.Point).GetProperty("X"); - // [Expressive] // public Point Shifted => P with // { // X = P.X + 1 // }; - static global::System.Linq.Expressions.Expression> Expression() + static global::System.Linq.Expressions.Expression> Shifted_Expression() { var p__this = global::System.Linq.Expressions.Expression.Parameter(typeof(global::Foo.C), "@this"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // P - var expr_2 = global::System.Linq.Expressions.Expression.Call(expr_1, _m0); + var expr_1 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("P")); // P + var expr_2 = global::System.Linq.Expressions.Expression.Call(expr_1, typeof(global::Foo.Point).GetMethod("$", global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, new global::System.Type[] { }, null)); var expr_3 = global::System.Linq.Expressions.Expression.Convert(expr_2, typeof(global::Foo.Point)); var expr_4 = global::System.Linq.Expressions.Expression.Variable(typeof(global::Foo.Point), "withTemp"); var expr_5 = global::System.Linq.Expressions.Expression.Assign(expr_4, expr_3); - var expr_8 = global::System.Linq.Expressions.Expression.Property(p__this, _p0); // P - var expr_7 = global::System.Linq.Expressions.Expression.Property(expr_8, _p1); + var expr_8 = global::System.Linq.Expressions.Expression.Property(p__this, typeof(global::Foo.C).GetProperty("P")); // P + var expr_7 = global::System.Linq.Expressions.Expression.Property(expr_8, typeof(global::Foo.Point).GetProperty("X")); var expr_9 = global::System.Linq.Expressions.Expression.Constant(1, typeof(int)); // 1 var expr_6 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Add, expr_7, expr_9); - var expr_10 = global::System.Linq.Expressions.Expression.Property(expr_4, _p1); + var expr_10 = global::System.Linq.Expressions.Expression.Property(expr_4, typeof(global::Foo.Point).GetProperty("X")); var expr_11 = global::System.Linq.Expressions.Expression.Assign(expr_10, expr_6); var expr_0 = global::System.Linq.Expressions.Expression.Block(new global::System.Linq.Expressions.ParameterExpression[] { expr_4 }, expr_5, expr_11, expr_4); return global::System.Linq.Expressions.Expression.Lambda>(expr_0, p__this); diff --git a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/GlobalOptionsTests.Polyfill_GlobalNullConditionalIgnore_UsesIgnoreMode.verified.txt b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/GlobalOptionsTests.Polyfill_GlobalNullConditionalIgnore_UsesIgnoreMode.verified.txt index 7c48820..96782bb 100644 --- a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/GlobalOptionsTests.Polyfill_GlobalNullConditionalIgnore_UsesIgnoreMode.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/GlobalOptionsTests.Polyfill_GlobalNullConditionalIgnore_UsesIgnoreMode.verified.txt @@ -5,17 +5,14 @@ namespace ExpressiveSharp.Generated.Interceptors { internal static class PolyfillInterceptors { - private static readonly global::System.Reflection.PropertyInfo _i0_p0 = typeof(global::TestNs.Order).GetProperty("Tag"); - private static readonly global::System.Reflection.PropertyInfo _i0_p1 = typeof(string).GetProperty("Length"); - [global::System.Runtime.CompilerServices.InterceptsLocationAttribute(/* scrubbed */)] internal static global::System.Linq.Expressions.Expression> __Polyfill_Create_0( global::System.Func _) { // Source: o => o.Tag?.Length var p_o = global::System.Linq.Expressions.Expression.Parameter(typeof(global::TestNs.Order), "o"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p_o, _i0_p0); // o.Tag - var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_0, _i0_p1); // .Length + var expr_0 = global::System.Linq.Expressions.Expression.Property(p_o, typeof(global::TestNs.Order).GetProperty("Tag")); // o.Tag + var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_0, typeof(string).GetProperty("Length")); // .Length var expr_2 = global::System.Linq.Expressions.Expression.Convert(expr_1, typeof(int?)); var expr_4 = global::System.Linq.Expressions.Expression.Constant(null, typeof(string)); var expr_5 = global::System.Linq.Expressions.Expression.NotEqual(expr_0, expr_4); diff --git a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/GlobalOptionsTests.Where_GlobalNullConditionalRewrite_AppliesWithoutPerCallOverride.verified.txt b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/GlobalOptionsTests.Where_GlobalNullConditionalRewrite_AppliesWithoutPerCallOverride.verified.txt index a7d97ac..e83f4d8 100644 --- a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/GlobalOptionsTests.Where_GlobalNullConditionalRewrite_AppliesWithoutPerCallOverride.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/GlobalOptionsTests.Where_GlobalNullConditionalRewrite_AppliesWithoutPerCallOverride.verified.txt @@ -5,9 +5,6 @@ namespace ExpressiveSharp.Generated.Interceptors { internal static class PolyfillInterceptors { - private static readonly global::System.Reflection.PropertyInfo _i0_p0 = typeof(global::TestNs.Order).GetProperty("Customer"); - private static readonly global::System.Reflection.PropertyInfo _i0_p1 = typeof(global::TestNs.Customer).GetProperty("Name"); - [global::System.Runtime.CompilerServices.InterceptsLocationAttribute(/* scrubbed */)] internal static global::ExpressiveSharp.IRewritableQueryable __Polyfill_Where_0( this global::ExpressiveSharp.IRewritableQueryable source, @@ -15,8 +12,8 @@ namespace ExpressiveSharp.Generated.Interceptors { // Source: o => o.Customer?.Name == "Alice" var p_o = global::System.Linq.Expressions.Expression.Parameter(typeof(global::TestNs.Order), "o"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p_o, _i0_p0); // o.Customer - var expr_2 = global::System.Linq.Expressions.Expression.Property(expr_1, _i0_p1); // .Name + var expr_1 = global::System.Linq.Expressions.Expression.Property(p_o, typeof(global::TestNs.Order).GetProperty("Customer")); // o.Customer + var expr_2 = global::System.Linq.Expressions.Expression.Property(expr_1, typeof(global::TestNs.Customer).GetProperty("Name")); // .Name var expr_4 = global::System.Linq.Expressions.Expression.Constant(null, typeof(global::TestNs.Customer)); var expr_5 = global::System.Linq.Expressions.Expression.NotEqual(expr_1, expr_4); var expr_6 = global::System.Linq.Expressions.Expression.Default(typeof(string)); diff --git a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/GlobalOptionsTests.Where_PerCallOverridesGlobal.verified.txt b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/GlobalOptionsTests.Where_PerCallOverridesGlobal.verified.txt index a7d97ac..e83f4d8 100644 --- a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/GlobalOptionsTests.Where_PerCallOverridesGlobal.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/GlobalOptionsTests.Where_PerCallOverridesGlobal.verified.txt @@ -5,9 +5,6 @@ namespace ExpressiveSharp.Generated.Interceptors { internal static class PolyfillInterceptors { - private static readonly global::System.Reflection.PropertyInfo _i0_p0 = typeof(global::TestNs.Order).GetProperty("Customer"); - private static readonly global::System.Reflection.PropertyInfo _i0_p1 = typeof(global::TestNs.Customer).GetProperty("Name"); - [global::System.Runtime.CompilerServices.InterceptsLocationAttribute(/* scrubbed */)] internal static global::ExpressiveSharp.IRewritableQueryable __Polyfill_Where_0( this global::ExpressiveSharp.IRewritableQueryable source, @@ -15,8 +12,8 @@ namespace ExpressiveSharp.Generated.Interceptors { // Source: o => o.Customer?.Name == "Alice" var p_o = global::System.Linq.Expressions.Expression.Parameter(typeof(global::TestNs.Order), "o"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p_o, _i0_p0); // o.Customer - var expr_2 = global::System.Linq.Expressions.Expression.Property(expr_1, _i0_p1); // .Name + var expr_1 = global::System.Linq.Expressions.Expression.Property(p_o, typeof(global::TestNs.Order).GetProperty("Customer")); // o.Customer + var expr_2 = global::System.Linq.Expressions.Expression.Property(expr_1, typeof(global::TestNs.Customer).GetProperty("Name")); // .Name var expr_4 = global::System.Linq.Expressions.Expression.Constant(null, typeof(global::TestNs.Customer)); var expr_5 = global::System.Linq.Expressions.Expression.NotEqual(expr_1, expr_4); var expr_6 = global::System.Linq.Expressions.Expression.Default(typeof(string)); diff --git a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/GroupByTests.GroupBy_GeneratesGroupingReturnType.verified.txt b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/GroupByTests.GroupBy_GeneratesGroupingReturnType.verified.txt index 4967ada..d296606 100644 --- a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/GroupByTests.GroupBy_GeneratesGroupingReturnType.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/GroupByTests.GroupBy_GeneratesGroupingReturnType.verified.txt @@ -5,8 +5,6 @@ namespace ExpressiveSharp.Generated.Interceptors { internal static class PolyfillInterceptors { - private static readonly global::System.Reflection.PropertyInfo _i0_p0 = typeof(global::TestNs.Order).GetProperty("Tag"); - [global::System.Runtime.CompilerServices.InterceptsLocationAttribute(/* scrubbed */)] internal static global::ExpressiveSharp.IRewritableQueryable> __Polyfill_GroupBy_0( this global::ExpressiveSharp.IRewritableQueryable source, @@ -14,7 +12,7 @@ namespace ExpressiveSharp.Generated.Interceptors { // Source: o => o.Tag var p_o = global::System.Linq.Expressions.Expression.Parameter(typeof(global::TestNs.Order), "o"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p_o, _i0_p0); // o.Tag + var expr_0 = global::System.Linq.Expressions.Expression.Property(p_o, typeof(global::TestNs.Order).GetProperty("Tag")); // o.Tag var __lambda = global::System.Linq.Expressions.Expression.Lambda>(expr_0, p_o); return global::ExpressiveSharp.Extensions.ExpressionRewriteExtensions.WithExpressionRewrite( global::System.Linq.Queryable.GroupBy( diff --git a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/NullConditionalTests.NullConditionalRewrite_ExpandsInWhereBody.verified.txt b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/NullConditionalTests.NullConditionalRewrite_ExpandsInWhereBody.verified.txt index a7d97ac..e83f4d8 100644 --- a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/NullConditionalTests.NullConditionalRewrite_ExpandsInWhereBody.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/NullConditionalTests.NullConditionalRewrite_ExpandsInWhereBody.verified.txt @@ -5,9 +5,6 @@ namespace ExpressiveSharp.Generated.Interceptors { internal static class PolyfillInterceptors { - private static readonly global::System.Reflection.PropertyInfo _i0_p0 = typeof(global::TestNs.Order).GetProperty("Customer"); - private static readonly global::System.Reflection.PropertyInfo _i0_p1 = typeof(global::TestNs.Customer).GetProperty("Name"); - [global::System.Runtime.CompilerServices.InterceptsLocationAttribute(/* scrubbed */)] internal static global::ExpressiveSharp.IRewritableQueryable __Polyfill_Where_0( this global::ExpressiveSharp.IRewritableQueryable source, @@ -15,8 +12,8 @@ namespace ExpressiveSharp.Generated.Interceptors { // Source: o => o.Customer?.Name == "Alice" var p_o = global::System.Linq.Expressions.Expression.Parameter(typeof(global::TestNs.Order), "o"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p_o, _i0_p0); // o.Customer - var expr_2 = global::System.Linq.Expressions.Expression.Property(expr_1, _i0_p1); // .Name + var expr_1 = global::System.Linq.Expressions.Expression.Property(p_o, typeof(global::TestNs.Order).GetProperty("Customer")); // o.Customer + var expr_2 = global::System.Linq.Expressions.Expression.Property(expr_1, typeof(global::TestNs.Customer).GetProperty("Name")); // .Name var expr_4 = global::System.Linq.Expressions.Expression.Constant(null, typeof(global::TestNs.Customer)); var expr_5 = global::System.Linq.Expressions.Expression.NotEqual(expr_1, expr_4); var expr_6 = global::System.Linq.Expressions.Expression.Default(typeof(string)); diff --git a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/OrderByTests.OrderBy_GeneratesInterceptor.verified.txt b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/OrderByTests.OrderBy_GeneratesInterceptor.verified.txt index d386851..2645549 100644 --- a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/OrderByTests.OrderBy_GeneratesInterceptor.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/OrderByTests.OrderBy_GeneratesInterceptor.verified.txt @@ -5,8 +5,6 @@ namespace ExpressiveSharp.Generated.Interceptors { internal static class PolyfillInterceptors { - private static readonly global::System.Reflection.PropertyInfo _i0_p0 = typeof(global::TestNs.Order).GetProperty("Priority"); - [global::System.Runtime.CompilerServices.InterceptsLocationAttribute(/* scrubbed */)] internal static global::ExpressiveSharp.IRewritableQueryable __Polyfill_OrderBy_0( this global::ExpressiveSharp.IRewritableQueryable source, @@ -14,7 +12,7 @@ namespace ExpressiveSharp.Generated.Interceptors { // Source: o => o.Priority var p_o = global::System.Linq.Expressions.Expression.Parameter(typeof(global::TestNs.Order), "o"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p_o, _i0_p0); // o.Priority + var expr_0 = global::System.Linq.Expressions.Expression.Property(p_o, typeof(global::TestNs.Order).GetProperty("Priority")); // o.Priority var __lambda = global::System.Linq.Expressions.Expression.Lambda>(expr_0, p_o); return global::ExpressiveSharp.Extensions.ExpressionRewriteExtensions.WithExpressionRewrite( global::System.Linq.Queryable.OrderBy( diff --git a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/OrderByTests.ThenBy_CastsToIOrderedQueryable.verified.txt b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/OrderByTests.ThenBy_CastsToIOrderedQueryable.verified.txt index 468c1ec..da08838 100644 --- a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/OrderByTests.ThenBy_CastsToIOrderedQueryable.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/OrderByTests.ThenBy_CastsToIOrderedQueryable.verified.txt @@ -5,9 +5,6 @@ namespace ExpressiveSharp.Generated.Interceptors { internal static class PolyfillInterceptors { - private static readonly global::System.Reflection.PropertyInfo _i0_p0 = typeof(global::TestNs.Order).GetProperty("Name"); - private static readonly global::System.Reflection.PropertyInfo _i1_p0 = typeof(global::TestNs.Order).GetProperty("Priority"); - [global::System.Runtime.CompilerServices.InterceptsLocationAttribute(/* scrubbed */)] internal static global::ExpressiveSharp.IRewritableQueryable __Polyfill_ThenBy_0( this global::ExpressiveSharp.IRewritableQueryable source, @@ -15,7 +12,7 @@ namespace ExpressiveSharp.Generated.Interceptors { // Source: o => o.Name var p_o = global::System.Linq.Expressions.Expression.Parameter(typeof(global::TestNs.Order), "o"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p_o, _i0_p0); // o.Name + var expr_0 = global::System.Linq.Expressions.Expression.Property(p_o, typeof(global::TestNs.Order).GetProperty("Name")); // o.Name var __lambda = global::System.Linq.Expressions.Expression.Lambda>(expr_0, p_o); return global::ExpressiveSharp.Extensions.ExpressionRewriteExtensions.WithExpressionRewrite( global::System.Linq.Queryable.ThenBy( @@ -29,7 +26,7 @@ namespace ExpressiveSharp.Generated.Interceptors { // Source: o => o.Priority var p_o = global::System.Linq.Expressions.Expression.Parameter(typeof(global::TestNs.Order), "o"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p_o, _i1_p0); // o.Priority + var expr_0 = global::System.Linq.Expressions.Expression.Property(p_o, typeof(global::TestNs.Order).GetProperty("Priority")); // o.Priority var __lambda = global::System.Linq.Expressions.Expression.Lambda>(expr_0, p_o); return global::ExpressiveSharp.Extensions.ExpressionRewriteExtensions.WithExpressionRewrite( global::System.Linq.Queryable.OrderBy( diff --git a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/PolyfillTests.Polyfill_InferredTypeArgument_GeneratesExpression.verified.txt b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/PolyfillTests.Polyfill_InferredTypeArgument_GeneratesExpression.verified.txt index 6e297b1..6da54bf 100644 --- a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/PolyfillTests.Polyfill_InferredTypeArgument_GeneratesExpression.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/PolyfillTests.Polyfill_InferredTypeArgument_GeneratesExpression.verified.txt @@ -5,15 +5,13 @@ namespace ExpressiveSharp.Generated.Interceptors { internal static class PolyfillInterceptors { - private static readonly global::System.Reflection.PropertyInfo _i0_p0 = typeof(global::TestNs.Order).GetProperty("Tag"); - [global::System.Runtime.CompilerServices.InterceptsLocationAttribute(/* scrubbed */)] internal static global::System.Linq.Expressions.Expression> __Polyfill_Create_0( global::System.Func _) { // Source: (Order o) => o.Tag == "urgent" var p_o = global::System.Linq.Expressions.Expression.Parameter(typeof(global::TestNs.Order), "o"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p_o, _i0_p0); // o.Tag + var expr_1 = global::System.Linq.Expressions.Expression.Property(p_o, typeof(global::TestNs.Order).GetProperty("Tag")); // o.Tag var expr_2 = global::System.Linq.Expressions.Expression.Constant("urgent", typeof(string)); // "urgent" var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Equal, expr_1, expr_2); var __lambda = global::System.Linq.Expressions.Expression.Lambda>(expr_0, p_o); diff --git a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/PolyfillTests.Polyfill_NullConditional_RewritesOperator.verified.txt b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/PolyfillTests.Polyfill_NullConditional_RewritesOperator.verified.txt index 7c48820..96782bb 100644 --- a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/PolyfillTests.Polyfill_NullConditional_RewritesOperator.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/PolyfillTests.Polyfill_NullConditional_RewritesOperator.verified.txt @@ -5,17 +5,14 @@ namespace ExpressiveSharp.Generated.Interceptors { internal static class PolyfillInterceptors { - private static readonly global::System.Reflection.PropertyInfo _i0_p0 = typeof(global::TestNs.Order).GetProperty("Tag"); - private static readonly global::System.Reflection.PropertyInfo _i0_p1 = typeof(string).GetProperty("Length"); - [global::System.Runtime.CompilerServices.InterceptsLocationAttribute(/* scrubbed */)] internal static global::System.Linq.Expressions.Expression> __Polyfill_Create_0( global::System.Func _) { // Source: o => o.Tag?.Length var p_o = global::System.Linq.Expressions.Expression.Parameter(typeof(global::TestNs.Order), "o"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p_o, _i0_p0); // o.Tag - var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_0, _i0_p1); // .Length + var expr_0 = global::System.Linq.Expressions.Expression.Property(p_o, typeof(global::TestNs.Order).GetProperty("Tag")); // o.Tag + var expr_1 = global::System.Linq.Expressions.Expression.Property(expr_0, typeof(string).GetProperty("Length")); // .Length var expr_2 = global::System.Linq.Expressions.Expression.Convert(expr_1, typeof(int?)); var expr_4 = global::System.Linq.Expressions.Expression.Constant(null, typeof(string)); var expr_5 = global::System.Linq.Expressions.Expression.NotEqual(expr_0, expr_4); diff --git a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/PolyfillTests.Polyfill_SimpleLambda_GeneratesExpression.verified.txt b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/PolyfillTests.Polyfill_SimpleLambda_GeneratesExpression.verified.txt index 480d28f..a4794af 100644 --- a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/PolyfillTests.Polyfill_SimpleLambda_GeneratesExpression.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/PolyfillTests.Polyfill_SimpleLambda_GeneratesExpression.verified.txt @@ -5,15 +5,13 @@ namespace ExpressiveSharp.Generated.Interceptors { internal static class PolyfillInterceptors { - private static readonly global::System.Reflection.PropertyInfo _i0_p0 = typeof(global::TestNs.Order).GetProperty("Tag"); - [global::System.Runtime.CompilerServices.InterceptsLocationAttribute(/* scrubbed */)] internal static global::System.Linq.Expressions.Expression> __Polyfill_Create_0( global::System.Func _) { // Source: o => o.Tag == "urgent" var p_o = global::System.Linq.Expressions.Expression.Parameter(typeof(global::TestNs.Order), "o"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p_o, _i0_p0); // o.Tag + var expr_1 = global::System.Linq.Expressions.Expression.Property(p_o, typeof(global::TestNs.Order).GetProperty("Tag")); // o.Tag var expr_2 = global::System.Linq.Expressions.Expression.Constant("urgent", typeof(string)); // "urgent" var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Equal, expr_1, expr_2); var __lambda = global::System.Linq.Expressions.Expression.Lambda>(expr_0, p_o); diff --git a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/SelectTests.Select_AnonymousType_GeneratesGenericInterceptor.verified.txt b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/SelectTests.Select_AnonymousType_GeneratesGenericInterceptor.verified.txt index 92da01a..eaa56e2 100644 --- a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/SelectTests.Select_AnonymousType_GeneratesGenericInterceptor.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/SelectTests.Select_AnonymousType_GeneratesGenericInterceptor.verified.txt @@ -5,9 +5,6 @@ namespace ExpressiveSharp.Generated.Interceptors { internal static class PolyfillInterceptors { - private static readonly global::System.Reflection.PropertyInfo _i0_p0 = typeof(global::TestNs.Order).GetProperty("Id"); - private static readonly global::System.Reflection.PropertyInfo _i0_p1 = typeof(global::TestNs.Order).GetProperty("Name"); - [global::System.Runtime.CompilerServices.InterceptsLocationAttribute(/* scrubbed */)] internal static global::ExpressiveSharp.IRewritableQueryable __Polyfill_Select_0( this global::ExpressiveSharp.IRewritableQueryable source, @@ -15,8 +12,8 @@ namespace ExpressiveSharp.Generated.Interceptors { // Source: o => new { o.Id, o.Name } var p_o = global::System.Linq.Expressions.Expression.Parameter(typeof(global::TestNs.Order), "o"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p_o, _i0_p0); // o.Id - var expr_2 = global::System.Linq.Expressions.Expression.Property(p_o, _i0_p1); // o.Name + var expr_1 = global::System.Linq.Expressions.Expression.Property(p_o, typeof(global::TestNs.Order).GetProperty("Id")); // o.Id + var expr_2 = global::System.Linq.Expressions.Expression.Property(p_o, typeof(global::TestNs.Order).GetProperty("Name")); // o.Name var expr_3 = typeof(TResult).GetConstructors()[0]; var expr_0 = global::System.Linq.Expressions.Expression.New(expr_3, new global::System.Linq.Expressions.Expression[] { expr_1, expr_2 }, new global::System.Reflection.MemberInfo[] { typeof(TResult).GetProperty("Id"), typeof(TResult).GetProperty("Name") }); var __lambda = global::System.Linq.Expressions.Expression.Lambda>(expr_0, p_o); diff --git a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/SelectTests.Select_AnonymousType_WithComputedExpression_GeneratesCorrectly.verified.txt b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/SelectTests.Select_AnonymousType_WithComputedExpression_GeneratesCorrectly.verified.txt index 7e5956a..aeb0268 100644 --- a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/SelectTests.Select_AnonymousType_WithComputedExpression_GeneratesCorrectly.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/SelectTests.Select_AnonymousType_WithComputedExpression_GeneratesCorrectly.verified.txt @@ -5,10 +5,6 @@ namespace ExpressiveSharp.Generated.Interceptors { internal static class PolyfillInterceptors { - private static readonly global::System.Reflection.PropertyInfo _i0_p0 = typeof(global::TestNs.Order).GetProperty("Id"); - private static readonly global::System.Reflection.PropertyInfo _i0_p1 = typeof(global::TestNs.Order).GetProperty("Price"); - private static readonly global::System.Reflection.PropertyInfo _i0_p2 = typeof(global::TestNs.Order).GetProperty("Qty"); - [global::System.Runtime.CompilerServices.InterceptsLocationAttribute(/* scrubbed */)] internal static global::ExpressiveSharp.IRewritableQueryable __Polyfill_Select_0( this global::ExpressiveSharp.IRewritableQueryable source, @@ -16,9 +12,9 @@ namespace ExpressiveSharp.Generated.Interceptors { // Source: o => new { o.Id, Total = o.Price * o.Qty } var p_o = global::System.Linq.Expressions.Expression.Parameter(typeof(global::TestNs.Order), "o"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p_o, _i0_p0); // o.Id - var expr_3 = global::System.Linq.Expressions.Expression.Property(p_o, _i0_p1); // o.Price - var expr_5 = global::System.Linq.Expressions.Expression.Property(p_o, _i0_p2); // o.Qty + var expr_1 = global::System.Linq.Expressions.Expression.Property(p_o, typeof(global::TestNs.Order).GetProperty("Id")); // o.Id + var expr_3 = global::System.Linq.Expressions.Expression.Property(p_o, typeof(global::TestNs.Order).GetProperty("Price")); // o.Price + var expr_5 = global::System.Linq.Expressions.Expression.Property(p_o, typeof(global::TestNs.Order).GetProperty("Qty")); // o.Qty var expr_4 = global::System.Linq.Expressions.Expression.Convert(expr_5, typeof(decimal)); var expr_2 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Multiply, expr_3, expr_4); var expr_6 = typeof(TResult).GetConstructors()[0]; diff --git a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/SelectTests.Select_NamedType_GeneratesConcreteInterceptor.verified.txt b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/SelectTests.Select_NamedType_GeneratesConcreteInterceptor.verified.txt index ea1ccf6..8306315 100644 --- a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/SelectTests.Select_NamedType_GeneratesConcreteInterceptor.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/SelectTests.Select_NamedType_GeneratesConcreteInterceptor.verified.txt @@ -5,8 +5,6 @@ namespace ExpressiveSharp.Generated.Interceptors { internal static class PolyfillInterceptors { - private static readonly global::System.Reflection.PropertyInfo _i0_p0 = typeof(global::TestNs.Order).GetProperty("Name"); - [global::System.Runtime.CompilerServices.InterceptsLocationAttribute(/* scrubbed */)] internal static global::ExpressiveSharp.IRewritableQueryable __Polyfill_Select_0( this global::ExpressiveSharp.IRewritableQueryable source, @@ -14,7 +12,7 @@ namespace ExpressiveSharp.Generated.Interceptors { // Source: o => o.Name var p_o = global::System.Linq.Expressions.Expression.Parameter(typeof(global::TestNs.Order), "o"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p_o, _i0_p0); // o.Name + var expr_0 = global::System.Linq.Expressions.Expression.Property(p_o, typeof(global::TestNs.Order).GetProperty("Name")); // o.Name var __lambda = global::System.Linq.Expressions.Expression.Lambda>(expr_0, p_o); return global::ExpressiveSharp.Extensions.ExpressionRewriteExtensions.WithExpressionRewrite( global::System.Linq.Queryable.Select( diff --git a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/WhereTests.ChainedWhereAndSelect_GeneratesTwoInterceptors.verified.txt b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/WhereTests.ChainedWhereAndSelect_GeneratesTwoInterceptors.verified.txt index 4fd6d31..9170094 100644 --- a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/WhereTests.ChainedWhereAndSelect_GeneratesTwoInterceptors.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/WhereTests.ChainedWhereAndSelect_GeneratesTwoInterceptors.verified.txt @@ -5,9 +5,6 @@ namespace ExpressiveSharp.Generated.Interceptors { internal static class PolyfillInterceptors { - private static readonly global::System.Reflection.PropertyInfo _i0_p0 = typeof(global::TestNs.Order).GetProperty("Name"); - private static readonly global::System.Reflection.PropertyInfo _i1_p0 = typeof(global::TestNs.Order).GetProperty("Tag"); - [global::System.Runtime.CompilerServices.InterceptsLocationAttribute(/* scrubbed */)] internal static global::ExpressiveSharp.IRewritableQueryable __Polyfill_Select_0( this global::ExpressiveSharp.IRewritableQueryable source, @@ -15,7 +12,7 @@ namespace ExpressiveSharp.Generated.Interceptors { // Source: o => o.Name var p_o = global::System.Linq.Expressions.Expression.Parameter(typeof(global::TestNs.Order), "o"); - var expr_0 = global::System.Linq.Expressions.Expression.Property(p_o, _i0_p0); // o.Name + var expr_0 = global::System.Linq.Expressions.Expression.Property(p_o, typeof(global::TestNs.Order).GetProperty("Name")); // o.Name var __lambda = global::System.Linq.Expressions.Expression.Lambda>(expr_0, p_o); return global::ExpressiveSharp.Extensions.ExpressionRewriteExtensions.WithExpressionRewrite( global::System.Linq.Queryable.Select( @@ -29,7 +26,7 @@ namespace ExpressiveSharp.Generated.Interceptors { // Source: o => o.Tag == "urgent" var p_o = global::System.Linq.Expressions.Expression.Parameter(typeof(global::TestNs.Order), "o"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p_o, _i1_p0); // o.Tag + var expr_1 = global::System.Linq.Expressions.Expression.Property(p_o, typeof(global::TestNs.Order).GetProperty("Tag")); // o.Tag var expr_2 = global::System.Linq.Expressions.Expression.Constant("urgent", typeof(string)); // "urgent" var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Equal, expr_1, expr_2); var __lambda = global::System.Linq.Expressions.Expression.Lambda>(expr_0, p_o); diff --git a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/WhereTests.Where_SimpleCondition_GeneratesInterceptor.verified.txt b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/WhereTests.Where_SimpleCondition_GeneratesInterceptor.verified.txt index 6b85ae5..673c091 100644 --- a/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/WhereTests.Where_SimpleCondition_GeneratesInterceptor.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/PolyfillInterceptorGenerator/WhereTests.Where_SimpleCondition_GeneratesInterceptor.verified.txt @@ -5,8 +5,6 @@ namespace ExpressiveSharp.Generated.Interceptors { internal static class PolyfillInterceptors { - private static readonly global::System.Reflection.PropertyInfo _i0_p0 = typeof(global::TestNs.Order).GetProperty("Tag"); - [global::System.Runtime.CompilerServices.InterceptsLocationAttribute(/* scrubbed */)] internal static global::ExpressiveSharp.IRewritableQueryable __Polyfill_Where_0( this global::ExpressiveSharp.IRewritableQueryable source, @@ -14,7 +12,7 @@ namespace ExpressiveSharp.Generated.Interceptors { // Source: o => o.Tag == "urgent" var p_o = global::System.Linq.Expressions.Expression.Parameter(typeof(global::TestNs.Order), "o"); - var expr_1 = global::System.Linq.Expressions.Expression.Property(p_o, _i0_p0); // o.Tag + var expr_1 = global::System.Linq.Expressions.Expression.Property(p_o, typeof(global::TestNs.Order).GetProperty("Tag")); // o.Tag var expr_2 = global::System.Linq.Expressions.Expression.Constant("urgent", typeof(string)); // "urgent" var expr_0 = global::System.Linq.Expressions.Expression.MakeBinary(global::System.Linq.Expressions.ExpressionType.Equal, expr_1, expr_2); var __lambda = global::System.Linq.Expressions.Expression.Lambda>(expr_0, p_o); diff --git a/tests/ExpressiveSharp.Tests/Services/ExpressionClassNameGeneratorTests.cs b/tests/ExpressiveSharp.Tests/Services/ExpressionClassNameGeneratorTests.cs index e4f6424..718b9d7 100644 --- a/tests/ExpressiveSharp.Tests/Services/ExpressionClassNameGeneratorTests.cs +++ b/tests/ExpressiveSharp.Tests/Services/ExpressionClassNameGeneratorTests.cs @@ -74,4 +74,81 @@ public void Namespace_ConstantIsCorrect() var actual = ExpressionClassNameGenerator.Namespace; Assert.AreEqual("ExpressiveSharp.Generated", actual); } + + [TestMethod] + public void GenerateClassName_SimpleNamespaceAndClass() + { + var result = ExpressionClassNameGenerator.GenerateClassName("Foo", ["C"]); + Assert.AreEqual("Foo_C", result); + } + + [TestMethod] + public void GenerateClassName_NullNamespace() + { + var result = ExpressionClassNameGenerator.GenerateClassName(null, ["C"]); + Assert.AreEqual("_C", result); + } + + [TestMethod] + public void GenerateClassName_NestedClasses() + { + var result = ExpressionClassNameGenerator.GenerateClassName("Ns", ["Outer", "Inner"]); + Assert.AreEqual("Ns_Outer_Inner", result); + } + + [TestMethod] + public void GenerateClassName_GenericClassWithArity() + { + var result = ExpressionClassNameGenerator.GenerateClassName("Ns", ["MyClass`1"]); + Assert.AreEqual("Ns_MyClass`1", result); + } + + [TestMethod] + public void GenerateClassName_DottedNamespace() + { + var result = ExpressionClassNameGenerator.GenerateClassName("Foo.Bar", ["C"]); + Assert.AreEqual("Foo_Bar_C", result); + } + + [TestMethod] + public void GenerateClassFullName_PrependsNamespace() + { + var result = ExpressionClassNameGenerator.GenerateClassFullName("Foo", ["C"]); + Assert.AreEqual("ExpressiveSharp.Generated.Foo_C", result); + } + + [TestMethod] + public void GenerateMethodSuffix_SimpleMember() + { + var result = ExpressionClassNameGenerator.GenerateMethodSuffix("IdPlus1", null); + Assert.AreEqual("IdPlus1", result); + } + + [TestMethod] + public void GenerateMethodSuffix_WithParameters() + { + var result = ExpressionClassNameGenerator.GenerateMethodSuffix("Add", ["int"]); + Assert.AreEqual("Add_P0_int", result); + } + + [TestMethod] + public void GenerateMethodSuffix_MultipleParameters() + { + var result = ExpressionClassNameGenerator.GenerateMethodSuffix("Method", ["int", "string"]); + Assert.AreEqual("Method_P0_int_P1_string", result); + } + + [TestMethod] + public void GenerateMethodSuffix_ExplicitInterface() + { + var result = ExpressionClassNameGenerator.GenerateMethodSuffix("IFoo.Bar", null); + Assert.AreEqual("IFoo__Bar", result); + } + + [TestMethod] + public void GenerateMethodSuffix_GlobalPrefixStripped() + { + var result = ExpressionClassNameGenerator.GenerateMethodSuffix("M", ["global::System.Int32"]); + Assert.AreEqual("M_P0_System_Int32", result); + } } From 9978ec1717c715b11d9252185b06a49156f17177 Mon Sep 17 00:00:00 2001 From: Koen Date: Fri, 27 Mar 2026 02:30:47 +0000 Subject: [PATCH 2/2] fix: Address PR review feedback for partial class consolidation - Add EndsWith guard around transformer method name Substring derivation in the generated Register helper for defense-in-depth - Re-add [EditorBrowsable(Never)] to generated partial classes via a single attribute-only partial file per unique class, emitted from the registry phase - Include generic/extension classes as metadata-only registry entries so they also receive the EditorBrowsable attribute - Add GenericClass_GetsEditorBrowsableAttribute test verifying generic classes get the attribute with correct type parameters Co-Authored-By: Claude Opus 4.6 (1M context) --- .../ExpressiveGenerator.cs | 22 ++++-- .../Registry/ExpressionRegistryEmitter.cs | 72 +++++++++++++++++-- .../Registry/ExpressionRegistryEntry.cs | 4 +- ..._GetsEditorBrowsableAttribute.verified.txt | 7 ++ ...ethodOverloads_BothRegistered.verified.txt | 16 +++-- ...ipleExpressives_AllRegistered.verified.txt | 16 +++-- ...eMethod_RegistryContainsEntry.verified.txt | 16 +++-- ...roperty_RegistryContainsEntry.verified.txt | 16 +++-- .../ExpressiveGenerator/RegistryTests.cs | 23 ++++++ .../Infrastructure/GeneratorTestBase.cs | 5 +- 10 files changed, 159 insertions(+), 38 deletions(-) create mode 100644 tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.GenericClass_GetsEditorBrowsableAttribute.verified.txt diff --git a/src/ExpressiveSharp.Generator/ExpressiveGenerator.cs b/src/ExpressiveSharp.Generator/ExpressiveGenerator.cs index 3539410..c1df0a2 100644 --- a/src/ExpressiveSharp.Generator/ExpressiveGenerator.cs +++ b/src/ExpressiveSharp.Generator/ExpressiveGenerator.cs @@ -232,16 +232,22 @@ private static void EmitExpressionTreeSource( { var containingType = memberSymbol.ContainingType; - // Skip C# 14 extension type members — they require special handling (fall back to reflection) + // Determine whether this entry is metadata-only (excluded from runtime registry + // but still used for [EditorBrowsable] attribute-only partial file emission). + var isMetadataOnly = false; + string? classTypeParameters = null; + + // C# 14 extension type members — metadata-only (fall back to reflection at runtime) if (containingType is { IsExtension: true }) { - return null; + isMetadataOnly = true; } - // Skip generic classes: the registry only supports closed constructed types. + // Generic classes — metadata-only (registry can't represent open generic types) if (containingType.TypeParameters.Length > 0) { - return null; + isMetadataOnly = true; + classTypeParameters = "<" + string.Join(", ", containingType.TypeParameters.Select(tp => tp.Name)) + ">"; } // Determine member kind and lookup name @@ -251,10 +257,10 @@ private static void EmitExpressionTreeSource( if (memberSymbol is IMethodSymbol methodSymbol) { - // Skip generic methods for the same reason as generic classes + // Generic methods — metadata-only (same reason as generic classes) if (methodSymbol.TypeParameters.Length > 0) { - return null; + isMetadataOnly = true; } if (methodSymbol.MethodKind is MethodKind.Constructor or MethodKind.StaticConstructor) @@ -303,7 +309,9 @@ private static void EmitExpressionTreeSource( MemberLookupName: memberLookupName, GeneratedClassFullName: generatedClassFullName, ExpressionMethodName: expressionMethodName, - ParameterTypeNames: parameterTypeNames); + ParameterTypeNames: parameterTypeNames, + IsMetadataOnly: isMetadataOnly, + ClassTypeParameters: classTypeParameters); } private static IEnumerable GetRegistryNestedTypePath(INamedTypeSymbol typeSymbol) diff --git a/src/ExpressiveSharp.Generator/Registry/ExpressionRegistryEmitter.cs b/src/ExpressiveSharp.Generator/Registry/ExpressionRegistryEmitter.cs index f56bc77..dda36fa 100644 --- a/src/ExpressiveSharp.Generator/Registry/ExpressionRegistryEmitter.cs +++ b/src/ExpressiveSharp.Generator/Registry/ExpressionRegistryEmitter.cs @@ -25,12 +25,23 @@ static internal class ExpressionRegistryEmitter /// public static void Emit(ImmutableArray entries, SourceProductionContext context) { - var validEntries = entries + var allEntries = entries .Where(e => e is not null) .Select(e => e!) .ToList(); - if (validEntries.Count == 0) + if (allEntries.Count == 0) + { + return; + } + + // Emit [EditorBrowsable] attribute-only partial files for each unique generated class. + EmitEditorBrowsablePartialFiles(allEntries, context); + + // Filter to registry-eligible entries (exclude metadata-only entries for generic/extension classes). + var registryEntries = allEntries.Where(e => !e.IsMetadataOnly).ToList(); + + if (registryEntries.Count == 0) { return; } @@ -57,7 +68,7 @@ public static void Emit(ImmutableArray entries, Source writer.WriteLine("{"); writer.Indent++; - EmitBuildMethod(writer, validEntries); + EmitBuildMethod(writer, registryEntries); writer.WriteLine(); EmitMapField(writer); writer.WriteLine(); @@ -184,7 +195,11 @@ private static void EmitRegisterHelper(IndentedTextWriter writer) writer.WriteLine("var expr = (LambdaExpression)exprMethod.Invoke(null, null)!;"); writer.WriteLine(); writer.WriteLine("// Apply declared transformers from the generated class (if any)"); - writer.WriteLine(@"var transformersSuffix = exprMethodName.Substring(0, exprMethodName.Length - ""_Expression"".Length) + ""_Transformers"";"); + writer.WriteLine(@"const string expressionSuffix = ""_Expression"";"); + writer.WriteLine(@"if (exprMethodName.EndsWith(expressionSuffix, StringComparison.Ordinal))"); + writer.WriteLine("{"); + writer.Indent++; + writer.WriteLine(@"var transformersSuffix = exprMethodName.Substring(0, exprMethodName.Length - expressionSuffix.Length) + ""_Transformers"";"); writer.WriteLine(@"var transformersMethod = exprType.GetMethod(transformersSuffix, BindingFlags.Static | BindingFlags.NonPublic);"); writer.WriteLine(@"if (transformersMethod?.Invoke(null, null) is global::ExpressiveSharp.IExpressionTreeTransformer[] transformers)"); writer.WriteLine("{"); @@ -194,6 +209,8 @@ private static void EmitRegisterHelper(IndentedTextWriter writer) writer.WriteLine("if (transformed is LambdaExpression lambdaResult) expr = lambdaResult;"); writer.Indent--; writer.WriteLine("}"); + writer.Indent--; + writer.WriteLine("}"); writer.WriteLine(); writer.WriteLine("map[m.MethodHandle.Value] = expr;"); writer.Indent--; @@ -214,4 +231,51 @@ private static string BuildTypeArrayExpr(ImmutableArray parameterTypeNam var typeofExprs = string.Join(", ", parameterTypeNames.Select(name => $"typeof({name})")); return $"new global::System.Type[] {{ {typeofExprs} }}"; } + + /// + /// Emits a single [EditorBrowsable(Never)] attribute-only partial class file + /// for each unique generated class. This ensures the attribute appears exactly once + /// per class, avoiding CS0579 (duplicate attribute) across per-member partial files. + /// + private static void EmitEditorBrowsablePartialFiles(List allEntries, SourceProductionContext context) + { + // Group by class full name to emit one file per unique class. + // Use the first entry per class to get type parameter info. + var seenClasses = new Dictionary(); + foreach (var entry in allEntries) + { + if (!seenClasses.ContainsKey(entry.GeneratedClassFullName)) + { + seenClasses[entry.GeneratedClassFullName] = entry; + } + } + + foreach (var kvp in seenClasses) + { + var classFullName = kvp.Key; + var entry = kvp.Value; + + // Extract the simple class name from the full name (after the last '.') + var className = classFullName; + var lastDot = classFullName.LastIndexOf('.'); + if (lastDot >= 0) + { + className = classFullName.Substring(lastDot + 1); + } + + var typeParams = entry.ClassTypeParameters ?? ""; + + var sb = new StringBuilder(); + sb.AppendLine("// "); + sb.AppendLine(); + sb.AppendLine("namespace ExpressiveSharp.Generated"); + sb.AppendLine("{"); + sb.AppendLine(" [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]"); + sb.AppendLine($" static partial class {className}{typeParams} {{ }}"); + sb.AppendLine("}"); + + context.AddSource($"{className}.Attributes.g.cs", + SourceText.From(sb.ToString(), Encoding.UTF8)); + } + } } diff --git a/src/ExpressiveSharp.Generator/Registry/ExpressionRegistryEntry.cs b/src/ExpressiveSharp.Generator/Registry/ExpressionRegistryEntry.cs index bac74d7..9c6617b 100644 --- a/src/ExpressiveSharp.Generator/Registry/ExpressionRegistryEntry.cs +++ b/src/ExpressiveSharp.Generator/Registry/ExpressionRegistryEntry.cs @@ -13,7 +13,9 @@ sealed internal record ExpressionRegistryEntry( string MemberLookupName, string GeneratedClassFullName, string ExpressionMethodName, - EquatableImmutableArray ParameterTypeNames + EquatableImmutableArray ParameterTypeNames, + bool IsMetadataOnly = false, + string? ClassTypeParameters = null ); /// diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.GenericClass_GetsEditorBrowsableAttribute.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.GenericClass_GetsEditorBrowsableAttribute.verified.txt new file mode 100644 index 0000000..a2b6a25 --- /dev/null +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.GenericClass_GetsEditorBrowsableAttribute.verified.txt @@ -0,0 +1,7 @@ +// + +namespace ExpressiveSharp.Generated +{ + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + static partial class Foo_C { } +} diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.MethodOverloads_BothRegistered.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.MethodOverloads_BothRegistered.verified.txt index b1c7712..116db3f 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.MethodOverloads_BothRegistered.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.MethodOverloads_BothRegistered.verified.txt @@ -46,13 +46,17 @@ namespace ExpressiveSharp.Generated var expr = (LambdaExpression)exprMethod.Invoke(null, null)!; // Apply declared transformers from the generated class (if any) - var transformersSuffix = exprMethodName.Substring(0, exprMethodName.Length - "_Expression".Length) + "_Transformers"; - var transformersMethod = exprType.GetMethod(transformersSuffix, BindingFlags.Static | BindingFlags.NonPublic); - if (transformersMethod?.Invoke(null, null) is global::ExpressiveSharp.IExpressionTreeTransformer[] transformers) + const string expressionSuffix = "_Expression"; + if (exprMethodName.EndsWith(expressionSuffix, StringComparison.Ordinal)) { - Expression transformed = expr; - foreach (var t in transformers) transformed = t.Transform(transformed); - if (transformed is LambdaExpression lambdaResult) expr = lambdaResult; + var transformersSuffix = exprMethodName.Substring(0, exprMethodName.Length - expressionSuffix.Length) + "_Transformers"; + var transformersMethod = exprType.GetMethod(transformersSuffix, BindingFlags.Static | BindingFlags.NonPublic); + if (transformersMethod?.Invoke(null, null) is global::ExpressiveSharp.IExpressionTreeTransformer[] transformers) + { + Expression transformed = expr; + foreach (var t in transformers) transformed = t.Transform(transformed); + if (transformed is LambdaExpression lambdaResult) expr = lambdaResult; + } } map[m.MethodHandle.Value] = expr; diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.MultipleExpressives_AllRegistered.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.MultipleExpressives_AllRegistered.verified.txt index fd0d51c..4f411a1 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.MultipleExpressives_AllRegistered.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.MultipleExpressives_AllRegistered.verified.txt @@ -46,13 +46,17 @@ namespace ExpressiveSharp.Generated var expr = (LambdaExpression)exprMethod.Invoke(null, null)!; // Apply declared transformers from the generated class (if any) - var transformersSuffix = exprMethodName.Substring(0, exprMethodName.Length - "_Expression".Length) + "_Transformers"; - var transformersMethod = exprType.GetMethod(transformersSuffix, BindingFlags.Static | BindingFlags.NonPublic); - if (transformersMethod?.Invoke(null, null) is global::ExpressiveSharp.IExpressionTreeTransformer[] transformers) + const string expressionSuffix = "_Expression"; + if (exprMethodName.EndsWith(expressionSuffix, StringComparison.Ordinal)) { - Expression transformed = expr; - foreach (var t in transformers) transformed = t.Transform(transformed); - if (transformed is LambdaExpression lambdaResult) expr = lambdaResult; + var transformersSuffix = exprMethodName.Substring(0, exprMethodName.Length - expressionSuffix.Length) + "_Transformers"; + var transformersMethod = exprType.GetMethod(transformersSuffix, BindingFlags.Static | BindingFlags.NonPublic); + if (transformersMethod?.Invoke(null, null) is global::ExpressiveSharp.IExpressionTreeTransformer[] transformers) + { + Expression transformed = expr; + foreach (var t in transformers) transformed = t.Transform(transformed); + if (transformed is LambdaExpression lambdaResult) expr = lambdaResult; + } } map[m.MethodHandle.Value] = expr; diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.SingleMethod_RegistryContainsEntry.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.SingleMethod_RegistryContainsEntry.verified.txt index 0ad4c50..959021d 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.SingleMethod_RegistryContainsEntry.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.SingleMethod_RegistryContainsEntry.verified.txt @@ -45,13 +45,17 @@ namespace ExpressiveSharp.Generated var expr = (LambdaExpression)exprMethod.Invoke(null, null)!; // Apply declared transformers from the generated class (if any) - var transformersSuffix = exprMethodName.Substring(0, exprMethodName.Length - "_Expression".Length) + "_Transformers"; - var transformersMethod = exprType.GetMethod(transformersSuffix, BindingFlags.Static | BindingFlags.NonPublic); - if (transformersMethod?.Invoke(null, null) is global::ExpressiveSharp.IExpressionTreeTransformer[] transformers) + const string expressionSuffix = "_Expression"; + if (exprMethodName.EndsWith(expressionSuffix, StringComparison.Ordinal)) { - Expression transformed = expr; - foreach (var t in transformers) transformed = t.Transform(transformed); - if (transformed is LambdaExpression lambdaResult) expr = lambdaResult; + var transformersSuffix = exprMethodName.Substring(0, exprMethodName.Length - expressionSuffix.Length) + "_Transformers"; + var transformersMethod = exprType.GetMethod(transformersSuffix, BindingFlags.Static | BindingFlags.NonPublic); + if (transformersMethod?.Invoke(null, null) is global::ExpressiveSharp.IExpressionTreeTransformer[] transformers) + { + Expression transformed = expr; + foreach (var t in transformers) transformed = t.Transform(transformed); + if (transformed is LambdaExpression lambdaResult) expr = lambdaResult; + } } map[m.MethodHandle.Value] = expr; diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.SingleProperty_RegistryContainsEntry.verified.txt b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.SingleProperty_RegistryContainsEntry.verified.txt index 2a9889f..68e032f 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.SingleProperty_RegistryContainsEntry.verified.txt +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.SingleProperty_RegistryContainsEntry.verified.txt @@ -45,13 +45,17 @@ namespace ExpressiveSharp.Generated var expr = (LambdaExpression)exprMethod.Invoke(null, null)!; // Apply declared transformers from the generated class (if any) - var transformersSuffix = exprMethodName.Substring(0, exprMethodName.Length - "_Expression".Length) + "_Transformers"; - var transformersMethod = exprType.GetMethod(transformersSuffix, BindingFlags.Static | BindingFlags.NonPublic); - if (transformersMethod?.Invoke(null, null) is global::ExpressiveSharp.IExpressionTreeTransformer[] transformers) + const string expressionSuffix = "_Expression"; + if (exprMethodName.EndsWith(expressionSuffix, StringComparison.Ordinal)) { - Expression transformed = expr; - foreach (var t in transformers) transformed = t.Transform(transformed); - if (transformed is LambdaExpression lambdaResult) expr = lambdaResult; + var transformersSuffix = exprMethodName.Substring(0, exprMethodName.Length - expressionSuffix.Length) + "_Transformers"; + var transformersMethod = exprType.GetMethod(transformersSuffix, BindingFlags.Static | BindingFlags.NonPublic); + if (transformersMethod?.Invoke(null, null) is global::ExpressiveSharp.IExpressionTreeTransformer[] transformers) + { + Expression transformed = expr; + foreach (var t in transformers) transformed = t.Transform(transformed); + if (transformed is LambdaExpression lambdaResult) expr = lambdaResult; + } } map[m.MethodHandle.Value] = expr; diff --git a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.cs b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.cs index bba9b0c..c2b52fa 100644 --- a/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.cs +++ b/tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/RegistryTests.cs @@ -90,6 +90,29 @@ class C { Assert.IsNull(result.RegistryTree); } + [TestMethod] + public Task GenericClass_GetsEditorBrowsableAttribute() + { + var compilation = CreateCompilation( + """ + namespace Foo { + class C { + public int Id { get; set; } + [Expressive] + public int IdPlus1 => Id + 1; + } + } + """); + var result = RunExpressiveGenerator(compilation); + + var attributeTree = result.AllGeneratedTrees + .FirstOrDefault(t => t.FilePath.EndsWith(".Attributes.g.cs", StringComparison.Ordinal)); + + Assert.IsNotNull(attributeTree); + + return Verifier.Verify(attributeTree!.GetText().ToString()); + } + [TestMethod] public Task MethodOverloads_BothRegistered() { diff --git a/tests/ExpressiveSharp.Generator.Tests/Infrastructure/GeneratorTestBase.cs b/tests/ExpressiveSharp.Generator.Tests/Infrastructure/GeneratorTestBase.cs index abc99c3..e18a702 100644 --- a/tests/ExpressiveSharp.Generator.Tests/Infrastructure/GeneratorTestBase.cs +++ b/tests/ExpressiveSharp.Generator.Tests/Infrastructure/GeneratorTestBase.cs @@ -28,10 +28,11 @@ protected sealed class TestGeneratorRunResult public ImmutableArray Diagnostics => _inner.Diagnostics; - /// Generated trees excluding ExpressionRegistry.g.cs. + /// Generated trees excluding ExpressionRegistry.g.cs and *.Attributes.g.cs. public ImmutableArray GeneratedTrees => _inner.GeneratedTrees - .Where(t => !t.FilePath.EndsWith("ExpressionRegistry.g.cs", StringComparison.Ordinal)) + .Where(t => !t.FilePath.EndsWith("ExpressionRegistry.g.cs", StringComparison.Ordinal) + && !t.FilePath.EndsWith(".Attributes.g.cs", StringComparison.Ordinal)) .ToImmutableArray(); /// All generated trees including ExpressionRegistry.g.cs.