Example #1
0
    protected void ParseHeader(){
      byte header = this.reader.tables.GetMethodBodyHeaderByte(this.RVA);
      if ((header & 0x3) == 2){
        this.size = header >> 2;
        this.bodyReader = this.reader.tables.GetNewCursor();
        this.reader.tables.Skip(size);
      }else{    
        method.InitLocals = (header & 0x10) != 0;
        byte header2 = this.reader.tables.GetByte();
        int fatHeaderSize = header2 >> 4;
        if (fatHeaderSize == 2) return;
        if (fatHeaderSize != 3) throw new InvalidMetadataException(ExceptionStrings.InvalidFatMethodHeader);
        this.reader.tables.Skip(2); //Skip over maxstack. No need to remember it.
        this.size = this.reader.tables.GetInt32();
        int localIndex = this.reader.tables.GetInt32();
        this.bodyReader = this.reader.tables.GetNewCursor();
        this.reader.tables.Skip(size);
        this.reader.tables.AlignTo32BitBoundary();
        while ((header & 0x8) != 0){
          header = this.reader.tables.GetByte();
          if ((header & 3) != 1) throw new InvalidMetadataException(ExceptionStrings.BadMethodHeaderSection);
          if ((header & 0x80) != 0) throw new InvalidMetadataException(ExceptionStrings.TooManyMethodHeaderSections);
          this.ParseExceptionHandlerEntry((header & 0x40) == 0);
        }
        Hashtable localSourceNames = new Hashtable();
#if UseSingularityPDB
        if (this.reader.getDebugSymbols && this.reader.pdbFunctions != null) {
          PdbFunction pdbFunc = this.reader.GetPdbFunction(0x6000000|(uint)methodIndex);
          if (pdbFunc != null)
            this.GetLocalNames(pdbFunc.scopes, localSourceNames);
        }
#elif !ROTOR
        if (this.reader.getDebugSymbols && this.reader.debugReader != null){
          ISymUnmanagedMethod methodInfo = null;
          try{
            try{
              this.reader.debugReader.GetMethod(0x6000000|(uint)methodIndex, ref methodInfo);
              if (methodInfo != null){
                ISymUnmanagedScope rootScope = methodInfo.GetRootScope();
                try{
                  this.reader.GetLocalSourceNames(rootScope, localSourceNames);
                }
                finally{
                  if (rootScope != null)
                    Marshal.ReleaseComObject(rootScope);
                }
              }
            }
            catch (COMException){
            }
            catch (InvalidCastException){
            }
            catch (System.Runtime.InteropServices.InvalidComObjectException){}            
          }
          finally{
            if (methodInfo != null)
              Marshal.ReleaseComObject(methodInfo);
          }
        }
#endif
        this.reader.GetLocals(localIndex, this.locals, localSourceNames);
      }
    }
Example #2
0
    internal ILParser(Reader/*!*/ reader, Method/*!*/ method, int methodIndex, int RVA) {
      this.reader = reader;
      this.bodyReader = reader.tables.GetNewCursor();
      this.method = method;
#if !FxCop
      this.method.LocalList = this.locals;
#else
      this.method.Locals = this.locals;
#endif
      this.methodIndex = methodIndex;
      this.RVA = RVA;
      //^ base();
    }
        public async Task RunAsync_WhenExceptionOccurs_DoesNotSkipPackage(string catalogUri, string expectedCursorBeforeRetry)
        {
            // Arrange
            var catalogStorage = Catalogs.CreateTestCatalogWithCommitThenTwoPackageCommit();
            await _mockServer.AddStorageAsync(catalogStorage);

            _mockServer.SetAction(
                "/packages/unlistedpackage.1.0.0.nupkg",
                request => Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StreamContent(File.OpenRead("Packages\\UnlistedPackage.1.0.0.zip"))
            }));
            _mockServer.SetAction(
                "/packages/listedpackage.1.0.1.nupkg",
                request => Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StreamContent(File.OpenRead("Packages\\ListedPackage.1.0.1.zip"))
            }));
            _mockServer.SetAction(
                "/packages/anotherpackage.1.0.0.nupkg",
                request => Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StreamContent(File.OpenRead("Packages\\ListedPackage.1.0.0.zip"))
            }));

            // Make the first request for a catalog leaf node fail. This will cause the registration collector
            // to fail the first time but pass the second time.
            FailFirstRequest(catalogUri);

            expectedCursorBeforeRetry = expectedCursorBeforeRetry ?? MemoryCursor.MinValue.ToString("O");

            var front = new DurableCursor(
                _cursorJsonUri,
                _catalogToDnxStorage,
                MemoryCursor.MinValue);
            ReadCursor back = MemoryCursor.CreateMax();

            // Act
            await Assert.ThrowsAsync <HttpRequestException>(() => _target.RunAsync(front, back, CancellationToken.None));

            var cursorBeforeRetry = front.Value;
            await _target.RunAsync(front, back, CancellationToken.None);

            var cursorAfterRetry = front.Value;

            // Assert
            var unlistedPackage100 = _catalogToDnxStorage
                                     .Content
                                     .FirstOrDefault(pair => pair.Key.PathAndQuery.EndsWith("/unlistedpackage/1.0.0/unlistedpackage.1.0.0.nupkg"));

            Assert.NotNull(unlistedPackage100.Key);

            var listedPackage101 = _catalogToDnxStorage
                                   .Content
                                   .FirstOrDefault(pair => pair.Key.PathAndQuery.EndsWith("/listedpackage/1.0.1/listedpackage.1.0.1.nupkg"));

            Assert.NotNull(listedPackage101.Key);

            var anotherPackage100 = _catalogToDnxStorage
                                    .Content
                                    .FirstOrDefault(pair => pair.Key.PathAndQuery.EndsWith("/anotherpackage/1.0.0/anotherpackage.1.0.0.nupkg"));

            Assert.NotNull(anotherPackage100.Key);

            Assert.Equal(DateTime.Parse(expectedCursorBeforeRetry).ToUniversalTime(), cursorBeforeRetry);
            Assert.Equal(DateTime.Parse("2015-10-12T10:08:55.3335317Z").ToUniversalTime(), cursorAfterRetry);
        }
Example #4
0
 internal MemoryCursor(MemoryCursor/*!*/ c) {
   this.buffer = c.buffer;
   this.pb = c.pb;
   this.Length = c.Length;
 }
Example #5
0
 internal MemoryCursor(MemoryCursor /*!*/ c)
 {
     this.buffer = c.buffer;
     this.pb     = c.pb;
     this.Length = c.Length;
 }