public void SSTDeclaration_WithSupertypes_OnlySuperclass()
        {
            var thisType  = Names.Type("TestClass,P");
            var superType = Names.Type("SuperClass,P");

            var sst = new SST {
                EnclosingType = thisType
            };
            var typeShape = new TypeShape
            {
                TypeHierarchy = new TypeHierarchy
                {
                    Element = thisType,
                    Extends = new TypeHierarchy {
                        Element = superType
                    }
                }
            };

            AssertPrintWithCustomContext(
                sst,
                new SSTPrintingContext {
                TypeShape = typeShape
            },
                "class TestClass : SuperClass",
                "{",
                "}");
        }
예제 #2
0
        public void ShouldGetThePrefix()
        {
            const string testPrefix = "SomeObj";

            var context = new StringBuilder();

            var sst = new SST();
            var methodDeclarationContainingCompletionExpression = new MethodDeclaration
            {
                Body =
                    Lists.NewList <IStatement>(
                        new ExpressionStatement
                {
                    Expression = new CompletionExpression {
                        Token = testPrefix
                    }
                })
            };

            sst.Methods.Add(methodDeclarationContainingCompletionExpression);

            sst.Accept(new CompletionPrefixVisitor(), context);

            Assert.AreEqual(testPrefix, context.ToString());
        }
        private void ReadSharedStrings(XmlReader reader)
        {
            if (!reader.IsStartElement(ElementSst, NsSpreadsheetMl))
            {
                return;
            }

            if (!XmlReaderHelper.ReadFirstContent(reader))
            {
                return;
            }

            while (!reader.EOF)
            {
                if (reader.IsStartElement(ElementStringItem, NsSpreadsheetMl))
                {
                    var value = ReadStringItem(reader);
                    SST.Add(value);
                }
                else if (!XmlReaderHelper.SkipContent(reader))
                {
                    break;
                }
            }
        }
예제 #4
0
        public void MethodDeclarationsAreAnonymized_EntryPointFlagIsNotChanged()
        {
            var actual = _sut.Anonymize(
                new SST
            {
                Methods =
                {
                    new MethodDeclaration {
                        IsEntryPoint = false
                    },
                    new MethodDeclaration {
                        IsEntryPoint = true
                    }
                }
            });

            var expected =
                new SST
            {
                Methods =
                {
                    new MethodDeclaration {
                        IsEntryPoint = false
                    },
                    new MethodDeclaration {
                        IsEntryPoint = true
                    }
                }
            };

            Assert.AreEqual(expected, actual);
        }
예제 #5
0
        public void Asd()
        {
            var eventDeclaration = new EventDeclaration
            {
                Name = Names.Event("[MyEvent, IO, 1.2.3.4] [DeclaringType, GUI, 5.6.7.8].E")
            };
            var fieldDeclaration = new FieldDeclaration
            {
                Name = Names.Field("[MyField, mscore, 4.0.0.0] [DeclaringType, mscore, 4.0.0.0]._f")
            };

            var sst = new SST {
                EnclosingType = Names.Type("MyType, mscore, 4.0.0.0")
            };

            sst.Events.Add(eventDeclaration);
            sst.Fields.Add(fieldDeclaration);

            var context = new StringBuilder();

            var sut = new ToStringVisitor();

            sst.Accept(sut, context);

            var          actual   = context.ToString();
            const string expected = "class MyType {\n\tevent MyEvent E;\n\tMyField _f;\n}\n";

            Assert.AreEqual(expected, actual);
        }
예제 #6
0
        public void Equality_ReallyTheSame()
        {
            var a = new SST
            {
                EnclosingType          = Names.Type("T1, P1"),
                PartialClassIdentifier = "abc",
                Delegates  = { new DelegateDeclaration() },
                Events     = { new EventDeclaration() },
                Fields     = { new FieldDeclaration() },
                Methods    = { new MethodDeclaration() },
                Properties = { new PropertyDeclaration() }
            };
            var b = new SST
            {
                EnclosingType          = Names.Type("T1, P1"),
                PartialClassIdentifier = "abc",
                Delegates  = { new DelegateDeclaration() },
                Events     = { new EventDeclaration() },
                Fields     = { new FieldDeclaration() },
                Methods    = { new MethodDeclaration() },
                Properties = { new PropertyDeclaration() }
            };

            Assert.AreEqual(a, b);
            Assert.AreEqual(a.GetHashCode(), b.GetHashCode());
        }
