Skip to content

Commit

Permalink
fix: Don't fail metadata updates on missing assemblies
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed May 7, 2024
1 parent 3d024bb commit c760626
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,37 @@ private UpdateHandlerActions GetMetadataUpdateHandlerActions()
var handlerActions = new UpdateHandlerActions();
foreach (var assembly in sortedAssemblies)
{
foreach (var attr in assembly.GetCustomAttributesData())
try
{
// Look up the attribute by name rather than by type. This would allow netstandard targeting libraries to
// define their own copy without having to cross-compile.
if (attr.AttributeType.FullName != "System.Reflection.Metadata.MetadataUpdateHandlerAttribute")
foreach (var attr in assembly.GetCustomAttributesData())
{
continue;
// Look up the attribute by name rather than by type. This would allow netstandard targeting libraries to
// define their own copy without having to cross-compile.
if (attr.AttributeType.FullName != "System.Reflection.Metadata.MetadataUpdateHandlerAttribute")
{
continue;
}

IList<CustomAttributeTypedArgument> ctorArgs = attr.ConstructorArguments;
if (ctorArgs.Count != 1 ||
ctorArgs[0].Value is not Type handlerType)
{
_log($"'{attr}' found with invalid arguments.");
continue;
}

GetHandlerActions(handlerActions, handlerType);
}

IList<CustomAttributeTypedArgument> ctorArgs = attr.ConstructorArguments;
if (ctorArgs.Count != 1 ||
ctorArgs[0].Value is not Type handlerType)
{
_log($"'{attr}' found with invalid arguments.");
continue;
}

GetHandlerActions(handlerActions, handlerType);
}
catch (Exception e)

Check failure on line 107 in src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build Ubuntu_22_04 Build_Release)

src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs#L107

src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs(107,34): error CS0168: (NETCORE_ENGINEERING_TELEMETRY=Build) The variable 'e' is declared but never used

Check failure on line 107 in src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build Ubuntu_22_04 Build_Release)

src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs#L107

src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs(107,34): error CS0168: (NETCORE_ENGINEERING_TELEMETRY=Build) The variable 'e' is declared but never used

Check failure on line 107 in src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build Darwin Build_Release)

src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs#L107

src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs(107,34): error CS0168: (NETCORE_ENGINEERING_TELEMETRY=Build) The variable 'e' is declared but never used

Check failure on line 107 in src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build Darwin Build_Release)

src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs#L107

src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs(107,34): error CS0168: (NETCORE_ENGINEERING_TELEMETRY=Build) The variable 'e' is declared but never used

Check failure on line 107 in src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build Ubuntu_22_04_TemplateEngine Build_Release)

src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs#L107

src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs(107,34): error CS0168: (NETCORE_ENGINEERING_TELEMETRY=Build) The variable 'e' is declared but never used

Check failure on line 107 in src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build Darwin_AoT_Tests Build_Release)

src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs#L107

src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs(107,34): error CS0168: (NETCORE_ENGINEERING_TELEMETRY=Build) The variable 'e' is declared but never used

Check failure on line 107 in src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci (Build Darwin_TemplateEngine Build_Release)

src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs#L107

src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs(107,34): error CS0168: (NETCORE_ENGINEERING_TELEMETRY=Build) The variable 'e' is declared but never used

Check failure on line 107 in src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci

src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs#L107

src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs(107,34): error CS0168: (NETCORE_ENGINEERING_TELEMETRY=Build) The variable 'e' is declared but never used

Check failure on line 107 in src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci

src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs#L107

src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs(107,34): error CS0168: (NETCORE_ENGINEERING_TELEMETRY=Build) The variable 'e' is declared but never used

Check failure on line 107 in src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs

View check run for this annotation

Azure Pipelines / dotnet-sdk-public-ci

src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs#L107

src/BuiltInTools/DotNetDeltaApplier/HotReloadAgent.cs(107,34): error CS0168: (NETCORE_ENGINEERING_TELEMETRY=Build) The variable 'e' is declared but never used
{
// In cross-platform scenarios, such as debugging in VS through WSL, Roslyn
// runs on Windows, and the agent runs on Linux. Assemblies accessible to Windows
// may not be available or loaded on linux (such as WPF's assemblies).
// In such case, we can ignore the assemblies and continue enumerating handlers for
// the rest of the assemblies of current domain.
_log($"'{assembly.FullName}' is not loaded");
continue;
}
}

Expand Down

0 comments on commit c760626

Please sign in to comment.