public void SkipOtherComparisons()
        {
            var parameter = Expression.Parameter(typeof(A), "x");

            PreProcessors.PropagateImplicitBooleans(ExpOf <A>(x => x.BoolProperty == x.BoolField))
            .ShouldBeLike(Expression.Lambda <Func <A, bool> >(
                              Expression.MakeBinary(ExpressionType.Equal,
                                                    Expression.MakeMemberAccess(parameter, typeof(A).GetMember(nameof(A.BoolProperty))[0]),
                                                    Expression.MakeMemberAccess(parameter, typeof(A).GetMember(nameof(A.BoolField))[0])),
                              parameter));
        }
        public void SkipExplicitBoolComparisons()
        {
            var parameter = Expression.Parameter(typeof(A), "x");

            // ReSharper disable once RedundantBoolCompare
            PreProcessors.PropagateImplicitBooleans(ExpOf <A>(x => x.BoolProperty == true))
            .ShouldBeLike(Expression.Lambda <Func <A, bool> >(
                              Expression.MakeBinary(ExpressionType.Equal,
                                                    Expression.MakeMemberAccess(parameter, typeof(A).GetMember(nameof(A.BoolProperty))[0]),
                                                    Expression.Constant(true)),
                              parameter));
        }
示例#3
0
        private void ApplySettings()
        {
            Sources.SelectedValue = _settings.SourceStoreConfiguration.StoreFullName;
            SourceConfiguration.LoadConfiguration(_settings.SourceStoreConfiguration, true);
            Destinations.SelectedValue = _settings.DestinationStoreConfiguration.StoreFullName;
            DestinationConfiguration.LoadConfiguration(_settings.DestinationStoreConfiguration, false);
            MappingSource.LoadItems(_settings.SourceStoreConfiguration.Columns.Select(x => x.Name));
            MappingDestination.LoadItems(_settings.DestinationStoreConfiguration.Columns.Select(x => x.Name));
            Mappings.LoadItems(_settings.Mappings.Select(x => x.DisplayName));
            ProcessorMappings.LoadItems(_settings.Mappings.Select(x => x.DisplayName));
            PreProcessors.LoadItems(_settings.Mappings.SelectMany(x => x.PreProcesses.Select(y => x.DisplayName + "|" + y.DisplayName)));

            UpdateControlState();
        }
        public void AndAlso()
        {
            var parameter = Expression.Parameter(typeof(A), "x");

            PreProcessors.PropagateImplicitBooleans(ExpOf <A>(x => x.BoolProperty && x.BoolField))
            .ShouldBeLike(Expression.Lambda <Func <A, bool> >(
                              Expression.MakeBinary(ExpressionType.AndAlso,
                                                    Expression.MakeBinary(ExpressionType.Equal,
                                                                          Expression.MakeMemberAccess(parameter, typeof(A).GetMember(nameof(A.BoolProperty))[0]),
                                                                          Expression.Constant(true)),
                                                    Expression.MakeBinary(ExpressionType.Equal,
                                                                          Expression.MakeMemberAccess(parameter, typeof(A).GetMember(nameof(A.BoolField))[0]),
                                                                          Expression.Constant(true))),
                              parameter));
        }
        public void ReduceConstantMemberAccess()
        {
            var test = new A
            {
                Property = new A
                {
                    Property = new A()
                }
            };

            var expression = PreProcessors.ReduceConstantMemberAccess((Expression <Func <A> >)(
                                                                          () => test.Property.Property
                                                                          ));

            // Assertion is like this, because of this: https://stackoverflow.com/questions/60452684/net-core-and-type-equality
            (expression as Expression <Func <A> >)
            .Body.ShouldBeOfType <ConstantExpression>()
            .Value.ShouldBe(test.Property.Property);
        }