Browse Source

Fixed SD2-512: Form Designer cannot load "Color.FromArgb" definitions

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@668 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 21 years ago
parent
commit
c7500d9f59
  1. 21
      src/AddIns/DisplayBindings/FormDesigner/Project/FormDesigner.csproj
  2. 17
      src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerLoader/NRefactoryDesignerLoader.cs
  3. 2
      src/AddIns/Misc/MbUnitPad/Project/MbUnitPad.addin
  4. 13
      src/Libraries/NRefactory/Project/NRefactory.csproj
  5. 28
      src/Libraries/NRefactory/Project/Src/Output/CodeDOM/CodeDOMOutputVisitor.cs
  6. 16
      src/Libraries/NRefactory/Test/NRefactoryTests.csproj
  7. 16
      src/Libraries/NRefactory/Test/Output/CodeDOM/InvocationExpressionTest.cs
  8. 6
      src/Main/StartUp/Project/StartUp.csproj

21
src/AddIns/DisplayBindings/FormDesigner/Project/FormDesigner.csproj

@ -13,20 +13,23 @@
<RunPostBuildEvent>OnSuccessfulBuild</RunPostBuildEvent> <RunPostBuildEvent>OnSuccessfulBuild</RunPostBuildEvent>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.FormDesigner</RootNamespace> <RootNamespace>ICSharpCode.FormDesigner</RootNamespace>
</PropertyGroup> <DebugType>Full</DebugType>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <RegisterForComInterop>False</RegisterForComInterop>
<DebugSymbols>True</DebugSymbols> <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<Optimize>False</Optimize> <PlatformTarget>AnyCPU</PlatformTarget>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<OutputPath>..\..\..\..\..\AddIns\AddIns\DisplayBindings\FormDesigner\</OutputPath> <OutputPath>..\..\..\..\..\AddIns\AddIns\DisplayBindings\FormDesigner\</OutputPath>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>False</DebugSymbols>
<Optimize>True</Optimize> <Optimize>True</Optimize>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<Optimize>False</Optimize>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<OutputPath>..\..\..\..\..\AddIns\AddIns\DisplayBindings\FormDesigner\</OutputPath> <DefineConstants>DEBUG</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />

17
src/AddIns/DisplayBindings/FormDesigner/Project/Src/FormDesigner/DesignerLoader/NRefactoryDesignerLoader.cs

@ -119,6 +119,13 @@ namespace ICSharpCode.FormDesigner
// Try to fix the type names to fully qualified ones // Try to fix the type names to fully qualified ones
ParseInformation parseInfo = ParserService.GetParseInformation(textEditorControl.FileName); ParseInformation parseInfo = ParserService.GetParseInformation(textEditorControl.FileName);
#if DEBUG
if ((Control.ModifierKeys & (Keys.Alt | Keys.Control)) == (Keys.Alt | Keys.Control)) {
System.Diagnostics.Debugger.Break();
}
#endif
bool foundInitMethod = false; bool foundInitMethod = false;
FixTypeNames(p.CompilationUnit, parseInfo.BestCompilationUnit, ref foundInitMethod); FixTypeNames(p.CompilationUnit, parseInfo.BestCompilationUnit, ref foundInitMethod);
if (!foundInitMethod) if (!foundInitMethod)
@ -128,9 +135,13 @@ namespace ICSharpCode.FormDesigner
visitor.Visit(p.CompilationUnit, null); visitor.Visit(p.CompilationUnit, null);
// output generated CodeDOM to the console : // output generated CodeDOM to the console :
// CodeDOMVerboseOutputGenerator outputGenerator = new CodeDOMVerboseOutputGenerator(); #if DEBUG
// outputGenerator.GenerateCodeFromMember(visitor.codeCompileUnit.Namespaces[0].Types[0], Console.Out, null); if ((Control.ModifierKeys & Keys.Control) == Keys.Control) {
// provider.GenerateCodeFromCompileUnit(visitor.codeCompileUnit, Console.Out, null); CodeDOMVerboseOutputGenerator outputGenerator = new CodeDOMVerboseOutputGenerator();
outputGenerator.GenerateCodeFromMember(visitor.codeCompileUnit.Namespaces[0].Types[0], Console.Out, null);
provider.GenerateCodeFromCompileUnit(visitor.codeCompileUnit, Console.Out, null);
}
#endif
LoggingService.Debug("NRefactoryDesignerLoader.Parse() finished"); LoggingService.Debug("NRefactoryDesignerLoader.Parse() finished");
return visitor.codeCompileUnit; return visitor.codeCompileUnit;

