-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add host option to disable AssemblyLoadContext
A host can disable the use of AssemblyLoadContext by returning a value of "true" or "1" when GetHostOption is called with the option name "DisableAssemblyLoadContext". This is an escape hatch for hosts that have issues with the ALC behavior, allowing them to opt out until the underlying issues can be fixed.
- Loading branch information
Showing
5 changed files
with
60 additions
and
19 deletions.
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
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
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
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
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,16 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using Microsoft.VisualStudio.TextTemplating; | ||
|
||
static class HostOptionExtensions | ||
{ | ||
const string DisableAlcOptionName = "DisableAssemblyLoadContext"; | ||
|
||
static bool IsOptionTrue (this ITextTemplatingEngineHost host, string optionName) => | ||
host.GetHostOption(optionName) is string optionVal | ||
&& (optionVal == "1" || optionVal.Equals("true", StringComparison.OrdinalIgnoreCase)); | ||
|
||
public static bool IsAssemblyLoadContextDisabled (this ITextTemplatingEngineHost host) => host.IsOptionTrue (DisableAlcOptionName); | ||
} |