コード例 #1
0
        public void IMM004MemberPropsWhitelistedByConfiguration()
        {
            var code = GetCode(@"
        [Immutable]
        class Test
        {
            public Action a {get;}
        }
");

            string whitelist = $"System.Action";
            var    test      = new CSharpCodeFixVerifier <ApexAnalyzersImmutableAnalyzer, ApexAnalyzersImmutableCodeFixProvider> .Test();

            test.TestCode = code;
            test.AdditionalFiles.Add(new AdditionalFile("ImmutableTypes.txt", whitelist));
            test.Run();
        }
コード例 #2
0
        public void IMM003MemberFieldsWhitelistedByConfiguration()
        {
            var code = GetCode(@"
        [Immutable]
        class Test
        {
            private readonly Func<int> a;
        }
");

            string whitelist = $"System.Func`1";
            var    test      = new CSharpCodeFixVerifier <ApexAnalyzersImmutableAnalyzer, ApexAnalyzersImmutableCodeFixProvider> .Test();

            test.TestCode = code;
            test.AdditionalFiles.Add(new AdditionalFile("ImmutableTypes.txt", whitelist));
            test.Run();
        }
コード例 #3
0
        public void IMM003ImmutableDelegatesDoNotCheckTypeParametersForImmutability()
        {
            var    code      = GetCode(@"
        class NotImmutable {}

        [Immutable]
        class Test
        {
            private readonly Func<NotImmutable> a;
        }
");
            string whitelist = $"System.Func`1";
            var    test      = new CSharpCodeFixVerifier <ApexAnalyzersImmutableAnalyzer, ApexAnalyzersImmutableCodeFixProvider> .Test();

            test.TestCode = code;
            test.AdditionalFiles.Add(new AdditionalFile("ImmutableTypes.txt", whitelist));
            test.Run();
        }