当前位置: 首页>>代码示例>>C#>>正文


C# FxCopNullabilityRuleValidatorBuilder类代码示例

本文整理汇总了C#中FxCopNullabilityRuleValidatorBuilder的典型用法代码示例。如果您正苦于以下问题:C# FxCopNullabilityRuleValidatorBuilder类的具体用法?C# FxCopNullabilityRuleValidatorBuilder怎么用?C# FxCopNullabilityRuleValidatorBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FxCopNullabilityRuleValidatorBuilder类属于命名空间,在下文中一共展示了FxCopNullabilityRuleValidatorBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: When_base_method_inherits_annotation_from_interface_it_must_be_skipped

        public void When_base_method_inherits_annotation_from_interface_it_must_be_skipped()
        {
            // Arrange
            FxCopRuleValidator validator = new FxCopNullabilityRuleValidatorBuilder()
                .ForRule<NullabilityRule>()
                .OnAssembly(new ClassSourceCodeBuilder()
                    .InGlobalScope(@"
                        namespace N
                        {
                            public interface I
                            {
                                [NotNull]
                                string M();
                            }

                            public class B : I
                            {
                                public virtual string M() { throw new NotImplementedException(); }
                            }

                            public class C : B
                            {
                                public override string M() { throw new NotImplementedException(); }
                            }
                        }
                    "))
                .Build();

            // Act
            FxCopRuleValidationResult result = validator.Execute();

            // Assert
            result.ProblemText.Should().Be(FxCopRuleValidationResult.NoProblemsText);
        }
开发者ID:FeodorFitsner,项目名称:ResharperCodeContractNullabilityFxCop,代码行数:34,代码来源:MethodReturnValueSpecs.cs

示例2: When_field_in_nested_class_is_externally_annotated_it_must_be_skipped

        public void When_field_in_nested_class_is_externally_annotated_it_must_be_skipped()
        {
            // Arrange
            FxCopRuleValidator validator = new FxCopNullabilityRuleValidatorBuilder()
                .ForRule<NullabilityRule>()
                .OnAssembly(new ClassSourceCodeBuilder()
                    .InGlobalScope(@"
                        namespace TestSystem
                        {
                            public class Outer
                            {
                                private class Inner
                                {
                                    public int? Value;
                                }
                            }
                        }
                    "))
                .ExternallyAnnotated(new ExternalAnnotationsBuilder()
                    .IncludingMember(new ExternalAnnotationFragmentBuilder()
                        .Named("F:TestSystem.Outer.Inner.Value")
                        .CanBeNull()))
                .Build();

            // Act
            FxCopRuleValidationResult result = validator.Execute();

            // Assert
            result.ProblemText.Should().Be(FxCopRuleValidationResult.NoProblemsText);
        }
开发者ID:bkoelman,项目名称:ResharperCodeContractNullabilityFxCop,代码行数:30,代码来源:ExternalAnnotationMemberNamingSpecs.cs

示例3: When_base_property_inherits_item_annotation_from_interface_it_must_be_skipped

        public void When_base_property_inherits_item_annotation_from_interface_it_must_be_skipped()
        {
            // Arrange
            FxCopRuleValidator validator = new FxCopNullabilityRuleValidatorBuilder()
                .ForRule<ItemNullabilityRule>()
                .OnAssembly(new ClassSourceCodeBuilder()
                    .Using(typeof (IEnumerable).Namespace)
                    .InGlobalScope(@"
                        namespace N
                        {
                            public interface I
                            {
                                [ItemNotNull]
                                IEnumerable P { get; set; }
                            }

                            public class B : I
                            {
                                public virtual IEnumerable P { get; set; }
                            }

                            public class C : B
                            {
                                public override IEnumerable P { get; set; }
                            }
                        }
                    "))
                .Build();

            // Act
            FxCopRuleValidationResult result = validator.Execute();

            // Assert
            result.ProblemText.Should().Be(FxCopRuleValidationResult.NoProblemsText);
        }
开发者ID:FeodorFitsner,项目名称:ResharperCodeContractNullabilityFxCop,代码行数:35,代码来源:PropertyCollectionSpecs.cs

示例4: When_containing_type_is_decorated_with_conditional_its_members_must_be_skipped

        public void When_containing_type_is_decorated_with_conditional_its_members_must_be_skipped()
        {
            // Arrange
            FxCopRuleValidator validator = new FxCopNullabilityRuleValidatorBuilder()
                .ForRule<NullabilityRule>()
                .OnAssembly(new ClassSourceCodeBuilder()
                    .WithReference(typeof (ConditionalAttribute).Assembly)
                    .Using(typeof (ConditionalAttribute).Namespace)
                    .InGlobalScope(@"
                        namespace N
                        {
                            [Conditional(""JETBRAINS_ANNOTATIONS"")]
                            class C : Attribute
                            {
                                string M() { throw new NotImplementedException(); }
                            }
                        }
                    "))
                .Build();

            // Act
            FxCopRuleValidationResult result = validator.Execute();

            // Assert
            result.ProblemText.Should().Be(FxCopRuleValidationResult.NoProblemsText);
        }
开发者ID:FeodorFitsner,项目名称:ResharperCodeContractNullabilityFxCop,代码行数:26,代码来源:MethodReturnValueSpecs.cs

示例5: When_async_method_returns_void_it_must_be_skipped

        public void When_async_method_returns_void_it_must_be_skipped()
        {
            // Arrange
            FxCopRuleValidator validator = new FxCopNullabilityRuleValidatorBuilder()
                .ForRule<ItemNullabilityRule>()
                .OnAssembly(new MemberSourceCodeBuilder()
                    .InDefaultClass(@"
                        async void M() { throw new NotImplementedException(); }
                    "))
                .Build();

            // Act
            FxCopRuleValidationResult result = validator.Execute();

            // Assert
            result.ProblemText.Should().Be(FxCopRuleValidationResult.NoProblemsText);
        }
开发者ID:bkoelman,项目名称:ResharperCodeContractNullabilityFxCop,代码行数:17,代码来源:MethodReturnValueCollectionSpecs.cs

示例6: When_async_method_returns_generic_task_it_must_be_skipped

        public void When_async_method_returns_generic_task_it_must_be_skipped()
        {
            // Arrange
            FxCopRuleValidator validator = new FxCopNullabilityRuleValidatorBuilder()
                .ForRule<NullabilityRule>()
                .OnAssembly(new MemberSourceCodeBuilder()
                    .Using(typeof (Task<>).Namespace)
                    .InDefaultClass(@"
                        async Task<string> M() { throw new NotImplementedException(); }
                    "))
                .Build();

            // Act
            FxCopRuleValidationResult result = validator.Execute();

            // Assert
            result.ProblemText.Should().Be(FxCopRuleValidationResult.NoProblemsText);
        }
开发者ID:bkoelman,项目名称:ResharperCodeContractNullabilityFxCop,代码行数:18,代码来源:MethodReturnValueSpecs.cs

示例7: When_array_item_type_is_value_type_it_must_be_skipped

        public void When_array_item_type_is_value_type_it_must_be_skipped()
        {
            // Arrange
            FxCopRuleValidator validator = new FxCopNullabilityRuleValidatorBuilder()
                .ForRule<ItemNullabilityRule>()
                .OnAssembly(new ClassSourceCodeBuilder()
                    .InGlobalScope(@"
                        class C
                        {
                            byte[] f;
                        }
                    "))
                .Build();

            // Act
            FxCopRuleValidationResult result = validator.Execute();

            // Assert
            result.ProblemText.Should().Be(FxCopRuleValidationResult.NoProblemsText);
        }
开发者ID:bkoelman,项目名称:ResharperCodeContractNullabilityFxCop,代码行数:20,代码来源:Bugfixes.cs

示例8: When_lambda_return_value_is_nullable_it_must_be_skipped

        public void When_lambda_return_value_is_nullable_it_must_be_skipped()
        {
            // Arrange
            FxCopRuleValidator validator = new FxCopNullabilityRuleValidatorBuilder()
                .ForRule<NullabilityRule>()
                .OnAssembly(new MemberSourceCodeBuilder()
                    .InDefaultClass(@"
                        public void M()
                        {
                            Func<int, string> f = p => null;
                        }
                    "))
                .Build();

            // Act
            FxCopRuleValidationResult result = validator.Execute();

            // Assert
            result.ProblemText.Should().Be(FxCopRuleValidationResult.NoProblemsText);
        }
开发者ID:bkoelman,项目名称:ResharperCodeContractNullabilityFxCop,代码行数:20,代码来源:LambdaSpecs.cs

示例9: FxCopNullabilityRuleValidatorBuilder

        public void When_deriving_constructed_arrays_from_externally_annotated_class_with_open_array_types_it_must_be_skipped()
        {
            // Arrange
            FxCopRuleValidator validator = new FxCopNullabilityRuleValidatorBuilder()
                .ForRule<NullabilityRule>()
                .OnAssembly(new ClassSourceCodeBuilder()
                    .InGlobalScope(@"
                        public abstract class B<T>
                        {
                            public abstract T[] P { get; }

                            public abstract T[] M(T[] p, int i);
                        }

                        public class D : B<string>
                        {
                            public override string[] P { get { throw new NotImplementedException(); } }

                            public override string[] M(string[] p, int i) { throw new NotImplementedException(); }
                        }
                    "))
                .ExternallyAnnotated(new ExternalAnnotationsBuilder()
                    .IncludingMember(new ExternalAnnotationFragmentBuilder()
                        .Named("P:B`1.P")
                        .NotNull())
                    .IncludingMember(new ExternalAnnotationFragmentBuilder()
                        .Named("M:B`1.M(`0[],System.Int32)")
                        .NotNull()
                        .WithParameter(new ExternalAnnotationParameterBuilder()
                            .Named("p")
                            .NotNull())))
                .Build();

            // Act
            FxCopRuleValidationResult result = validator.Execute();

            // Assert
            result.ProblemText.Should().Be(FxCopRuleValidationResult.NoProblemsText);
        }
开发者ID:bkoelman,项目名称:ResharperCodeContractNullabilityFxCop,代码行数:39,代码来源:Bugfixes.cs

示例10: When_property_type_is_lazy_it_must_be_reported

        public void When_property_type_is_lazy_it_must_be_reported()
        {
            // Arrange
            FxCopRuleValidator validator = new FxCopNullabilityRuleValidatorBuilder()
                .ForRule<ItemNullabilityRule>()
                .OnAssembly(new MemberSourceCodeBuilder()
                    .InDefaultClass(@"
                    Lazy<string> P { get; set; }
                "))
                .Build();

            // Act
            FxCopRuleValidationResult result = validator.Execute();

            // Assert
            result.Problems.Should().HaveCount(1);
            result.Problems[0].Resolution.Name.Should().Be(ItemNullabilityRule.RuleName);
        }
开发者ID:FeodorFitsner,项目名称:ResharperCodeContractNullabilityFxCop,代码行数:18,代码来源:PropertyCollectionSpecs.cs

示例11: When_return_value_in_implicit_interface_is_not_annotated_with_explicit_interface_it_must_be_reported

        public void When_return_value_in_implicit_interface_is_not_annotated_with_explicit_interface_it_must_be_reported()
        {
            // Arrange
            FxCopRuleValidator validator = new FxCopNullabilityRuleValidatorBuilder()
                .ForRule<NullabilityRule>()
                .OnAssembly(new ClassSourceCodeBuilder()
                    .InGlobalScope(@"
                        interface I
                        {
                            [NotNull]
                            string M();
                        }

                        class C : I
                        {
                            // implicitly inherits decoration from interface
                            string I.M() { throw new NotImplementedException(); }

                            // requires explicit decoration
                            public string M() { throw new NotImplementedException(); }
                        }
                    "))
                .Build();

            // Act
            FxCopRuleValidationResult result = validator.Execute();

            // Assert
            result.Problems.Should().HaveCount(1);
            result.Problems[0].Resolution.Name.Should().Be(NullabilityRule.RuleName);
        }
开发者ID:FeodorFitsner,项目名称:ResharperCodeContractNullabilityFxCop,代码行数:31,代码来源:MethodReturnValueSpecs.cs

示例12: FxCopNullabilityRuleValidatorBuilder

        public void When_return_value_in_implicit_interface_is_annotated_with_externally_annotated_explicit_interface_it_must_be_skipped()
        {
            // Arrange
            FxCopRuleValidator validator = new FxCopNullabilityRuleValidatorBuilder()
                .ForRule<NullabilityRule>()
                .OnAssembly(new ClassSourceCodeBuilder()
                    .InGlobalScope(@"
                        namespace N
                        {
                            interface I
                            {
                                string M();
                            }

                            class C : I
                            {
                                // implicitly inherits decoration from interface
                                string I.M() { throw new NotImplementedException(); }

                                // requires explicit decoration
                                [NotNull]
                                public string M() { throw new NotImplementedException(); }
                            }
                        }
                    "))
                .ExternallyAnnotated(new ExternalAnnotationsBuilder()
                    .IncludingMember(new ExternalAnnotationFragmentBuilder()
                        .Named("M:N.I.M")
                        .CanBeNull()))
                .Build();

            // Act
            FxCopRuleValidationResult result = validator.Execute();

            // Assert
            result.ProblemText.Should().Be(FxCopRuleValidationResult.NoProblemsText);
        }
开发者ID:FeodorFitsner,项目名称:ResharperCodeContractNullabilityFxCop,代码行数:37,代码来源:MethodReturnValueSpecs.cs

示例13: When_return_value_in_implicit_interface_is_annotated_it_must_be_skipped

        public void When_return_value_in_implicit_interface_is_annotated_it_must_be_skipped()
        {
            // Arrange
            FxCopRuleValidator validator = new FxCopNullabilityRuleValidatorBuilder()
                .ForRule<NullabilityRule>()
                .OnAssembly(new ClassSourceCodeBuilder()
                    .InGlobalScope(@"
                        interface I
                        {
                            [CanBeNull]
                            string M();
                        }

                        class C : I
                        {
                            // implicitly inherits decoration from interface
                            public string M() { throw new NotImplementedException(); }
                        }
                    "))
                .Build();

            // Act
            FxCopRuleValidationResult result = validator.Execute();

            // Assert
            result.ProblemText.Should().Be(FxCopRuleValidationResult.NoProblemsText);
        }
开发者ID:FeodorFitsner,项目名称:ResharperCodeContractNullabilityFxCop,代码行数:27,代码来源:MethodReturnValueSpecs.cs

示例14: When_return_value_in_base_class_is_externally_annotated_it_must_be_skipped

        public void When_return_value_in_base_class_is_externally_annotated_it_must_be_skipped()
        {
            // Arrange
            FxCopRuleValidator validator = new FxCopNullabilityRuleValidatorBuilder()
                .ForRule<NullabilityRule>()
                .OnAssembly(new ClassSourceCodeBuilder()
                    .InGlobalScope(@"
                        namespace N
                        {
                            class B
                            {
                                public virtual string M() { throw new NotImplementedException(); }
                            }

                            class D1 : B { }

                            class D2 : D1
                            {
                                // implicitly inherits decoration from base class
                                public override string M() { throw new NotImplementedException(); }
                            }
                        }
                    "))
                .ExternallyAnnotated(new ExternalAnnotationsBuilder()
                    .IncludingMember(new ExternalAnnotationFragmentBuilder()
                        .Named("M:N.B.M")
                        .NotNull()))
                .Build();

            // Act
            FxCopRuleValidationResult result = validator.Execute();

            // Assert
            result.ProblemText.Should().Be(FxCopRuleValidationResult.NoProblemsText);
        }
开发者ID:FeodorFitsner,项目名称:ResharperCodeContractNullabilityFxCop,代码行数:35,代码来源:MethodReturnValueSpecs.cs

示例15: When_override_breaks_inheritance_it_must_be_reported

        public void When_override_breaks_inheritance_it_must_be_reported()
        {
            // Arrange
            FxCopRuleValidator validator = new FxCopNullabilityRuleValidatorBuilder()
                .ForRule<NullabilityRule>()
                .OnAssembly(new ClassSourceCodeBuilder()
                    .InGlobalScope(@"
                    namespace N
                    {
                        public class B
                        {
                            [NotNull]
                            public virtual string M() { throw new NotImplementedException(); }
                        }

                        public class C : B
                        {
                            public new string M() { throw new NotImplementedException(); }
                        }
                    }
                    "))
                .Build();

            // Act
            FxCopRuleValidationResult result = validator.Execute();

            // Assert
            result.Problems.Should().HaveCount(1);
            result.Problems[0].Resolution.Name.Should().Be(NullabilityRule.RuleName);
        }
开发者ID:FeodorFitsner,项目名称:ResharperCodeContractNullabilityFxCop,代码行数:30,代码来源:MethodReturnValueSpecs.cs


注:本文中的FxCopNullabilityRuleValidatorBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。