From 2f86318fd84949355a271cfef4de370c3b6a16ac Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Fri, 10 Apr 2009 13:26:30 +0000 Subject: [PATCH] Improved performance of UpdateAssemblyInfo. Code-completion debug output: use Debug.WriteLine instead of Console.WriteLine. Custom Tool project template: fixed compile error. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3963 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../project/CSharp/SharpDevelopCustomTool.xpt | 4 +-- .../Project/Src/MemberLookupHelper.cs | 3 ++- src/Tools/UpdateAssemblyInfo/Main.cs | 25 +++++++++++++----- .../bin/Debug/UpdateAssemblyInfo.exe | Bin 20480 -> 20480 bytes src/Tools/UpdateSetupInfo/Main.cs | 24 ++++++++++++----- 5 files changed, 40 insertions(+), 16 deletions(-) diff --git a/data/templates/project/CSharp/SharpDevelopCustomTool.xpt b/data/templates/project/CSharp/SharpDevelopCustomTool.xpt index 161f70020f..b42b8e9bd6 100644 --- a/data/templates/project/CSharp/SharpDevelopCustomTool.xpt +++ b/data/templates/project/CSharp/SharpDevelopCustomTool.xpt @@ -125,8 +125,8 @@ namespace ${StandardNamespace} // This makes the generation code much more concise. // EasyCodeDom classes derive from the System.CodeDom types or have an implicit conversion operator, so // use can use EasyCodeDom objects whereever CodeDom is expected. - EasyCompileUnit ccu = new EasyCompileUnit(); - EasyTypeDeclaration generatedClass = ccu.AddNamespace(targetNamespace).AddType(className); + CodeCompileUnit ccu = new CodeCompileUnit(); + CodeTypeDeclaration generatedClass = ccu.AddNamespace(targetNamespace).AddType(className); EasyMethod m = generatedClass.AddMethod("Create"); m.ReturnType = Easy.TypeRef(doc.DocumentElement.Name); m.Attributes = MemberAttributes.Static | MemberAttributes.Public; diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/MemberLookupHelper.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/MemberLookupHelper.cs index 7df5a3b6e3..1928dbb058 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/MemberLookupHelper.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/MemberLookupHelper.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; namespace ICSharpCode.SharpDevelop.Dom @@ -873,7 +874,7 @@ namespace ICSharpCode.SharpDevelop.Dom [System.Diagnostics.ConditionalAttribute("DEBUG")] internal static void Log(string text) { - Console.WriteLine(text); + Debug.WriteLine(text); } [System.Diagnostics.ConditionalAttribute("DEBUG")] diff --git a/src/Tools/UpdateAssemblyInfo/Main.cs b/src/Tools/UpdateAssemblyInfo/Main.cs index 39eb7ec05a..7c1e4b1f79 100644 --- a/src/Tools/UpdateAssemblyInfo/Main.cs +++ b/src/Tools/UpdateAssemblyInfo/Main.cs @@ -54,9 +54,8 @@ namespace UpdateAssemblyInfo Console.WriteLine("Working directory must be SharpDevelop\\src!"); return 2; } - File.Copy(Path.Combine(subversionLibraryDir, "SharpSvn.dll"), - Path.Combine(exeDir, "SharpSvn.dll"), - true); + FileCopy(Path.Combine(subversionLibraryDir, "SharpSvn.dll"), + Path.Combine(exeDir, "SharpSvn.dll")); RetrieveRevisionNumber(); string versionNumber = GetMajorVersion() + "." + revisionNumber; UpdateStartup(); @@ -69,6 +68,16 @@ namespace UpdateAssemblyInfo } } + static void FileCopy(string source, string target) + { + if (File.Exists(target)) { + // don't copy file if it is up-to-date: repeatedly copying a 3 MB file slows down the build + if (File.GetLastWriteTimeUtc(source) == File.GetLastWriteTimeUtc(target)) + return; + } + File.Copy(source, target, true); + } + static void UpdateStartup() { string content; @@ -189,10 +198,12 @@ namespace UpdateAssemblyInfo // Change working dir so that the subversion libraries can be found Environment.CurrentDirectory = Path.Combine(Environment.CurrentDirectory, subversionLibraryDir); - SvnWorkingCopyClient client = new SvnWorkingCopyClient(); - SvnWorkingCopyVersion version; - if (client.GetVersion(oldWorkingDir, out version)) { - revisionNumber = version.Start.ToString(CultureInfo.InvariantCulture); + using (SvnClient client = new SvnClient()) { + client.Info( + oldWorkingDir, + (sender, info) => { + revisionNumber = info.Revision.ToString(CultureInfo.InvariantCulture); + }); } } catch (Exception e) { Console.WriteLine("Reading revision number with SharpSvn failed: " + e.ToString()); diff --git a/src/Tools/UpdateAssemblyInfo/bin/Debug/UpdateAssemblyInfo.exe b/src/Tools/UpdateAssemblyInfo/bin/Debug/UpdateAssemblyInfo.exe index 47f0a4681ebbd9314d2f3017dbf54bf103a8a4d0..f5c77169f8d4320780b52d7b863a712f42c14bfd 100755 GIT binary patch delta 3211 zcmbVPdu$ZP8UJQxcW>`}UVL}`U6Qw9={%D+qJX9s2sv4D+M5T_}rd3KG|1_zRfxT=ww&%I^;mSejQ*hDD7&v4BA3^83 zZWV!?7Z4$8R>Cq{1qhO^+4DgV%;kZ}1#w*Ni{ZQ4XOerjkX&J*kI8Kzrwm74#gWGR zZSvZ6>%6+*{XgU-Gd)YrOSiYyXSZ=Y(w#>|;EeASlnH!v(nYlFI?kV*Wsn!^e!Ci> zBT7h#UQ@iHSwebsZAkIkaVR#=-E7xL167|Dh18HTIHMl4YoQE~v*i}S++URzcm8*f znex3&D6gmy?~y`0_e5#=UH@MYR8+#PElaS7ySnU-JYG+TxL0jAU1(Sqo810QaQt_|%<4UyI7}|{(GSP+5oA3&dStrr?HoOZ0HyMqxMeake}Q zg${xDX(NX~AWUYX4AKOcl&u5OSer_hV292UBC}bV&3wFGvM8QskW3`6c{}(xzxB#39i3JcCyu@q_*{d$6L~&sHc?D= zG!8nI!A>z+Jnxw^n$OL4S1&j79e78HeMDcw_Y$fo(U)^l>5;5-I0&~G$)S}bR*u@+q%j8CCVQZY>wd|6$d(ZLB)Ti%W~EME2NhvTeLE%!CXYWO zGYV-aCt_j*JX)Hpryg)~**`%4kiEj@&?%T{B=`lUQNqI&ya$ri9zMc%a*dAgmw-R> zBqu%mD?bm(6%YMFYU_b{je3N19`ta`!#zTpe$k`f@J!$G@bBV}LL*g?&S7AH29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m9`2eg3jRW6>LT zd-cC@1{AD@yfz&1vv8d-<7VorsZaV&3OBXH&4|AgimmCbev>k=!q-J{D{gM9s<-($ zD5Df?{~TvBU0=KQW+&C2yM-&=iSYNG1%EPD-_Y~_IYC=B%YphNr*Y4LxVrrr(0PV&UsYs4cj&i*GopT8e}hTF8xDcN0MqHKn@iEftS~AEOc- zG)gw|8BEoGwc3-a?OPGWgB9-OZ3=^5!TKga$y^Xn@TQ{MMb|s4Z4W4 zv{fkY4tRhg_0eNMPXG^NBTD1#z?zWlvX9HEZjLUfk-~l__=M$JUKa?j8!)9t0mak|dV1v+x@P{X=X{El8`oKBj0_c~;L9vM5 zRI{Dt#5=;K7%S}HK1h~pEOCKt`XL_x9@Ua#8qe?yBp+z}yVkmfvdJ4IwYbkv_>jhu zp-lH`^|Km}8x_N*)0&c<#|q=rgrm}>-h}z zns4w&R5UM%k7&0!FV5*I&r!vEk1x_&<}80o=gdE|5J~H=s4{86olt2-l%*WXv@f~B z%kXP$7|W=UV#apf&xiSEe1bn_`9|hz_DL?|Cdp{_xcpuA=auJ|o)KoRKQ<|MNZY~Am z!~Q7sl_nO*q0+>|g^9snLUy-oma{EQOn1xUZ4H%F>w{L^;^Mo-{>$IE_qq1-Po4kp zh2hHM-kgxTI|h1%Zc;pl|Ij|v_QHYfUML5Tb?&5* zqp0$`*UkyYo!XBP?6{A)lkO&t%43~h>Bc|Ae$~NhdVC9S9{>9C7<3O7?kSvUd!jVp zpWOJ&md`%P@7VuaQ)as!a%ZmnFI1~$6`h-IPVuRp$}3$vjaT_YQE~ED7V&&fCBF8; IqUn6-Kdp${IRF3v diff --git a/src/Tools/UpdateSetupInfo/Main.cs b/src/Tools/UpdateSetupInfo/Main.cs index 72e4417013..33ed23f861 100644 --- a/src/Tools/UpdateSetupInfo/Main.cs +++ b/src/Tools/UpdateSetupInfo/Main.cs @@ -78,13 +78,23 @@ namespace UpdateSetupInfo previousRevisionFolder = Path.Combine(setupProjectFolder, @"bin"); previousRevisionFileName = Path.Combine(previousRevisionFolder, "REVISION"); - File.Copy(Path.Combine(Path.Combine(applicationFolder, subversionLibraryDir), "SharpSvn.dll"), - Path.Combine(applicationFolder, "SharpSvn.dll"), true); + FileCopy(Path.Combine(Path.Combine(applicationFolder, subversionLibraryDir), "SharpSvn.dll"), + Path.Combine(applicationFolder, "SharpSvn.dll")); // Set current directory to a folder that is in the repository. Environment.CurrentDirectory = setupProjectFolder; } + static void FileCopy(string source, string target) + { + if (File.Exists(target)) { + // don't copy file if it is up-to-date: repeatedly copying a 3 MB file slows down the build + if (File.GetLastWriteTimeUtc(source) == File.GetLastWriteTimeUtc(target)) + return; + } + File.Copy(source, target, true); + } + public static int Main(string[] args) { try { @@ -164,10 +174,12 @@ namespace UpdateSetupInfo // Set working directory so msvcp70.dll and msvcr70.dll can be found Environment.CurrentDirectory = Path.Combine(applicationFolder, subversionLibraryDir); - SvnWorkingCopyClient client = new SvnWorkingCopyClient(); - SvnWorkingCopyVersion version; - if (client.GetVersion(oldWorkingDir, out version)) { - revisionNumber = version.Start.ToString(CultureInfo.InvariantCulture); + using (SvnClient client = new SvnClient()) { + client.Info( + oldWorkingDir, + (sender, info) => { + revisionNumber = info.Revision.ToString(CultureInfo.InvariantCulture); + }); } } catch (Exception e) { Console.WriteLine("Reading revision number with Svn.Net failed: " + e.ToString());