internal CompilationDifference(
     ImmutableArray <byte> metadata,
     ImmutableArray <byte> il,
     ImmutableArray <byte> pdb,
     CompilationTestData testData,
     EmitDifferenceResult result)
 {
     MetadataDelta = metadata;
     ILDelta       = il;
     PdbDelta      = pdb;
     TestData      = testData;
     EmitResult    = result;
 }
Exemplo n.º 2
0
 public Deltas(
     byte[] il,
     byte[] metadata,
     int[] updatedMethods,
     MemoryStream pdb,
     List <KeyValuePair <DocumentId, ImmutableArray <LineChange> > > lineEdits,
     EmitDifferenceResult emitResult)
 {
     this.IL         = new ILDelta(il);
     this.Metadata   = new MetadataDelta(metadata);
     this.Pdb        = new PdbDelta(pdb, updatedMethods);
     this.EmitResult = emitResult;
     this.LineEdits  = lineEdits;
 }
Exemplo n.º 3
0
 public CompilationDifference(
     ImmutableArray <byte> metadata,
     ImmutableArray <byte> il,
     ImmutableArray <byte> pdb,
     CompilationTestData testData,
     EmitDifferenceResult result,
     ImmutableArray <MethodDefinitionHandle> methodHandles)
 {
     MetadataDelta  = metadata;
     ILDelta        = il;
     PdbDelta       = pdb;
     TestData       = testData;
     EmitResult     = result;
     UpdatedMethods = methodHandles;
 }
Exemplo n.º 4
0
 public CompilationDifference(
     ImmutableArray <byte> metadata,
     ImmutableArray <byte> il,
     Stream pdbStream,
     CompilationTestData testData,
     EmitDifferenceResult result,
     ImmutableArray <MethodDefinitionHandle> methodHandles)
 {
     this.MetadataDelta  = metadata;
     this.ILDelta        = il;
     this.PdbDelta       = pdbStream;
     this.TestData       = testData;
     this.EmitResult     = result;
     this.UpdatedMethods = methodHandles;
 }
Exemplo n.º 5
0
 public CompilationDifference(
     ImmutableArray <byte> metadata,
     ImmutableArray <byte> il,
     Stream pdbStream,
     EmitBaseline nextGeneration,
     CompilationTestData testData,
     EmitDifferenceResult result,
     ImmutableArray <uint> methodTokens)
 {
     this.MetadataDelta  = metadata;
     this.ILDelta        = il;
     this.PdbDelta       = pdbStream;
     this.NextGeneration = nextGeneration;
     this.TestData       = testData;
     this.EmitResult     = result;
     this.UpdatedMethods = methodTokens;
 }
Exemplo n.º 6
0
        public async Task <Deltas> EmitProjectDeltaAsync(Project project, EmitBaseline baseline, CancellationToken cancellationToken)
        {
            try
            {
                Debug.Assert(!_stoppedAtException);

                var changes = await GetProjectChangesAsync(project, cancellationToken).ConfigureAwait(false);

                var currentCompilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);

                var allAddedSymbols = await GetAllAddedSymbols(cancellationToken).ConfigureAwait(false);

                var pdbStream      = new MemoryStream();
                var updatedMethods = new List <MethodDefinitionHandle>();

                using (var metadataStream = SerializableBytes.CreateWritableStream())
                    using (var ilStream = SerializableBytes.CreateWritableStream())
                    {
                        EmitDifferenceResult result = currentCompilation.EmitDifference(
                            baseline,
                            changes.SemanticEdits,
                            s => allAddedSymbols?.Contains(s) ?? false,
                            metadataStream,
                            ilStream,
                            pdbStream,
                            updatedMethods,
                            cancellationToken);

                        int[] updateMethodTokens = updatedMethods.Select(h => MetadataTokens.GetToken(h)).ToArray();
                        return(new Deltas(ilStream.ToArray(), metadataStream.ToArray(), updateMethodTokens, pdbStream, changes.LineChanges, result));
                    }
            }
            catch (Exception e) when(FatalError.ReportWithoutCrash(e))
            {
                // recover (cancel EnC)
                return(null);
            }
        }
Exemplo n.º 7
0
 public static StringHandle[] GetUpdatedTypeDefNames(this MetadataReader reader, EmitDifferenceResult emitResult)
 {
     return(emitResult.UpdatedTypes.Select(handle => reader.GetTypeDefinition(handle).Name).ToArray());
 }
Exemplo n.º 8
0
        public async Task <Deltas> EmitProjectDeltaAsync(Project project, EmitBaseline baseline, CancellationToken cancellationToken)
        {
            try
            {
                Debug.Assert(!_stoppedAtException);

                var projectChanges = await GetProjectChangesAsync(project, cancellationToken).ConfigureAwait(false);

                var currentCompilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);

                var allAddedSymbols = await GetAllAddedSymbolsAsync(project, cancellationToken).ConfigureAwait(false);

                var baseActiveStatements = await BaseActiveStatements.GetValueAsync(cancellationToken).ConfigureAwait(false);

                var baseActiveExceptionRegions = await BaseActiveExceptionRegions.GetValueAsync(cancellationToken).ConfigureAwait(false);

                var pdbStream      = new MemoryStream();
                var updatedMethods = new List <MethodDefinitionHandle>();

                using (var metadataStream = SerializableBytes.CreateWritableStream())
                    using (var ilStream = SerializableBytes.CreateWritableStream())
                    {
                        EmitDifferenceResult result = currentCompilation.EmitDifference(
                            baseline,
                            projectChanges.SemanticEdits,
                            s => allAddedSymbols?.Contains(s) ?? false,
                            metadataStream,
                            ilStream,
                            pdbStream,
                            updatedMethods,
                            cancellationToken);

                        int[] updatedMethodTokens = updatedMethods.Select(h => MetadataTokens.GetToken(h)).ToArray();

                        // Determine all active statements whose span changed and exception region span deltas.

                        GetActiveStatementAndExceptionRegionSpans(
                            baseline.OriginalMetadata.GetModuleVersionId(),
                            baseActiveStatements,
                            baseActiveExceptionRegions,
                            updatedMethodTokens,
                            _nonRemappableRegions,
                            projectChanges.NewActiveStatements,
                            out var activeStatementsInUpdatedMethods,
                            out var nonRemappableRegions);

                        return(new Deltas(
                                   ilStream.ToArray(),
                                   metadataStream.ToArray(),
                                   pdbStream,
                                   updatedMethodTokens,
                                   projectChanges.LineChanges,
                                   nonRemappableRegions,
                                   activeStatementsInUpdatedMethods,
                                   result));
                    }
            }
            catch (Exception e) when(FatalError.ReportWithoutCrashAndPropagate(e))
            {
                throw ExceptionUtilities.Unreachable;
            }
        }