Skip to content

Commit

Permalink
Don't use AppDomain codepath for CurrentDomain
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mhutch committed Dec 6, 2023
1 parent d5fb8e6 commit 145334b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Mono.TextTemplating/Mono.TextTemplating/CompiledTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
}

Expand Down

0 comments on commit 145334b

Please sign in to comment.