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

[Mono] trim hot reload #111247

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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 @@ -13,6 +13,7 @@

<!-- disabled due to https://github.com/dotnet/runtime/issues/65672 -->
<XUnitUseRandomizedTestOrderer>false</XUnitUseRandomizedTestOrderer>
<MetadataUpdaterSupport>true</MetadataUpdaterSupport>
</PropertyGroup>
<ItemGroup>
<Compile Include="ApplyUpdateTest.cs" />
Expand Down
27 changes: 14 additions & 13 deletions src/mono/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -639,19 +639,20 @@
<method signature="System.Void .ctor()" />
</type>

<!-- FIXME: only if feature="System.Reflection.Metadata.MetadataUpdater.IsSupported" featurevalue="true" -->
</assembly>
<assembly fullname="System.Private.CoreLib" feature="System.Reflection.Metadata.MetadataUpdater.IsSupported" featurevalue="true" featuredefault="true">
<type fullname="Mono.HotReload.FieldStore" preserve="fields" />
<type fullname="Mono.HotReload.InstanceFieldTable">
<!-- hot_reload.c -->
<method name="GetInstanceFieldFieldStore" />
</type>
<type fullname="Mono.HotReload.InstanceFieldTable">
<!-- hot_reload.c -->
<method name="GetInstanceFieldFieldStore" />
</type>
</assembly>
<assembly fullname="System.Private.CoreLib" feature="System.StartupHookProvider.IsSupported" featurevalue="true" featuredefault="true">
<type fullname="System.StartupHookProvider">
<!-- ds-rt-coreclr.h: ds_rt_apply_startup_hook -->
<method name="CallStartupHook" />
<!-- object.c: mono_runtime_run_startup_hooks -->
<method name="ProcessStartupHooks" />
</type>
</assembly>
<assembly fullname="System.Private.CoreLib" feature="System.StartupHookProvider.IsSupported" featurevalue="true" featuredefault="true">
<type fullname="System.StartupHookProvider">
<!-- ds-rt-coreclr.h: ds_rt_apply_startup_hook -->
<method name="CallStartupHook" />
<!-- object.c: mono_runtime_run_startup_hooks -->
<method name="ProcessStartupHooks" />
</type>
</assembly>
</linker>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<EnableDefaultItems>false</EnableDefaultItems>
<!-- setting WasmXHarnessMonoArgs doesn't work here, but see main.js -->
<!-- <WasmXHarnessMonoArgs>- -setenv=DOTNET_MODIFIABLE_ASSEMBLIES=debug</WasmXHarnessMonoArgs> -->
<MetadataUpdaterSupport>true</MetadataUpdaterSupport>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="ApplyUpdateReferencedAssembly\ApplyUpdateReferencedAssembly.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Copyright (c) .NET Foundation. All rights reserved.
could be removed by the ILLink, causing a trimmed app to crash. -->
<PropertyGroup Condition="'$(PublishTrimmed)' == 'true'">
<StartupHookSupport Condition="'$(StartupHookSupport)' == ''">false</StartupHookSupport>
<MetadataUpdaterSupport Condition="'$(MetadataUpdaterSupport)' == ''">false</MetadataUpdaterSupport>
Copy link
Member

Choose a reason for hiding this comment

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

Can you test that hot reload still works when you dotnet run (or dotnet watch) a project that has PublishAot/PublishTrimmed=true in the .csproj?

I think setting this property is going to break hot reload at debug time.

Copy link
Member

Choose a reason for hiding this comment

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

I tried:

using System.Runtime.CompilerServices;

while (true)
{
    Do();
    await Task.Delay(500);
}

[MethodImpl(MethodImplOptions.NoInlining)]
static void Do() => Console.WriteLine("Hello, World!");

with

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net9.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
	  <MetadataUpdaterSupport>false</MetadataUpdaterSupport>
  </PropertyGroup>

</Project>

With dotnet watch and then tried editing the Hello World string. The metadata does get updated. Did I miss some step?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

using System.Reflection.Metadata;

Console.WriteLine(MetadataUpdater.IsSupported);

This will print False with dotnet run (irrespective of MetadataUpdaterSupport value) and True with dotnet watch (again, irrespective of the property). This still matches my expectations.

<CustomResourceTypesSupport Condition="'$(CustomResourceTypesSupport)' == ''">false</CustomResourceTypesSupport>
<EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization Condition="'$(EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization)' == ''">false</EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization>
<EnableUnsafeBinaryFormatterSerialization Condition="'$(EnableUnsafeBinaryFormatterSerialization)' == ''">false</EnableUnsafeBinaryFormatterSerialization>
Expand Down
Loading