2
src/AddIns/Misc/MbUnitPad/Project/MbUnitPad.addin

@ -17,7 +17,7 @@
<Path name = "/SharpDevelop/Workbench/Pads"> <Path name = "/SharpDevelop/Workbench/Pads">
<Pad id = "MbUnitPad" <Pad id = "MbUnitPad"
category = "Tools" category = "Tools"
title = "MbUnit Tests" title = "Unit Tests"
icon = "PadIcons.MbUnitTest" icon = "PadIcons.MbUnitTest"
shortcut = "Control|Alt|T" shortcut = "Control|Alt|T"
class = "ICSharpCode.MbUnitPad.MbUnitPadContent"/> class = "ICSharpCode.MbUnitPad.MbUnitPadContent"/>

13
src/Libraries/NRefactory/Project/NRefactory.csproj

@ -17,23 +17,26 @@
<AssemblyOriginatorKeyFile>Resources\ICSharpCode.NRefactory.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>Resources\ICSharpCode.NRefactory.snk</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<Optimize>False</Optimize> <Optimize>False</Optimize>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>TEST; DEBUG</DefineConstants> <DefineConstants>TEST; DEBUG</DefineConstants>
<OutputPath>..\..\..\..\bin\</OutputPath> <OutputPath>..\..\..\..\bin\</OutputPath>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors> <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>False</DebugSymbols>
<Optimize>True</Optimize> <Optimize>True</Optimize>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TEST</DefineConstants> <DefineConstants>TEST</DefineConstants>
<OutputPath>..\..\..\..\bin\</OutputPath> <OutputPath>..\..\..\..\bin\</OutputPath>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors> <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugType>Full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>False</DebugSymbols>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />

28
src/Libraries/NRefactory/Project/Src/Output/CodeDOM/CodeDOMOutputVisitor.cs

