Dominik Guder schrieb: > Hi, > > This is a follow up to [ nantcontrib-Bugs-1082302 ] Vb6task ignors > references when parsing the project. > https://sourceforge.net/tracker/?func=detail&atid=474851&aid=1082302&group_id=54790 >
Patch attached -- The answer to the great question of life, the universe and everything is 42 (Douglas Adams)
--- U:\projects\nant\nantcontrib-0.85-rc2\src\Tasks\Vb6Task.cs.org Wed Jan 12 20:02:08 2005 +++ U:\projects\nant\nantcontrib-0.85-rc2\src\Tasks\Vb6Task.cs Wed Mar 23 09:48:58 2005 @@ -325,11 +325,11 @@ /// 5. Get the TLB filename and returns it /// </summary> /// <param name="guid">The guid of the tlb to look for</param> - /// <param name="major">The major version number of the tlb</param> + /// <param name="major16">The major version number of the tlb</param> /// <param name="minor16">The minor version number of the tlb. If you parse minor from a string, treat the string as hex value.</param> /// <param name="lcid">The culture id</param> /// <returns>null if couldn't find a match, otherwise it returns the file.</returns> - private string VB6GetTypeLibFile(Guid guid, ushort major, ushort minor16, uint lcid) { + private string VB6GetTypeLibFile(Guid guid, ushort major16, ushort minor16, uint lcid) { string tlbFile = null; Microsoft.Win32.RegistryKey regKey; @@ -340,17 +340,18 @@ if (regKeyCulture == null) continue; - ushort tmpMajor = 0; + ushort tmpMajor16 = 0; ushort tmpMinor16 = 0; string [] parts = ver.Split('.'); if (parts.Length > 0) { - tmpMajor = (ushort) double.Parse(parts[0], CultureInfo.InvariantCulture); + // tmpMajor = (ushort) double.Parse(parts[0], CultureInfo.InvariantCulture); + tmpMajor16 = Convert.ToUInt16(parts[0], 16); // Treat major as hex if (parts.Length > 1) { tmpMinor16 = Convert.ToUInt16(parts[1], 16); // Treat minor as hex } } - if (major < tmpMajor || (major == tmpMajor && minor16 <= tmpMinor16)) { + if (major16 < tmpMajor16 || (major16 == tmpMajor16 && minor16 <= tmpMinor16)) { // Found it.. Microsoft.Win32.RegistryKey regKeyWin32 = regKeyCulture.OpenSubKey("win32"); if (regKeyWin32 != null) { @@ -400,7 +401,7 @@ Regex codeRegEx = new Regex(@"(Class|Module)\s*=\s*\w*;\s*(?<filename>.*($^\.)*)\s*$"); // Regexp that extracts reference entries from the VBP (Reference=) - Regex referenceRegEx = new Regex(@"(Object|Reference)\s*=\s*({|\*\\G{)(?<tlbguid>[0-9\-A-Fa-f]*($^\.)*)}\#(?<majorver>[0-9($^\.)]*)\.(?<minorver>[0-9a-fA-F($^\.)]*)\#(?<lcid>[0-9]($^\.)*)(;|\#)(?<tlbname>[^\#\n\r]*)"); + Regex referenceRegEx = new Regex(@"(Object|Reference)\s*=\s*({|\*\\G{)(?<tlbguid>[0-9\-A-Fa-f]*($^\.)*)}\#(?<majorver>[0-9a-fA-F($^\.)]*)\.(?<minorver>[0-9a-fA-F($^\.)]*)\#(?<lcid>[0-9]($^\.)*)(;|\#)(?<tlbname>[^\#\n\r]*)"); string key = String.Empty; string keyValue = String.Empty; @@ -443,7 +444,8 @@ // # Added to properly cast the parts of the version # // Ensure that we use the correct cast option string temp = match.Groups["majorver"].Value; - ushort majorVer = (ushort) double.Parse(temp, CultureInfo.InvariantCulture); + //ushort majorVer = (ushort) double.Parse(temp, CultureInfo.InvariantCulture); + ushort majorVer16 = Convert.ToUInt16(temp, 16); // Minor is considered a hex value temp = match.Groups["minorver"].Value; @@ -460,13 +462,13 @@ Guid guid = new Guid(tlbGuid); // Find the tlb file - tlbName = VB6GetTypeLibFile(guid, majorVer, minorVer16, lcid); + tlbName = VB6GetTypeLibFile(guid, majorVer16, minorVer16, lcid); if (File.Exists(tlbName)) { references.Includes.Add(tlbName); } else { // Show a warning if we couldn't find the reference. Don't rely on VB. if (tlbName == null) { - Log(Level.Warning, "Couldn't find the tlb file for '{0}' ver.{1}.{2:x}.", guid, majorVer, minorVer16); + Log(Level.Warning, "Couldn't find the tlb file for '{0}' ver.{1}.{2:x}.", guid, majorVer16, minorVer16); } else { Log(Level.Warning, "Couldn't find the file '{0}'.", tlbName); }