Skip to content

Commit

Permalink
优化DEBUG判断
Browse files Browse the repository at this point in the history
  • Loading branch information
jiniannet committed Oct 27, 2021
1 parent eeadcee commit b7b8371
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
7 changes: 2 additions & 5 deletions src/JinianNet.JNTemplate/Context.cs
Expand Up @@ -27,11 +27,8 @@ public Context(IHostEnvironment hostEnvironment)
this.ThrowExceptions = hostEnvironment.Options.ThrowExceptions;
this.Environment = hostEnvironment;
this.EnableCache = hostEnvironment.Options.EnableCache;
#if DEBUG
this.Debug = true;
#else
this.Debug = false;
#endif
this.Debug = System.Diagnostics.Debugger.IsAttached;

}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions src/JinianNet.JNTemplate/JinianNet.JNTemplate.csproj
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>JinianNet.JNTemplate</RootNamespace>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>2.2.2</Version>
<Version>2.2.3</Version>
<Authors>JinianNet.com</Authors>
<Company>JinianNet.com</Company>
<Product>JNTemplate</Product>
Expand All @@ -25,8 +25,8 @@
<PostBuildEvent></PostBuildEvent>
<AssemblyOriginatorKeyFile>jiniannet.snk</AssemblyOriginatorKeyFile>
<PackageLicenseFile>License.txt</PackageLicenseFile>
<FileVersion>2.2.2.0</FileVersion>
<AssemblyVersion>2.2.2.0</AssemblyVersion>
<FileVersion>2.2.3.0</FileVersion>
<AssemblyVersion>2.2.3.0</AssemblyVersion>
<DelaySign>false</DelaySign>
</PropertyGroup>

Expand Down
3 changes: 1 addition & 2 deletions src/JinianNet.JNTemplate/TemplateContextExtensions.cs
Expand Up @@ -274,10 +274,9 @@ public static ICompilerResult CompileTemplate(this TemplateContext context, stri

var env = context.Environment;

if (!context.EnableCache)
if (!context.EnableCache && context.Debug)
{
System.Diagnostics.Trace.TraceWarning("WARN:The template cache is disabled.");

return env.Compile(name, reader.ReadToEnd(), (c) => context.CopyTo(c));

}
Expand Down

0 comments on commit b7b8371

Please sign in to comment.