Пример #1
0
        public string RemoveAttributes(string fileContents)
        {
            var tree          = CSharpSyntaxTree.ParseText(fileContents);
            var rewrittenRoot = _remover.Visit(tree.GetRoot());

            return(rewrittenRoot.GetText().ToString());
        }
Пример #2
0
        public void RemovesProtoAttributesWhenAttributesAlreadyExists()
        {
            var tree     = CSharpSyntaxTree.ParseText(_fixture.LoadTestFile(@"./Mocks/TestRemoveAttributes.cs"));
            var rewriter = new ProtoAttributeRemover();

            var rewrittenRoot = rewriter.Visit(tree.GetRoot());

            var output = rewrittenRoot.GetText().ToString();

            output.Should().NotContain("ProtoBuf");
            output.Should().NotContain("[ProtoContract]");
            output.Should().NotContain("[ProtoInclude]");
            output.Should().NotContain("[ProtoEnum]");
            output.Should().NotContain("[ProtoIgnore]");
            output.Should().NotContain(@"[ProtoMember(1, Name=""Test"")]");
            output.Should().NotContain("[ProtoMember(2)]");

            output.Should().Contain("[Required]");

            output.Should().Contain("[Serializable]");
        }