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. 30
      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 @@ @@ -2207,13 +2207,13 @@
<Condition name = "ProjectActive" activeproject="C#"/>
<Condition name = "ProjectActive" activeproject="VBNet"/>
</Or>
<Condition name = "CompareProjectProperty" property = "TargetFrameworkVersion" equals = "v1.0">
<Condition name = "CompareProjectProperty" property = "SharpDevelopTargetFrameworkVersion" equals = "v1.0">
<ProjectContentRegistry id="Net10" class="ICSharpCode.SharpDevelop.Net10ProjectContentRegistry"/>
</Condition>
<Condition name = "CompareProjectProperty" property = "TargetFrameworkVersion" equals = "v1.1">
<Condition name = "CompareProjectProperty" property = "SharpDevelopTargetFrameworkVersion" equals = "v1.1">
<ProjectContentRegistry id="Net11" class="ICSharpCode.SharpDevelop.Net11ProjectContentRegistry"/>
</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"/>
</Condition>
</ComplexCondition>

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

@ -106,23 +106,35 @@ namespace ICSharpCode.FormsDesigner.Services @@ -106,23 +106,35 @@ namespace ICSharpCode.FormsDesigner.Services
this.formSourceFileName = formSourceFileName;
}
static readonly Dictionary<IProjectContent, object> projectContentsCurrentlyLoadingAssembly = new Dictionary<IProjectContent, object>();
/// <summary>
/// Loads the assembly represented by the project content. Returns null on failure.
/// </summary>
public static Assembly LoadAssembly(IProjectContent pc)
{
// load dependencies of current assembly
foreach (IProjectContent rpc in pc.ReferencedContents) {
if (rpc is ParseProjectContent) {
LoadAssembly(rpc);
} else if (rpc is ReflectionProjectContent) {
ReflectionProjectContent rrpc = (ReflectionProjectContent)rpc;
if (rrpc.AssemblyFullName != typeof(object).FullName
&& !FileUtility.IsBaseDirectory(GacInterop.GacRootPath, rrpc.AssemblyLocation))
{
// 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
foreach (IProjectContent rpc in pc.ReferencedContents) {
if (rpc is ParseProjectContent) {
LoadAssembly(rpc);
} else if (rpc is ReflectionProjectContent) {
ReflectionProjectContent rrpc = (ReflectionProjectContent)rpc;
if (rrpc.AssemblyFullName != typeof(object).FullName
&& !FileUtility.IsBaseDirectory(GacInterop.GacRootPath, rrpc.AssemblyLocation))
{
LoadAssembly(rpc);
}
}
}
} finally {
projectContentsCurrentlyLoadingAssembly.Remove(pc);
}
if (pc.Project != null) {

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

@ -1,6 +1,14 @@ @@ -1,6 +1,14 @@
<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 -->
<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' ">
<CscToolPath>$(SystemRoot)\Microsoft.NET\Framework\v1.0.3705</CscToolPath>
<SharpDevelopUse1xCompiler>true</SharpDevelopUse1xCompiler>

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

@ -1,6 +1,14 @@ @@ -1,6 +1,14 @@
<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 -->
<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' ">
<VbcToolPath>$(SystemRoot)\Microsoft.NET\Framework\v1.0.3705</VbcToolPath>
<SharpDevelopUse1xCompiler>true</SharpDevelopUse1xCompiler>

Loading…
Cancel
Save