Esempio n. 1
0
        private static unsafe void TestAllPrefixes(string ns)
        {
            byte[] bytes = Encoding.UTF8.GetBytes(ns + '\0');
            fixed (byte* fbytes = &bytes[0]) {
                MetadataNamePart name = new MetadataName(fbytes, null).GetExtent();
                int dot = name.Length;

                while (true) {
                    int nextDot = name.LastIndexOf((byte)'.', dot - 1, dot);
                    Assert(nextDot == ns.LastIndexOf('.', dot - 1, dot));
                    dot = nextDot;
                    if (dot < 0) {
                        break;
                    }
                    Assert(name.GetPart(0, dot).ToString() == ns.Substring(0, dot));
                    Assert(name.GetPart(dot + 1).ToString() == ns.Substring(dot + 1));
                }
            }
        }
Esempio n. 2
0
        public unsafe void TestAllPrefixes(string ns)
        {
            byte[] bytes = Encoding.UTF8.GetBytes(ns + '\0');
            fixed(byte *fbytes = &bytes[0])
            {
                MetadataNamePart name = new MetadataName(fbytes, null).GetExtent();
                int dot = name.Length;

                while (true)
                {
                    int nextDot = name.LastIndexOf((byte)'.', dot - 1, dot);
                    Assert.That(nextDot, Is.EqualTo(ns.LastIndexOf('.', dot - 1, dot)));
                    dot = nextDot;
                    if (dot < 0)
                    {
                        break;
                    }
                    Assert.That(name.GetPart(0, dot).ToString(), Is.EqualTo(ns.Substring(0, dot)));
                    Assert.That(name.GetPart(dot + 1).ToString(), Is.EqualTo(ns.Substring(dot + 1)));
                }
            }
        }