예제 #7
0
        public void AnonymizationIsDefaultSafe()
        {
            var actual   = _sut.Anonymize(new SST());
            var expected = new SST();

            Assert.AreEqual(expected, actual);
        }
예제 #8
0
 /// <summary>
 /// copies the different datasources from the SST BiffRecord
 /// </summary>
 /// <param name="sst">The SST BiffRecord </param>
 public void copySSTData(SST sst)
 {
     this.StringList = sst.StringList;
     this.FormatList = sst.FormatList;
     this.cstTotal   = sst.cstTotal;
     this.cstUnique  = sst.cstUnique;
 }
예제 #9
0
        // XmlElement ***************************************************************

        /// <summary>Creates an attribute for a XmlElement and appends it</summary>
        /// <param name="xelem">The XmlElement where the attribute should be added</param>
        /// <param name="name">The SSD-ID of the element, which will be converted with the NameCompressor and used as the name for the attribute</param>
        /// <param name="value">The value for the new attribute</param>
        public static void CreateAttribute(this XmlNode xelem, SST name, string value)
        {
            XmlAttribute NewAttribute = xelem.OwnerDocument.CreateAttribute(nc[name]);

            NewAttribute.Value = value;
            xelem.Attributes.Append(NewAttribute);
        }
        public void SSTDeclaration_WithSupertypes_OnlyInterface()
        {
            var thisType   = Names.Type("TestClass,P");
            var interface1 = Names.Type("i:IDoesSomething,P");

            var sst = new SST {
                EnclosingType = thisType
            };
            var typeShape = new TypeShape
            {
                TypeHierarchy = new TypeHierarchy
                {
                    Element    = thisType,
                    Implements =
                    {
                        new TypeHierarchy {
                            Element = interface1
                        }
                    }
                }
            };

            AssertPrintWithCustomContext(
                sst,
                new SSTPrintingContext {
                TypeShape = typeShape
            },
                "class TestClass : IDoesSomething",
                "{",
                "}");
        }
예제 #11
0
        public void Equality_Default()
        {
            var a = new SST();
            var b = new SST();

            Assert.AreEqual(a, b);
            Assert.AreEqual(a.GetHashCode(), b.GetHashCode());
        }
예제 #12
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = 397;
         hashCode = (hashCode * 397) ^ TypeShape.GetHashCode();
         hashCode = (hashCode * 397) ^ SST.GetHashCode();
         return(hashCode);
     }
 }
예제 #13
0
        public void PartialClassIdentifierCannotBeSetToEmpty()
        {
            var sut = new SST();

            Assert.Null(sut.PartialClassIdentifier);
            sut.PartialClassIdentifier = "";
            Assert.Null(sut.PartialClassIdentifier);
            sut.PartialClassIdentifier = "a";
            Assert.NotNull(sut.PartialClassIdentifier);
        }
예제 #14
0
        private void InitializeValue(SST entry, string lowname)
        {
#if DEBUG
            if (lowtable[(int)entry] != null)
            {
                Log.Write(Log.Level.Error, $"NameCompress Value \"{entry}\" already set.");
            }
#endif
            lowtable[(int)entry] = new Tuple <string, string>(entry.ToString(), lowname);
        }
