Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EnC: Include added types in changed types of emit result #55099

Merged
merged 4 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.IO;
using System.Reflection.Metadata;
Expand Down Expand Up @@ -35,9 +36,6 @@ internal static EmitDifferenceResult EmitDifference(
var serializationProperties = compilation.ConstructModuleSerializationProperties(emitOptions, runtimeMDVersion, baseline.ModuleVersionId);
var manifestResources = SpecializedCollections.EmptyEnumerable<ResourceDescription>();

var updatedMethods = ArrayBuilder<MethodDefinitionHandle>.GetInstance();
var updatedTypes = ArrayBuilder<TypeDefinitionHandle>.GetInstance();

PEDeltaAssemblyBuilder moduleBeingBuilt;
try
{
Expand All @@ -55,7 +53,12 @@ internal static EmitDifferenceResult EmitDifference(
{
// TODO: https://github.com/dotnet/roslyn/issues/9004
diagnostics.Add(ErrorCode.ERR_ModuleEmitFailure, NoLocation.Singleton, compilation.AssemblyName, e.Message);
return new EmitDifferenceResult(success: false, diagnostics: diagnostics.ToReadOnlyAndFree(), baseline: null, updatedMethods: updatedMethods.ToImmutableAndFree(), updatedTypes: updatedTypes.ToImmutableAndFree());
return new EmitDifferenceResult(
success: false,
diagnostics: diagnostics.ToReadOnlyAndFree(),
baseline: null,
updatedMethods: ImmutableArray<MethodDefinitionHandle>.Empty,
changedTypes: ImmutableArray<TypeDefinitionHandle>.Empty);
}

if (testData != null)
Expand All @@ -69,6 +72,8 @@ internal static EmitDifferenceResult EmitDifference(
Debug.Assert(changes != null);

EmitBaseline? newBaseline = null;
var updatedMethods = ArrayBuilder<MethodDefinitionHandle>.GetInstance();
var changedTypes = ArrayBuilder<TypeDefinitionHandle>.GetInstance();

if (compilation.Compile(
moduleBeingBuilt,
Expand All @@ -91,7 +96,7 @@ internal static EmitDifferenceResult EmitDifference(
ilStream,
pdbStream,
updatedMethods,
updatedTypes,
changedTypes,
diagnostics,
testData?.SymWriterFactory,
emitOptions.PdbFilePath,
Expand All @@ -103,7 +108,7 @@ internal static EmitDifferenceResult EmitDifference(
diagnostics: diagnostics.ToReadOnlyAndFree(),
baseline: newBaseline,
updatedMethods: updatedMethods.ToImmutableAndFree(),
updatedTypes: updatedTypes.ToImmutableAndFree());
changedTypes: changedTypes.ToImmutableAndFree());
}

/// <summary>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,31 @@ internal static void CheckNames(IList<MetadataReader> readers, IEnumerable<(Stri
AssertEx.Equal(expectedNames, actualNames);
}

public static void CheckNames(IList<MetadataReader> readers, ImmutableArray<TypeDefinitionHandle> typeHandles, params string[] expectedNames)
=> CheckNames(readers, typeHandles, (reader, handle) => reader.GetTypeDefinition((TypeDefinitionHandle)handle).Name, handle => handle, expectedNames);

public static void CheckNames(IList<MetadataReader> readers, ImmutableArray<MethodDefinitionHandle> methodHandles, params string[] expectedNames)
=> CheckNames(readers, methodHandles, (reader, handle) => reader.GetMethodDefinition((MethodDefinitionHandle)handle).Name, handle => handle, expectedNames);

private static void CheckNames<THandle>(
IList<MetadataReader> readers,
ImmutableArray<THandle> entityHandles,
Func<MetadataReader, Handle, StringHandle> getName,
Func<THandle, Handle> toHandle,
string[] expectedNames)
{
var aggregator = new MetadataAggregator(readers[0], readers.Skip(1).ToArray());

AssertEx.Equal(expectedNames, entityHandles.Select(handle =>
{
var genEntityHandle = aggregator.GetGenerationHandle(toHandle(handle), out int typeGeneration);
var nameHandle = getName(readers[typeGeneration], genEntityHandle);

var genNameHandle = (StringHandle)aggregator.GetGenerationHandle(nameHandle, out int nameGeneration);
return readers[nameGeneration].GetString(genNameHandle);
}));
}

internal static string EncLogRowToString(EditAndContinueLogEntry row)
{
TableIndex tableIndex;
Expand Down
Loading