From 145334bd06cecb59f520dc780d7300c94baa838c Mon Sep 17 00:00:00 2001 From: Mikayla Hutchinson Date: Wed, 6 Dec 2023 15:10:44 -0500 Subject: [PATCH] Don't use AppDomain codepath for CurrentDomain Template hosts should return null from ProvideTemplatingAppDomain if they don't want to use an AppDomain, but check for AppDomain.CurrentDomain and shortcircuit that as well. Improves usability issue discovered in #170 --- Mono.TextTemplating/Mono.TextTemplating/CompiledTemplate.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Mono.TextTemplating/Mono.TextTemplating/CompiledTemplate.cs b/Mono.TextTemplating/Mono.TextTemplating/CompiledTemplate.cs index 80c18a2d..97ba0f83 100644 --- a/Mono.TextTemplating/Mono.TextTemplating/CompiledTemplate.cs +++ b/Mono.TextTemplating/Mono.TextTemplating/CompiledTemplate.cs @@ -82,7 +82,10 @@ internal void SetTemplateContentForAppDomain (string content) TemplateProcessor CreateTemplateProcessor () { var domain = host.ProvideTemplatingAppDomain (templateContentForAppDomain); - if (domain == null) { + + // hosts are supposed to return null of they don't want to use a domain + // but check for CurrentDomain too so we can optimize if they do that + if (domain == null || domain == AppDomain.CurrentDomain) { return new TemplateProcessor (); }