예제 #15
0
        public void Equality_DifferentMethods()
        {
            var a = new SST {
                Methods = { new MethodDeclaration() }
            };
            var b = new SST();

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
예제 #16
0
        public void Equality_DifferentEvents()
        {
            var a = new SST {
                Events = { new EventDeclaration() }
            };
            var b = new SST();

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
예제 #17
0
        public void Equality_DifferentPartialClassId()
        {
            var a = new SST {
                PartialClassIdentifier = "abc"
            };
            var b = new SST();

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
예제 #18
0
        public void Equality_DifferentType()
        {
            var a = new SST {
                EnclosingType = Names.Type("T1, P1")
            };
            var b = new SST();

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
예제 #19
0
        public void ShouldUseEmptyStringAsDefault()
        {
            var context = new StringBuilder();

            var sst = new SST();

            sst.Accept(new CompletionPrefixVisitor(), context);

            Assert.AreEqual(string.Empty, context.ToString());
        }
예제 #20
0
        public void Equality_DifferentProperties()
        {
            var a = new SST {
                Properties = { new PropertyDeclaration() }
            };
            var b = new SST();

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
예제 #21
0
            // https://github.com/jbevain/cecil/blob/master/symbols/pdb/Microsoft.Cci.Pdb/CvInfo.cs
            public CodeViewTypes(SST sst, int module, byte[] data) : base(sst, module, data)
            {
                var cvtl = new CodeViewTypeLoader(data);
                var dict = cvtl.Load();

                Console.WriteLine("== Type information for module {0}", module);
                foreach (var item in dict.OrderBy(d => d.Key))
                {
                    Dump(item.Key, item.Value.Leaves);
                }
            }
예제 #22
0
        private void Init(FileManager fm)
        {
            base.DAL                = fm.DALMngr;
            myFM                    = fm;
            myAtMng                 = fm.AtMng;
            RuleHandler             = fm.RuleHandler;
            MyDS                    = new SST();
            MyDS.EnforceConstraints = false;

            FixTZDSIssue(MyDS);
        }
예제 #23
0
 public string this[SST val]
 {
     get { if (Compress)
           {
               return(GetValComp(val));
           }
           else
           {
               return(GetValUnComp(val));
           } }
 }
예제 #24
0
        public string GetValUnComp(SST val)
        {
#if DEBUG
            if (lowtable[(int)val] == null)
            {
                Log.Write(Log.Level.Error, $"NameCompress Value \"{val}\" not found.");
                return(val.ToString());
            }
#endif
            return(lowtable[(int)val].Item1);
        }
예제 #25
0
        // XmlNode ******************************************************************

        /// <summary>Creates a new XmlElement with the NameCompressor SST Entry as the name.
        /// If name compression is enabled in the NameCompressor it will use the short name, otherwise the long one</summary>
        /// <param name="xelem">Any XmlNode from the used XmlDocument or the XmlDocument itself.
        /// Since the new XmlElement won't be added it doesn't matter</param>
        /// <param name="name">The SSD-ID of the element, which will be converted with the NameCompressor and used as the name for the XmlElement</param>
        /// <returns>Returns a new XmlElement with the give values</returns>
        public static XmlNode CreateCompressedElement(this XmlNode xelem, SST name)
        {
            if (xelem.NodeType == XmlNodeType.Document)
            {
                return(((XmlDocument)xelem).CreateElement(nc[name]));
            }
            else                //if (xelem.NodeType == XmlNodeType.Element)
            {
                return(xelem.OwnerDocument.CreateElement(nc[name]));
            }
        }
예제 #26
0
        public void PartialClassIdentifierIsAnonymized()
        {
            var actual = _sut.Anonymize(new SST {
                PartialClassIdentifier = "abc"
            });
            var expected = new SST {
                PartialClassIdentifier = "abc".ToHash()
            };

            Assert.AreEqual(expected, actual);
        }
        public void SSTDeclaration_EmptyClass()
        {
            var sst = new SST {
                EnclosingType = Names.Type("TestClass,TestProject")
            };

            AssertPrint(
                sst,
                "class TestClass",
                "{",
                "}");
        }
        public void SSTDeclaration_Enum()
        {
            var sst = new SST {
                EnclosingType = Names.Type("e:SomeEnum,P")
            };

            AssertPrint(
                sst,
                "enum SomeEnum",
                "{",
                "}");
        }
        public void SSTDeclaration_Struct()
        {
            var sst = new SST {
                EnclosingType = Names.Type("s:SomeStruct,P")
            };

            AssertPrint(
                sst,
                "struct SomeStruct",
                "{",
                "}");
        }
        public void SSTDeclaration_Interface()
        {
            var sst = new SST {
                EnclosingType = Names.Type("i:SomeInterface,P")
            };

            AssertPrint(
                sst,
                "interface SomeInterface",
                "{",
                "}");
        }