-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Merge hotreload-utils source into runtime repo #126512
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d4e3330
Merge hotreload-utils source into runtime repo
steveisok 5c7d08f
Apply suggestions from code review
akoeplinger 8dbe9ef
Merge branch 'main' into merge-hotreload-utils
akoeplinger 5f447b1
Merge branch 'main' into merge-hotreload-utils
akoeplinger 3d083f5
Apply suggestions from code review
akoeplinger 3ed9426
Apply suggestion from @Copilot
akoeplinger 88e8e05
Merge branch 'main' into merge-hotreload-utils
akoeplinger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| <!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. --> | ||
|
|
||
| <!-- | ||
| Targets for generating hot reload deltas from a delta script. | ||
| This replaces the external Microsoft.DotNet.HotReload.Utils.Generator.BuildTool NuGet package. | ||
|
|
||
| Projects must define the DeltaScript property that specifies the (relative) path to the json script. | ||
| Deltas will be emitted next to the output assembly. Deltas will be copied when the current | ||
| project is referenced from other projects. | ||
| --> | ||
| <Project> | ||
|
|
||
| <PropertyGroup> | ||
| <DotNetTool Condition="'$(DotNetTool)' == ''">dotnet</DotNetTool> | ||
|
|
||
| <_HotReloadDeltaGeneratorToolDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'Microsoft.DotNet.HotReload.Utils.Generator.BuildTool', '$(Configuration)', '$(NetCoreAppToolCurrent)'))</_HotReloadDeltaGeneratorToolDir> | ||
|
|
||
| <_HotReloadDeltaGeneratorPath Condition="'$(_HotReloadDeltaGeneratorPath)' == ''">$(_HotReloadDeltaGeneratorToolDir)Microsoft.DotNet.HotReload.Utils.Generator.BuildTool.dll</_HotReloadDeltaGeneratorPath> | ||
|
|
||
| <_HotReloadDeltaGeneratorCommand>"$(DotNetTool)" "$(_HotReloadDeltaGeneratorPath)"</_HotReloadDeltaGeneratorCommand> | ||
|
|
||
| <_HotReloadDeltaGeneratorTasksDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'Microsoft.DotNet.HotReload.Utils.Generator.Tasks', '$(Configuration)', '$(NetCoreAppToolCurrent)'))</_HotReloadDeltaGeneratorTasksDir> | ||
|
|
||
| <_HotReloadDeltaGeneratorTasksPath Condition="'$(_HotReloadDeltaGeneratorTasksPath)' == ''">$(_HotReloadDeltaGeneratorTasksDir)Microsoft.DotNet.HotReload.Utils.Generator.Tasks.dll</_HotReloadDeltaGeneratorTasksPath> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <_HotReloadDeltaGeneratorDeltaScript Condition="'$(DeltaScript)' != ''">$([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', '$(DeltaScript)'))</_HotReloadDeltaGeneratorDeltaScript> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <_HotReloadDeltaGeneratorShouldRun Condition="'$(_HotReloadDeltaGeneratorShouldRun)' == '' and Exists('$(_HotReloadDeltaGeneratorDeltaScript)')">true</_HotReloadDeltaGeneratorShouldRun> | ||
| <_HotReloadDeltaGeneratorShouldRun Condition="'$(_HotReloadDeltaGeneratorShouldRun)' == ''">false</_HotReloadDeltaGeneratorShouldRun> | ||
| </PropertyGroup> | ||
|
|
||
| <UsingTask TaskName="HotReloadDeltaGeneratorComputeScriptOutputs" AssemblyFile="$(_HotReloadDeltaGeneratorTasksPath)" /> | ||
|
|
||
| <!-- Doesn't actually run the delta generator, but just analyzes the script and figures out what output items it would produce. | ||
| Used for computing incremental inputs/outputs of HotReloadDeltaGeneratorGenerateDeltas, and for ContentForDeltaFileOutputNames | ||
| --> | ||
| <Target Name="HotReloadDeltaGeneratorComputeScriptInputsOutputs" | ||
| Condition="'$(_HotReloadDeltaGeneratorShouldRun)' == 'true'"> | ||
| <HotReloadDeltaGeneratorComputeScriptOutputs BaseAssemblyName="$(TargetPath)" DeltaScript="$(_HotReloadDeltaGeneratorDeltaScript)"> | ||
| <Output TaskParameter="DeltaOutputs" ItemName="_HotReloadDeltaGeneratorOutputs" /> | ||
| <Output TaskParameter="DeltaSources" ItemName="_HotReloadDeltaGeneratorInputs" /> | ||
| </HotReloadDeltaGeneratorComputeScriptOutputs> | ||
| </Target> | ||
|
|
||
| <!-- Invoke hotreload-delta-gen to apply the DeltaScript to the output assembly to | ||
| create the .dmeta, .dil and .dpdb files on the OutputPath --> | ||
| <Target Name="HotReloadDeltaGeneratorGenerateDeltas" | ||
| AfterTargets="Build" | ||
| DependsOnTargets="HotReloadDeltaGeneratorComputeScriptInputsOutputs" | ||
| Condition="'$(_HotReloadDeltaGeneratorShouldRun)' == 'true'" | ||
| Inputs="$(TargetPath); @(_HotReloadDeltaGeneratorInputs)" | ||
| Outputs="@(_HotReloadDeltaGeneratorOutputs)" | ||
| > | ||
| <PropertyGroup> | ||
| <_HotReloadDeltaGeneratorArgs>"-msbuild:$(MSBuildProjectFullPath)"</_HotReloadDeltaGeneratorArgs> | ||
| <_HotReloadDeltaGeneratorArgs>$(_HotReloadDeltaGeneratorArgs) "-script:$(_HotReloadDeltaGeneratorDeltaScript)"</_HotReloadDeltaGeneratorArgs> | ||
|
|
||
| <!-- This is a little bit delicate: we're invoking a design-time msbuild here, and we need it to come back with the same OutputPath as the current | ||
| run of msbuild. If there are other properties that affect where the baseline assembly ends up, we need to pass those here too. | ||
| --> | ||
| <_HotReloadDeltaGeneratorArgs Condition="'$(Configuration)' != ''">$(_HotReloadDeltaGeneratorArgs) -p:Configuration=$(Configuration)</_HotReloadDeltaGeneratorArgs> | ||
| <_HotReloadDeltaGeneratorArgs Condition="'$(RuntimeIdentifier)' != ''">$(_HotReloadDeltaGeneratorArgs) -p:RuntimeIdentifier=$(RuntimeIdentifier)</_HotReloadDeltaGeneratorArgs> | ||
| <!-- escape hatch for any extra arguments --> | ||
| <_HotReloadDeltaGeneratorArgs Condition="'$(HotReloadDeltaGeneratorExtraArgs)' != ''">$(_HotReloadDeltaGeneratorArgs) $(HotReloadDeltaGeneratorExtraArgs)</_HotReloadDeltaGeneratorArgs> | ||
| </PropertyGroup> | ||
| <Exec Command="$(_HotReloadDeltaGeneratorCommand) $(_HotReloadDeltaGeneratorArgs)" /> | ||
| </Target> | ||
|
|
||
| <Target Name="HotReloadDeltaGeneratorContentForOutputs" | ||
| BeforeTargets="AssignTargetPaths" | ||
| DependsOnTargets="HotReloadDeltaGeneratorComputeScriptInputsOutputs" | ||
| Condition="'$(_HotReloadDeltaGeneratorShouldRun)' == 'true' and '$(DesignTimeBuild)' != 'true'"> | ||
| <ItemGroup> | ||
| <Content Include="@(_HotReloadDeltaGeneratorOutputs)"> | ||
| <CopyToOutputDirectory>always</CopyToOutputDirectory> | ||
| </Content> | ||
| </ItemGroup> | ||
| </Target> | ||
|
|
||
| </Project> | ||
11 changes: 0 additions & 11 deletions
11
src/libraries/System.Runtime.Loader/tests/ApplyUpdate/Directory.Build.props
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/libraries/System.Runtime.Loader/tests/ApplyUpdate/Directory.Build.targets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| <Project> | ||
| <Import Project="..\..\..\Directory.Build.targets" /> | ||
| <Import Project="$(RepositoryEngineeringDir)testing\hotreload-delta-gen.targets" /> | ||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.IO; | ||
|
|
||
| namespace Microsoft.DotNet.HotReload.Utils.Common; | ||
|
|
||
| internal class TempDirectory : IDisposable | ||
| { | ||
| public TempDirectory(bool keep = false, string? dirname = null) | ||
| { | ||
| string subdir = dirname ?? System.IO.Path.GetRandomFileName(); | ||
| Path = System.IO.Path.Combine(System.IO.Path.GetTempPath(), subdir); | ||
| Keep = keep; | ||
| Directory.CreateDirectory(Path); | ||
| } | ||
|
|
||
| public string Path { get; } | ||
| public bool Keep { get; set; } | ||
|
|
||
| public void Dispose() | ||
| { | ||
| if (!Keep) | ||
| Directory.Delete(Path, true); | ||
| GC.SuppressFinalize(this); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <Project> | ||
| <Import Project="..\Directory.Build.props" /> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>$(NetCoreAppToolCurrent)</TargetFramework> | ||
| <Nullable>enable</Nullable> | ||
| <LangVersion>Latest</LangVersion> | ||
| <SlnGenSolutionFolder>tools\hotreload-delta-gen\</SlnGenSolutionFolder> | ||
| <IsShipping>false</IsShipping> | ||
|
|
||
|
akoeplinger marked this conversation as resolved.
|
||
| <!-- | ||
| This code was imported from https://github.com/dotnet/hotreload-utils which did not | ||
| enforce runtime's strict analyzer rules. Suppress analyzer warnings-as-errors for now. | ||
| --> | ||
| <RunAnalyzers>false</RunAnalyzers> | ||
| </PropertyGroup> | ||
| </Project> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <Project> | ||
| <Import Project="..\Directory.Build.targets" /> | ||
| </Project> |
12 changes: 12 additions & 0 deletions
12
...oad.Utils.Generator.BuildTool/Microsoft.DotNet.HotReload.Utils.Generator.BuildTool.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <RollForward>Major</RollForward> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Microsoft.DotNet.HotReload.Utils.Generator.Frontend\Microsoft.DotNet.HotReload.Utils.Generator.Frontend.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
4 changes: 4 additions & 0 deletions
4
...tools/hotreload-delta-gen/Microsoft.DotNet.HotReload.Utils.Generator.BuildTool/Program.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| return Microsoft.DotNet.HotReload.Utils.Generator.Frontend.Frontend.Main(args); |
31 changes: 31 additions & 0 deletions
31
...reload-delta-gen/Microsoft.DotNet.HotReload.Utils.Generator.BuildTool/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Microsoft.DotNet.HotReload.Utils.Generator.BuildTool # | ||
|
|
||
| Generate deltas as part of an MSBuild project. | ||
|
|
||
| ## How to use it ## | ||
|
|
||
| Starting with an existing SDK-style project, add: | ||
|
|
||
| ```xml | ||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.DotNet.HotReload.Utils.Generator.BuildTool" Version="..." /> | ||
| </ItemGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <DeltaScript>deltascript.json</DeltaScript> | ||
| </PropertyGroup> | ||
| ``` | ||
|
|
||
| Where the `deltascript.json` file contains the changes to be applied: | ||
|
|
||
| ```json | ||
| {"changes": | ||
| [ | ||
| {"document": "relativePath/to/file.cs", "update": "relativePath/to/file_v1.cs"}, | ||
| {"document": "file2.cs", "update": "file2_v2.cs"}, | ||
| {"document": "relativePath/to/file.cs", "update": "relativePath/to/file_v3.cs"} | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| The tool will run as part of the build after the `Build` target and generate `.dmeta`, `.dil` and `.dpdb` files in `$(OutputPath)`. |
2 changes: 2 additions & 0 deletions
2
...Net.HotReload.Utils.Generator.Data/Microsoft.DotNet.HotReload.Utils.Generator.Data.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| </Project> |
42 changes: 42 additions & 0 deletions
42
...-delta-gen/Microsoft.DotNet.HotReload.Utils.Generator.Data/OutputSummary/OutputSummary.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Text.Json.Serialization; | ||
|
|
||
|
|
||
| namespace Microsoft.DotNet.HotReload.Utils.Generator.OutputSummary; | ||
|
|
||
| public class OutputSummary { | ||
| [JsonPropertyName("deltas")] | ||
| public Delta[]? Deltas {get; init;} | ||
|
|
||
| [JsonExtensionData] | ||
| public System.Collections.Generic.Dictionary<string, object>? Extra {get; init;} | ||
|
|
||
| [JsonConstructor] | ||
| public OutputSummary(Delta[]? deltas) { | ||
| Deltas = deltas; | ||
| } | ||
| } | ||
|
|
||
| public class Delta { | ||
| [JsonPropertyName("assembly")] | ||
| public string? Assembly {get; init;} | ||
| [JsonPropertyName("metadata")] | ||
| public string? Metadata {get; init;} | ||
| [JsonPropertyName("il")] | ||
| public string? IL {get; init;} | ||
| [JsonPropertyName("pdb")] | ||
| public string? Pdb {get; init;} | ||
|
|
||
| [JsonConstructor] | ||
| public Delta (string? assembly, string? metadata, string? il, string? pdb) { | ||
| Assembly = assembly; | ||
| Metadata = metadata; | ||
| IL = il; | ||
| Pdb = pdb; | ||
| } | ||
|
|
||
| [JsonExtensionData] | ||
| public System.Collections.Generic.Dictionary<string, object>? Extra {get; set;} | ||
| } |
30 changes: 30 additions & 0 deletions
30
...hotreload-delta-gen/Microsoft.DotNet.HotReload.Utils.Generator.Data/Script/Json/Script.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Text.Json.Serialization; | ||
|
|
||
| namespace Microsoft.DotNet.HotReload.Utils.Generator.Script.Json; | ||
| public class Script { | ||
|
|
||
| [JsonConverter(typeof(ScriptCapabilitiesConverter))] | ||
| public string? Capabilities {get; init;} | ||
| public Change[]? Changes {get; init;} | ||
|
|
||
| [System.Text.Json.Serialization.JsonConstructor] | ||
| public Script (string? capabilities, Change[]? changes) { | ||
| Capabilities = capabilities; | ||
| Changes = changes; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| public class Change { | ||
| public string Document {get; init;} | ||
| public string Update {get; init;} | ||
|
|
||
| [System.Text.Json.Serialization.JsonConstructor] | ||
| public Change (string document, string update) { | ||
| Document = document; | ||
| Update = update; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.