Browse Source

Fixed SD2-1149: Partial generic classes not correctly supported

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2030 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
5f991c3e21
  1. 19
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ProjectContent/DefaultProjectContent.cs

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

@ -465,10 +465,15 @@ namespace ICSharpCode.SharpDevelop.Dom
{ {
foreach (IClass c in oldUnit.Classes) { foreach (IClass c in oldUnit.Classes) {
bool found = false; bool found = false;
foreach (IClass c2 in newUnit.Classes) { // Partial classes always have to be removed. Otherwise editing the type
if (c.FullyQualifiedName == c2.FullyQualifiedName) { // arguments of a partial would leave the class registered in the wrong compound
found = true; // class. See SD2-1149.
break; if (!c.IsPartial) {
foreach (IClass c2 in newUnit.Classes) {
if (c.FullyQualifiedName == c2.FullyQualifiedName) {
found = true;
break;
}
} }
} }
if (!found) { if (!found) {
@ -480,11 +485,13 @@ namespace ICSharpCode.SharpDevelop.Dom
void RemoveClass(IClass @class) void RemoveClass(IClass @class)
{ {
string fullyQualifiedName = @class.FullyQualifiedName; string fullyQualifiedName = @class.FullyQualifiedName;
int typeParameterCount = @class.TypeParameters.Count;
if (@class.IsPartial) { if (@class.IsPartial) {
// remove a part of a partial class // remove a part of a partial class
// Use "as" cast to fix SD2-680: the stored class might be a part not marked as partial // Use "as" cast to fix SD2-680: the stored class might be a part not marked as partial
CompoundClass compound = GetClassInternal(fullyQualifiedName, @class.TypeParameters.Count, language) as CompoundClass; CompoundClass compound = GetClassInternal(fullyQualifiedName, typeParameterCount, language) as CompoundClass;
if (compound == null) return; if (compound == null) return;
typeParameterCount = compound.TypeParameters.Count;
lock (compound) { lock (compound) {
compound.parts.Remove(@class); compound.parts.Remove(@class);
if (compound.parts.Count > 0) { if (compound.parts.Count > 0) {
@ -503,7 +510,7 @@ namespace ICSharpCode.SharpDevelop.Dom
GenericClassContainer gcc = classInDictionary as GenericClassContainer; GenericClassContainer gcc = classInDictionary as GenericClassContainer;
if (gcc != null) { if (gcc != null) {
gcc.Remove(@class.TypeParameters.Count); gcc.Remove(typeParameterCount);
if (gcc.RealClassCount > 0) { if (gcc.RealClassCount > 0) {
return; return;
} }

Loading…
Cancel
Save