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

Conversation

pavelsavara
Copy link
Member

Trim Mono.HotReload classes when MetadataUpdaterSupport is false or not specified.

Related discussion #111215 (comment)

@pavelsavara pavelsavara added area-Build-mono size-reduction Issues impacting final app size primary for size sensitive workloads labels Jan 9, 2025
@pavelsavara pavelsavara added this to the 10.0.0 milestone Jan 9, 2025
@pavelsavara pavelsavara self-assigned this Jan 9, 2025
Copy link
Contributor

Tagging subscribers to 'size-reduction': @eerhardt, @SamMonoRT, @marek-safar
See info in area-owners.md if you want to be subscribed.

@pavelsavara
Copy link
Member Author

cc @MichalStrehovsky - this is separated from the timezones PR

@@ -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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Build-mono size-reduction Issues impacting final app size primary for size sensitive workloads
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants