• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# FxCopNullabilityRuleValidatorBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: When_property_in_implicit_interface_is_not_annotated_with_explicit_interface_it_must_be_reported

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

                        class C : I
                        {
                            // implicitly inherits decoration from interface
                            IEnumerable<string> I.P { get; set; }

                            // requires explicit decoration
                            public IEnumerable<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,代码行数:32,代码来源:PropertyCollectionSpecs.cs


示例17: When_method_is_not_debuggable_it_must_be_skipped

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

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

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


示例18: When_return_value_type_is_generic_nullable_it_must_be_reported

        public void When_return_value_type_is_generic_nullable_it_must_be_reported()
        {
            // Arrange
            FxCopRuleValidator validator = new FxCopNullabilityRuleValidatorBuilder()
                .ForRule<NullabilityRule>()
                .OnAssembly(new ClassSourceCodeBuilder()
                    .InGlobalScope(@"
                        class C<T> where T : struct
                        {
                            T? 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,代码行数:21,代码来源:MethodReturnValueSpecs.cs


示例19: When_return_value_type_is_reference_it_must_be_reported

        public void When_return_value_type_is_reference_it_must_be_reported()
        {
            // Arrange
            FxCopRuleValidator validator = new FxCopNullabilityRuleValidatorBuilder()
                .ForRule<NullabilityRule>()
                .OnAssembly(new MemberSourceCodeBuilder()
                    .InDefaultClass(@"
                        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,代码行数:18,代码来源:MethodReturnValueSpecs.cs


示例20: When_return_value_is_externally_annotated_it_must_be_skipped

        public void When_return_value_is_externally_annotated_it_must_be_skipped()
        {
            // Arrange
            FxCopRuleValidator validator = new FxCopNullabilityRuleValidatorBuilder()
                .ForRule<NullabilityRule>()
                .OnAssembly(new ClassSourceCodeBuilder()
                    .InGlobalScope(@"
                        namespace N
                        {
                            class C
                            {
                                string M() { throw new NotImplementedException(); }
                            }
                        }
                    "))
                .ExternallyAnnotated(new ExternalAnnotationsBuilder()
                    .IncludingMember(new ExternalAnnotationFragmentBuilder()
                        .Named("M:N.C.M")
                        .NotNull()))
                .Build();

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

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# G25类代码示例发布时间:2022-05-24
下一篇:
C# FwStyleSheet类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap