From c0ce4fcbf8e93151ffdef7f2542eedfff3a3f750 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 28 Feb 2019 07:56:40 -0800 Subject: [PATCH] Prefer manual code generation over CodeDOM CodeDOM is *very* slow, it turns out. Addresses on eof the perf issues reported in #114 --- .../AssemblyVersionInfo.cs | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/Nerdbank.GitVersioning.Tasks/AssemblyVersionInfo.cs b/src/Nerdbank.GitVersioning.Tasks/AssemblyVersionInfo.cs index dae72bfc..895936a5 100644 --- a/src/Nerdbank.GitVersioning.Tasks/AssemblyVersionInfo.cs +++ b/src/Nerdbank.GitVersioning.Tasks/AssemblyVersionInfo.cs @@ -72,7 +72,14 @@ public class AssemblyVersionInfo : Task #if NET461 public override bool Execute() { - if (CodeDomProvider.IsDefinedLanguage(this.CodeLanguage)) + // attempt to use local codegen + string fileContent = this.BuildCode(); + if (fileContent != null) + { + Directory.CreateDirectory(Path.GetDirectoryName(this.OutputFile)); + Utilities.FileOperationWithRetry(() => File.WriteAllText(this.OutputFile, fileContent)); + } + else if (CodeDomProvider.IsDefinedLanguage(this.CodeLanguage)) { using (var codeDomProvider = CodeDomProvider.CreateProvider(this.CodeLanguage)) { @@ -100,17 +107,7 @@ public override bool Execute() } else { - // attempt to use local codegen - string fileContent = this.BuildCode(); - if (fileContent != null) - { - Directory.CreateDirectory(Path.GetDirectoryName(this.OutputFile)); - Utilities.FileOperationWithRetry(() => File.WriteAllText(this.OutputFile, fileContent)); - } - else - { - this.Log.LogError("CodeDomProvider not available for language: {0}. No version info will be embedded into assembly.", this.CodeLanguage); - } + this.Log.LogError("CodeDomProvider not available for language: {0}. No version info will be embedded into assembly.", this.CodeLanguage); } return !this.Log.HasLoggedErrors;