Browse Source

Prevent StackOverflowException when loading assemblies with cyclic dependencies into the forms designer. Fixes SD2-1177: Forms Designer for .NET 1.1 projects (System.dll and System.Xml.dll depend on each other)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2084 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
e9dc0db183
  1. 6
      AddIns/ICSharpCode.SharpDevelop.addin
  2. 12
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs
  3. 8
      src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.Build.CSharp.targets
  4. 8
      src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.Build.VisualBasic.targets

6
AddIns/ICSharpCode.SharpDevelop.addin

@ -2207,13 +2207,13 @@
<Condition name = "ProjectActive" activeproject="C#"/> <Condition name = "ProjectActive" activeproject="C#"/>
<Condition name = "ProjectActive" activeproject="VBNet"/> <Condition name = "ProjectActive" activeproject="VBNet"/>
</Or> </Or>
<Condition name = "CompareProjectProperty" property = "TargetFrameworkVersion" equals = "v1.0"> <Condition name = "CompareProjectProperty" property = "SharpDevelopTargetFrameworkVersion" equals = "v1.0">
<ProjectContentRegistry id="Net10" class="ICSharpCode.SharpDevelop.Net10ProjectContentRegistry"/> <ProjectContentRegistry id="Net10" class="ICSharpCode.SharpDevelop.Net10ProjectContentRegistry"/>
</Condition> </Condition>
<Condition name = "CompareProjectProperty" property = "TargetFrameworkVersion" equals = "v1.1"> <Condition name = "CompareProjectProperty" property = "SharpDevelopTargetFrameworkVersion" equals = "v1.1">
<ProjectContentRegistry id="Net11" class="ICSharpCode.SharpDevelop.Net11ProjectContentRegistry"/> <ProjectContentRegistry id="Net11" class="ICSharpCode.SharpDevelop.Net11ProjectContentRegistry"/>
</Condition> </Condition>
<Condition name = "CompareProjectProperty" property = "TargetFrameworkVersion" equals = "CF 2.0"> <Condition name = "CompareProjectProperty" property = "SharpDevelopTargetFrameworkVersion" equals = "CF 2.0">
<ProjectContentRegistry id="NetCF20" class="ICSharpCode.SharpDevelop.NetCF20ProjectContentRegistry"/> <ProjectContentRegistry id="NetCF20" class="ICSharpCode.SharpDevelop.NetCF20ProjectContentRegistry"/>
</Condition> </Condition>
</ComplexCondition> </ComplexCondition>

12
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs

@ -106,11 +106,20 @@ namespace ICSharpCode.FormsDesigner.Services
this.formSourceFileName = formSourceFileName; this.formSourceFileName = formSourceFileName;
} }
static readonly Dictionary<IProjectContent, object> projectContentsCurrentlyLoadingAssembly = new Dictionary<IProjectContent, object>();
/// <summary> /// <summary>
/// Loads the assembly represented by the project content. Returns null on failure. /// Loads the assembly represented by the project content. Returns null on failure.
/// </summary> /// </summary>
public static Assembly LoadAssembly(IProjectContent pc) public static Assembly LoadAssembly(IProjectContent pc)
{ {
// prevent StackOverflow when project contents have cyclic dependencies
// Very popular example of cyclic dependency: System <-> System.Xml (yes, really!)
if (projectContentsCurrentlyLoadingAssembly.ContainsKey(pc))
return null;
projectContentsCurrentlyLoadingAssembly.Add(pc, null);
try {
// load dependencies of current assembly // load dependencies of current assembly
foreach (IProjectContent rpc in pc.ReferencedContents) { foreach (IProjectContent rpc in pc.ReferencedContents) {
if (rpc is ParseProjectContent) { if (rpc is ParseProjectContent) {
@ -124,6 +133,9 @@ namespace ICSharpCode.FormsDesigner.Services
} }
} }
} }
} finally {
projectContentsCurrentlyLoadingAssembly.Remove(pc);
}
if (pc.Project != null) { if (pc.Project != null) {
return LoadAssembly(((IProject)pc.Project).OutputAssemblyFullPath); return LoadAssembly(((IProject)pc.Project).OutputAssemblyFullPath);

8
src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.Build.CSharp.targets

@ -1,6 +1,14 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- This file can be used to compile C# applications against other .NET Framework versions --> <!-- This file can be used to compile C# applications against other .NET Framework versions -->
<PropertyGroup>
<!--
Save original target framework version because we'll need to change it
to work around a problem in Microsoft's C# targets
-->
<SharpDevelopTargetFrameworkVersion>$(TargetFrameworkVersion)</SharpDevelopTargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFrameworkVersion)' == 'v1.0' "> <PropertyGroup Condition=" '$(TargetFrameworkVersion)' == 'v1.0' ">
<CscToolPath>$(SystemRoot)\Microsoft.NET\Framework\v1.0.3705</CscToolPath> <CscToolPath>$(SystemRoot)\Microsoft.NET\Framework\v1.0.3705</CscToolPath>
<SharpDevelopUse1xCompiler>true</SharpDevelopUse1xCompiler> <SharpDevelopUse1xCompiler>true</SharpDevelopUse1xCompiler>

8
src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.Build.VisualBasic.targets

@ -1,6 +1,14 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- This file can be used to compile VB.NET applications against other .NET Framework versions --> <!-- This file can be used to compile VB.NET applications against other .NET Framework versions -->
<PropertyGroup>
<!--
Save original target framework version because we'll need to change it
to work around a problem in Microsoft's C# targets
-->
<SharpDevelopTargetFrameworkVersion>$(TargetFrameworkVersion)</SharpDevelopTargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFrameworkVersion)' == 'v1.0' "> <PropertyGroup Condition=" '$(TargetFrameworkVersion)' == 'v1.0' ">
<VbcToolPath>$(SystemRoot)\Microsoft.NET\Framework\v1.0.3705</VbcToolPath> <VbcToolPath>$(SystemRoot)\Microsoft.NET\Framework\v1.0.3705</VbcToolPath>
<SharpDevelopUse1xCompiler>true</SharpDevelopUse1xCompiler> <SharpDevelopUse1xCompiler>true</SharpDevelopUse1xCompiler>

Loading…
Cancel
Save