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

Loading…
Cancel
Save