Ejemplo n.º 1
0
            public MethodDebugInfoBytes Build()
            {
                // Global header
                _bytesBuilder.Insert(0, Version);
                _bytesBuilder.Insert(1, (byte)_recordCount);
                _bytesBuilder.Insert(2, Padding);
                _bytesBuilder.Insert(3, Padding);

                Assert.Equal(0, _bytesBuilder.Count % 4);

                var info = new MethodDebugInfoBytes(_bytesBuilder.ToImmutableAndFree(), _method);

                _bytesBuilder = null; // We'll blow up if any other methods are called.
                return(info);
            }
Ejemplo n.º 2
0
        private static void GetLocals(RuntimeInstance runtime, string methodName, MethodDebugInfoBytes debugInfo, ArrayBuilder<LocalAndMethod> locals, int count)
        {
            ImmutableArray<MetadataBlock> blocks;
            Guid moduleVersionId;
            ISymUnmanagedReader unused;
            int methodToken;
            int localSignatureToken;
            GetContextState(runtime, methodName, out blocks, out moduleVersionId, out unused, out methodToken, out localSignatureToken);

            var symReader = new MockSymUnmanagedReader(
                new Dictionary<int, MethodDebugInfoBytes>()
                {
                    {methodToken, debugInfo}
                }.ToImmutableDictionary());
            var context = EvaluationContext.CreateMethodContext(
                default(CSharpMetadataContext),
                blocks,
                symReader,
                moduleVersionId,
                methodToken,
                methodVersion: 1,
                ilOffset: 0,
                localSignatureToken: localSignatureToken);

            string typeName;
            var assembly = context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: null);

            Assert.NotNull(assembly);
            if (count == 0)
            {
                Assert.Equal(0, assembly.Count);
            }
            else
            {
                Assert.InRange(assembly.Count, 0, int.MaxValue);
            }
            Assert.Equal(count, locals.Count);
        }
            public MethodDebugInfoBytes Build()
            {
                // Global header
                _bytesBuilder.Insert(0, Version);
                _bytesBuilder.Insert(1, (byte)_recordCount);
                _bytesBuilder.Insert(2, Padding);
                _bytesBuilder.Insert(3, Padding);

                Assert.Equal(0, _bytesBuilder.Count % 4);

                var info = new MethodDebugInfoBytes(_bytesBuilder.ToImmutableAndFree(), _method);
                _bytesBuilder = null; // We'll blow up if any other methods are called.
                return info;
            }