Browse Source

WinFormsUI/License.txt: disable Copy to Output Directory.

Fixed a bug that could cause a file to be registered multiple times in the project content, showing all class members twice in the "quick class browser".

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2724 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
6bd9f43482
  1. 2
      src/Libraries/DockPanel_Src/WinFormsUI/WinFormsUI.csproj
  2. 1
      src/Main/Core/Project/ICSharpCode.Core.csproj
  3. 106
      src/Main/Core/Project/Src/Services/FileUtility/FileUtility.Minimal.cs
  4. 89
      src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs
  5. 3
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/ICSharpCode.SharpDevelop.Dom.csproj
  6. 9
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/DefaultProjectContent.cs

2
src/Libraries/DockPanel_Src/WinFormsUI/WinFormsUI.csproj

@ -196,7 +196,7 @@ @@ -196,7 +196,7 @@
</ItemGroup>
<ItemGroup>
<None Include="license.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>

1
src/Main/Core/Project/ICSharpCode.Core.csproj

@ -123,6 +123,7 @@ @@ -123,6 +123,7 @@
<Compile Include="Src\CoreException.cs" />
<Compile Include="Src\Services\FileUtility\FileNameEventHandler.cs" />
<Compile Include="Src\Services\FileUtility\FileUtility.cs" />
<Compile Include="Src\Services\FileUtility\FileUtility.Minimal.cs" />
<Compile Include="Src\Services\FileUtility\SaveErrorChooseDialog.cs">
<SubType>Form</SubType>
</Compile>

106
src/Main/Core/Project/Src/Services/FileUtility/FileUtility.Minimal.cs

@ -0,0 +1,106 @@ @@ -0,0 +1,106 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Text;
namespace ICSharpCode.Core
{
/// <summary>
/// A minimal version of FileUtility. Is used by ICSharpCode.SharpDevelop.Dom (which doesn't reference
/// ICSharpCode.Core)
/// </summary>
static partial class FileUtility
{
/// <summary>
/// Gets the normalized version of fileName.
/// Slashes are replaced with backslashes, backreferences "." and ".." are 'evaluated'.
/// </summary>
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);
}
}
}

89
src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs

@ -34,7 +34,7 @@ namespace ICSharpCode.Core @@ -34,7 +34,7 @@ namespace ICSharpCode.Core
/// <summary>
/// A utility class related to file utilities.
/// </summary>
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 @@ -179,93 +179,6 @@ namespace ICSharpCode.Core
return NormalizePath(Path.Combine(baseDirectoryPath, relPath));
}
/// <summary>
/// Gets the normalized version of fileName.
/// Slashes are replaced with backslashes, backreferences "." and ".." are 'evaluated'.
/// </summary>
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 {

3
src/Main/ICSharpCode.SharpDevelop.Dom/Project/ICSharpCode.SharpDevelop.Dom.csproj

@ -55,6 +55,9 @@ @@ -55,6 +55,9 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Core\Project\Src\Services\FileUtility\FileUtility.Minimal.cs">
<Link>Src\ProjectContent\FileUtility.Minimal.cs</Link>
</Compile>
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="..\..\GlobalAssemblyInfo.cs">
<Link>Configuration\GlobalAssemblyInfo.cs</Link>

9
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/DefaultProjectContent.cs

@ -315,6 +315,11 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -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 @@ -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 @@ -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

Loading…
Cancel
Save