-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release/9.0.1xx] Don't fail metadata updates on missing assemblies (#…
- Loading branch information
1 parent
7ffe7d4
commit 25a2f65
Showing
10 changed files
with
166 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
13 changes: 13 additions & 0 deletions
13
test/TestAssets/TestProjects/WatchAppMissingAssemblyFailure/App/App.csproj
This file contains 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,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>$(CurrentTargetFramework)</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Dep\Dep.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
34 changes: 34 additions & 0 deletions
34
test/TestAssets/TestProjects/WatchAppMissingAssemblyFailure/App/Program.cs
This file contains 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,34 @@ | ||
using System.Diagnostics; | ||
using System.Reflection.Metadata; | ||
|
||
[assembly: MetadataUpdateHandler(typeof(UpdateHandler))] | ||
|
||
// delete the dependency dll to cause load failure of DepSubType | ||
var depPath = Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location!)!, "Dep2.dll"); | ||
File.Delete(depPath); | ||
Console.WriteLine($"File deleted: {depPath}"); | ||
|
||
while (true) | ||
{ | ||
lock (UpdateHandler.Guard) | ||
{ | ||
Printer.Print(); | ||
Dep.DepLib.F(); | ||
} | ||
|
||
Thread.Sleep(100); | ||
} | ||
|
||
static class UpdateHandler | ||
{ | ||
// Lock to avoid the updated Print method executing concurrently with the update handler. | ||
public static object Guard = new object(); | ||
|
||
public static void UpdateApplication(Type[] types) | ||
{ | ||
lock (Guard) | ||
{ | ||
Console.WriteLine($"Updated types: {(types == null ? "<null>" : types.Length == 0 ? "<empty>" : string.Join(",", types.Select(t => t.Name)))}"); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
test/TestAssets/TestProjects/WatchAppMissingAssemblyFailure/App/Update.cs
This file contains 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 @@ | ||
using System; | ||
|
||
public class DepType | ||
{ | ||
int F() => 1; | ||
} | ||
|
||
public class Printer | ||
{ | ||
public static void Print() | ||
=> Console.WriteLine("Hello!"); | ||
} |
13 changes: 13 additions & 0 deletions
13
test/TestAssets/TestProjects/WatchAppMissingAssemblyFailure/Dep/Dep.cs
This file contains 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,13 @@ | ||
// This attribute is not causing Dep.dll to be loaded, but enough | ||
// to cause the HotReloadAgent to fail on getting custom attributes. | ||
[assembly: Dep2.Test()] | ||
|
||
namespace Dep; | ||
|
||
public class DepLib | ||
{ | ||
public static void F() | ||
{ | ||
Console.WriteLine(1); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
test/TestAssets/TestProjects/WatchAppMissingAssemblyFailure/Dep/Dep.csproj
This file contains 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> | ||
<TargetFramework>$(CurrentTargetFramework)</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Dep2\Dep2.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
9 changes: 9 additions & 0 deletions
9
test/TestAssets/TestProjects/WatchAppMissingAssemblyFailure/Dep2/Dep2.cs
This file contains 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,9 @@ | ||
namespace Dep2; | ||
|
||
public class Dep2Lib | ||
{ | ||
void F() | ||
{ | ||
Console.WriteLine(1); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
test/TestAssets/TestProjects/WatchAppMissingAssemblyFailure/Dep2/Dep2.csproj
This file contains 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,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>$(CurrentTargetFramework)</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
</Project> |
8 changes: 8 additions & 0 deletions
8
test/TestAssets/TestProjects/WatchAppMissingAssemblyFailure/Dep2/TestAttribute.cs
This file contains 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,8 @@ | ||
using System; | ||
|
||
namespace Dep2; | ||
|
||
[AttributeUsage(AttributeTargets.Assembly)] | ||
public class TestAttribute : Attribute | ||
{ | ||
} |
This file contains 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