diff --git a/src/Libraries/DockPanel_Src/WinFormsUI/WinFormsUI.csproj b/src/Libraries/DockPanel_Src/WinFormsUI/WinFormsUI.csproj index 05f4680fe4..8084a86a73 100644 --- a/src/Libraries/DockPanel_Src/WinFormsUI/WinFormsUI.csproj +++ b/src/Libraries/DockPanel_Src/WinFormsUI/WinFormsUI.csproj @@ -196,7 +196,7 @@ - Always + Never diff --git a/src/Main/Core/Project/ICSharpCode.Core.csproj b/src/Main/Core/Project/ICSharpCode.Core.csproj index 3740c5a416..085bb6be7f 100644 --- a/src/Main/Core/Project/ICSharpCode.Core.csproj +++ b/src/Main/Core/Project/ICSharpCode.Core.csproj @@ -123,6 +123,7 @@ + Form diff --git a/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.Minimal.cs b/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.Minimal.cs new file mode 100644 index 0000000000..0afbff8b7c --- /dev/null +++ b/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.Minimal.cs @@ -0,0 +1,106 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Text; + +namespace ICSharpCode.Core +{ + /// + /// A minimal version of FileUtility. Is used by ICSharpCode.SharpDevelop.Dom (which doesn't reference + /// ICSharpCode.Core) + /// + static partial class FileUtility + { + /// + /// Gets the normalized version of fileName. + /// Slashes are replaced with backslashes, backreferences "." and ".." are 'evaluated'. + /// + public static string NormalizePath(string fileName) + { + if (string.IsNullOrEmpty(fileName)) return fileName; + + int i; + + bool isWeb = false; + for (i = 0; i < fileName.Length; i++) { + if (fileName[i] == '/' || fileName[i] == '\\') + break; + if (fileName[i] == ':') { + if (i > 1) + isWeb = true; + break; + } + } + + char outputSeparator = isWeb ? '/' : '\\'; + + StringBuilder result = new StringBuilder(); + if (isWeb == false && fileName.StartsWith(@"\\") || fileName.StartsWith("//")) { + i = 2; + result.Append(outputSeparator); + } else { + i = 0; + } + int segmentStartPos = i; + for (; i <= fileName.Length; i++) { + if (i == fileName.Length || fileName[i] == '/' || fileName[i] == '\\') { + int segmentLength = i - segmentStartPos; + switch (segmentLength) { + case 0: + // ignore empty segment (if not in web mode) + if (isWeb) { + result.Append(outputSeparator); + } + break; + case 1: + // ignore /./ segment, but append other one-letter segments + if (fileName[segmentStartPos] != '.') { + if (result.Length > 0) result.Append(outputSeparator); + result.Append(fileName[segmentStartPos]); + } + break; + case 2: + if (fileName[segmentStartPos] == '.' && fileName[segmentStartPos + 1] == '.') { + // remove previous segment + int j; + for (j = result.Length - 1; j >= 0 && result[j] != outputSeparator; j--); + if (j > 0) { + result.Length = j; + } + break; + } else { + // append normal segment + goto default; + } + default: + if (result.Length > 0) result.Append(outputSeparator); + result.Append(fileName, segmentStartPos, segmentLength); + break; + } + segmentStartPos = i + 1; // remember start position for next segment + } + } + if (isWeb == false) { + if (result.Length > 0 && result[result.Length - 1] == outputSeparator) { + result.Length -= 1; + } + if (result.Length == 2 && result[1] == ':') { + result.Append(outputSeparator); + } + } + return result.ToString(); + } + + public static bool IsEqualFileName(string fileName1, string fileName2) + { + return string.Equals(NormalizePath(fileName1), + NormalizePath(fileName2), + StringComparison.OrdinalIgnoreCase); + } + } +} diff --git a/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs b/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs index 5324ec7cd8..9c62490ddb 100644 --- a/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs +++ b/src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs @@ -34,7 +34,7 @@ namespace ICSharpCode.Core /// /// A utility class related to file utilities. /// - public static class FileUtility + public static partial class FileUtility { readonly static char[] separators = { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar, Path.VolumeSeparatorChar }; static string applicationRootPath = AppDomain.CurrentDomain.BaseDirectory; @@ -179,93 +179,6 @@ namespace ICSharpCode.Core return NormalizePath(Path.Combine(baseDirectoryPath, relPath)); } - /// - /// Gets the normalized version of fileName. - /// Slashes are replaced with backslashes, backreferences "." and ".." are 'evaluated'. - /// - public static string NormalizePath(string fileName) - { - if (string.IsNullOrEmpty(fileName)) return fileName; - - int i; - - bool isWeb = false; - for (i = 0; i < fileName.Length; i++) { - if (fileName[i] == '/' || fileName[i] == '\\') - break; - if (fileName[i] == ':') { - if (i > 1) - isWeb = true; - break; - } - } - - char outputSeparator = isWeb ? '/' : '\\'; - - StringBuilder result = new StringBuilder(); - if (isWeb == false && fileName.StartsWith(@"\\") || fileName.StartsWith("//")) { - i = 2; - result.Append(outputSeparator); - } else { - i = 0; - } - int segmentStartPos = i; - for (; i <= fileName.Length; i++) { - if (i == fileName.Length || fileName[i] == '/' || fileName[i] == '\\') { - int segmentLength = i - segmentStartPos; - switch (segmentLength) { - case 0: - // ignore empty segment (if not in web mode) - if (isWeb) { - result.Append(outputSeparator); - } - break; - case 1: - // ignore /./ segment, but append other one-letter segments - if (fileName[segmentStartPos] != '.') { - if (result.Length > 0) result.Append(outputSeparator); - result.Append(fileName[segmentStartPos]); - } - break; - case 2: - if (fileName[segmentStartPos] == '.' && fileName[segmentStartPos + 1] == '.') { - // remove previous segment - int j; - for (j = result.Length - 1; j >= 0 && result[j] != outputSeparator; j--); - if (j > 0) { - result.Length = j; - } - break; - } else { - // append normal segment - goto default; - } - default: - if (result.Length > 0) result.Append(outputSeparator); - result.Append(fileName, segmentStartPos, segmentLength); - break; - } - segmentStartPos = i + 1; // remember start position for next segment - } - } - if (isWeb == false) { - if (result.Length > 0 && result[result.Length - 1] == outputSeparator) { - result.Length -= 1; - } - if (result.Length == 2 && result[1] == ':') { - result.Append(outputSeparator); - } - } - return result.ToString(); - } - - public static bool IsEqualFileName(string fileName1, string fileName2) - { - return string.Equals(NormalizePath(fileName1), - NormalizePath(fileName2), - StringComparison.OrdinalIgnoreCase); - } - public static bool IsBaseDirectory(string baseDirectory, string testDirectory) { try { diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/ICSharpCode.SharpDevelop.Dom.csproj b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/ICSharpCode.SharpDevelop.Dom.csproj index e28267b267..6fb1dc0637 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/ICSharpCode.SharpDevelop.Dom.csproj +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/ICSharpCode.SharpDevelop.Dom.csproj @@ -55,6 +55,9 @@ + + Src\ProjectContent\FileUtility.Minimal.cs + Configuration\GlobalAssemblyInfo.cs diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/DefaultProjectContent.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/DefaultProjectContent.cs index 3878aff28d..8bc2f2edde 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/DefaultProjectContent.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/DefaultProjectContent.cs @@ -315,6 +315,11 @@ namespace ICSharpCode.SharpDevelop.Dom } } + static bool IsEqualFileName(string fileName1, string fileName2) + { + return ICSharpCode.Core.FileUtility.IsEqualFileName(fileName1, fileName2); + } + protected void AddClassToNamespaceListInternal(IClass addClass) { string fullyQualifiedName = addClass.FullyQualifiedName; @@ -330,7 +335,7 @@ namespace ICSharpCode.SharpDevelop.Dom // possibly replace existing class (look for CU with same filename) lock (compound) { for (int i = 0; i < compound.parts.Count; i++) { - if (compound.parts[i].CompilationUnit.FileName == addClass.CompilationUnit.FileName) { + if (IsEqualFileName(compound.parts[i].CompilationUnit.FileName, addClass.CompilationUnit.FileName)) { compound.parts[i] = addClass; compound.UpdateInformationFromParts(); //LoggingService.Debug("Replaced old part!"); @@ -343,7 +348,7 @@ namespace ICSharpCode.SharpDevelop.Dom //LoggingService.Debug("Added new part!"); return; - } else if (existingClass.CompilationUnit.FileName != addClass.CompilationUnit.FileName) { + } else if (!IsEqualFileName(existingClass.CompilationUnit.FileName, addClass.CompilationUnit.FileName)) { // Instead of overwriting a class with another, treat both parts as partial. // This fixes SD2-1217. // But if the classes are in the same file, this is an update and we need to replace