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

Add AssemblyExtensions.GetApplyUpdateCapabilities method #51954

Merged
4 commits merged into from
Apr 28, 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 @@ -81,5 +81,10 @@ public static void ApplyUpdate(Assembly assembly, ReadOnlySpan<byte> metadataDel
}
}
}

internal static string GetApplyUpdateCapabilities()
{
return "Baseline AddMethodToExistingType AddStaticFieldToExistingType AddInstanceFieldToExistingType NewTypeDefinition";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,13 @@
<method signature="System.Void Initialize()" />
</type>
</assembly>

<!-- methods used by hot reload.
TODO: once there's a feature flag, add it to the linker descriptor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the Debugger.IsSupported feature switch for now? That's what we did for MetadataUpdateHandlerAttribute.

<!-- Hot reload attributes-->
<type fullname="System.Reflection.Metadata.MetadataUpdateHandlerAttribute">
<attribute internal="RemoveAttributeInstances" />
</type>

I can put a PR to fix this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that makes sense to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened #51994

-->
<assembly fullname="System.Private.CoreLib">
<type fullname="System.Reflection.Metadata.AssemblyExtensions">
<method name="GetApplyUpdateCapabilities" />
</type>
</assembly>
</linker>
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,19 @@ public static void ApplyUpdateInvalidParameters()
AssemblyExtensions.ApplyUpdate(typeof(AssemblyExtensions).Assembly, new ReadOnlySpan<byte>(metadataDelta), new ReadOnlySpan<byte>(ilDelta), ReadOnlySpan<byte>.Empty));
}
}

[Fact]
public void GetApplyUpdateCapabilitiesIsCallable()
{
var ty = typeof(System.Reflection.Metadata.AssemblyExtensions);
var mi = ty.GetMethod("GetApplyUpdateCapabilities", BindingFlags.NonPublic | BindingFlags.Static, Array.Empty<Type>());

Assert.NotNull(mi);

var result = mi.Invoke(null, null);

Assert.NotNull(result);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's bit odd to check for notnull if the return value is not declared as nullable

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nullable annotations are just a suggestions. They do not guarantee any behavior. We have similar checks in many other tests.

lambdageek marked this conversation as resolved.
Show resolved Hide resolved
Assert.Equal(typeof(string), result.GetType());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ public static void ApplyUpdate(Assembly assembly, ReadOnlySpan<byte> metadataDel
#endif
}

internal static void ApplyUpdateSdb(Assembly assembly, byte[] metadataDelta, byte[] ilDelta, byte[]? pdbDelta)
internal static string GetApplyUpdateCapabilities()
{
ReadOnlySpan<byte> md = metadataDelta;
ReadOnlySpan<byte> il = ilDelta;
ReadOnlySpan<byte> dpdb = pdbDelta == null ? default : pdbDelta;
ApplyUpdate (assembly, md, il, dpdb);
#if !FEATURE_METADATA_UPDATE
return string.Empty;
#else
return "Baseline";
#endif
}

#if FEATURE_METADATA_UPDATE
Expand Down