@ -626,23 +626,15 @@ namespace ICSharpCode.NRefactory.Parser
targetExpr = new CodeThisReferenceExpression(); targetExpr = new CodeThisReferenceExpression();
} else if (target is FieldReferenceExpression) { } else if (target is FieldReferenceExpression) {
FieldReferenceExpression fRef = (FieldReferenceExpression)target; FieldReferenceExpression fRef = (FieldReferenceExpression)target;
targetExpr = (CodeExpression)fRef.TargetObject.AcceptVisitor(this, data); targetExpr = null;
// Commented out because of SD2-428: Form designer does not load child controls in panels if (fRef.TargetObject is FieldReferenceExpression) {
// if (IsQualIdent((FieldReferenceExpression)fRef.TargetObject)) {
// if (fRef.TargetObject is FieldReferenceExpression) { targetExpr = ConvertToIdentifier((FieldReferenceExpression)fRef.TargetObject);
// FieldReferenceExpression fRef2 = (FieldReferenceExpression)fRef.TargetObject; }
// if (fRef2.FieldName != null && Char.IsUpper(fRef2.FieldName[0])) { }
// // an exception is thrown if it doesn't end in an indentifier exception if (targetExpr == null)
// // for example for : this.MyObject.MyMethod() leads to an exception, which targetExpr = (CodeExpression)fRef.TargetObject.AcceptVisitor(this, data);
// // is correct in this case ... I know this is really HACKY :)
// try {
// CodeExpression tExpr = ConvertToIdentifier(fRef2);
// if (tExpr != null) {
// targetExpr = tExpr;
// }
// } catch (Exception) {}
// }
// }
methodName = fRef.FieldName; methodName = fRef.FieldName;
// HACK for : Microsoft.VisualBasic.ChrW(NUMBER) // HACK for : Microsoft.VisualBasic.ChrW(NUMBER)
if (methodName == "ChrW") { if (methodName == "ChrW") {
@ -914,6 +906,8 @@ namespace ICSharpCode.NRefactory.Parser
bool IsField(string identifier) bool IsField(string identifier)
{ {
if (currentTypeDeclaration == null) // e.g. in unit tests
return false;
foreach (INode node in currentTypeDeclaration.Children) { foreach (INode node in currentTypeDeclaration.Children) {
if (node is FieldDeclaration) { if (node is FieldDeclaration) {
FieldDeclaration fd = (FieldDeclaration)node; FieldDeclaration fd = (FieldDeclaration)node;

16
src/Libraries/NRefactory/Test/NRefactoryTests.csproj

@ -12,22 +12,26 @@
<NoConfig>False</NoConfig> <NoConfig>False</NoConfig>
<RunPostBuildEvent>OnSuccessfulBuild</RunPostBuildEvent> <RunPostBuildEvent>OnSuccessfulBuild</RunPostBuildEvent>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<OutputPath>..\..\..\..\bin\</OutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG</DefineConstants> <DefineConstants>DEBUG</DefineConstants>
<OutputPath>..\..\..\..\bin\</OutputPath> <Optimize>False</Optimize>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>False</DebugSymbols>
<Optimize>True</Optimize> <Optimize>True</Optimize>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<OutputPath>..\..\..\..\bin\</OutputPath>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors> <TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugType>Full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>False</DebugSymbols>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />

16
src/Libraries/NRefactory/Test/Output/CodeDOM/InvocationExpressionTest.cs

@ -42,5 +42,21 @@ namespace ICSharpCode.NRefactory.Tests.Output.CodeDom.Tests
Assert.AreEqual("InitializeComponents", mie.Method.MethodName); Assert.AreEqual("InitializeComponents", mie.Method.MethodName);
Assert.IsTrue(mie.Method.TargetObject is CodeThisReferenceExpression); Assert.IsTrue(mie.Method.TargetObject is CodeThisReferenceExpression);
} }
[Test]
public void InvocationOfStaticMethod()
{
// System.Drawing.Color.FromArgb();
FieldReferenceExpression field = new FieldReferenceExpression(new IdentifierExpression("System"), "Drawing");
field = new FieldReferenceExpression(field, "Color");
field = new FieldReferenceExpression(field, "FromArgb");
InvocationExpression invocation = new InvocationExpression(field, new ArrayList());
object output = invocation.AcceptVisitor(new CodeDOMVisitor(), null);
Assert.IsTrue(output is CodeMethodInvokeExpression);
CodeMethodInvokeExpression mie = (CodeMethodInvokeExpression)output;
Assert.AreEqual("FromArgb", mie.Method.MethodName);
Assert.IsTrue(mie.Method.TargetObject is CodeTypeReferenceExpression);
Assert.AreEqual("System.Drawing.Color", (mie.Method.TargetObject as CodeTypeReferenceExpression).Type.BaseType);
}
} }
} }

6
src/Main/StartUp/Project/StartUp.csproj

@ -15,19 +15,21 @@
<PreBuildEvent>..\src\Tools\UpdateAssemblyInfo\bin\Debug\UpdateAssemblyInfo.exe StartupOnly</PreBuildEvent> <PreBuildEvent>..\src\Tools\UpdateAssemblyInfo\bin\Debug\UpdateAssemblyInfo.exe StartupOnly</PreBuildEvent>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols> <DebugType>Full</DebugType>
<Optimize>False</Optimize> <Optimize>False</Optimize>
<DefineConstants>DEBUG</DefineConstants> <DefineConstants>DEBUG</DefineConstants>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<OutputPath>..\..\..\..\bin\</OutputPath> <OutputPath>..\..\..\..\bin\</OutputPath>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>False</DebugSymbols> <DebugType>None</DebugType>
<Optimize>True</Optimize> <Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<OutputPath>..\..\..\..\bin\</OutputPath> <OutputPath>..\..\..\..\bin\</OutputPath>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />

Loading…
Cancel
Save