diff --git a/data/resources/StringResources.fr.resx b/data/resources/StringResources.fr.resx
index e8e68aa95f..2ea1fca7a5 100644
--- a/data/resources/StringResources.fr.resx
+++ b/data/resources/StringResources.fr.resx
@@ -4973,6 +4973,9 @@ Soit ils n'existent pas, soit le document Wix n'est pas pour WiX 3.0 et l'espace
Copier la valeur dans le presse-papier
+
+ Nom
+
Membres non publics
@@ -4994,6 +4997,12 @@ Soit ils n'existent pas, soit le document Wix n'est pas pour WiX 3.0 et l'espace
Membres statiques
+
+ Type
+
+
+ Valeur
+
Mémoire
@@ -5369,6 +5378,9 @@ Soit ils n'existent pas, soit le document Wix n'est pas pour WiX 3.0 et l'espace
Ouvrir le répertoire dans l'explorateur
+
+ Ouvrir une invite de commande ici
+
Réduire tous les noeuds
@@ -5504,6 +5516,9 @@ Soit ils n'existent pas, soit le document Wix n'est pas pour WiX 3.0 et l'espace
Lance&r projet
+
+ Exécuter ce projet sans débogueur
+
Définir comme projet de dém&arrage
diff --git a/data/resources/StringResources.nl.resx b/data/resources/StringResources.nl.resx
index 7cd2bbc355..5660fe197f 100644
--- a/data/resources/StringResources.nl.resx
+++ b/data/resources/StringResources.nl.resx
@@ -5380,6 +5380,9 @@ Microsoft.Tools.WindowsInstallerXml.Extenties.NetFxCompiler, WixNetFxExtentie
Open de document bevattende map in de Explorer
+
+ Open hier de commando prompt
+
Alle knooppunten invouwen
@@ -5515,6 +5518,9 @@ Microsoft.Tools.WindowsInstallerXml.Extenties.NetFxCompiler, WixNetFxExtentie
P&roject starten
+
+ Project uitvoeren zonder foutopsporing
+
Als startproject instellen.
diff --git a/data/templates/packages/Modernizr.1.7.nupkg b/data/templates/packages/Modernizr.1.7.nupkg
deleted file mode 100644
index df76835723..0000000000
Binary files a/data/templates/packages/Modernizr.1.7.nupkg and /dev/null differ
diff --git a/data/templates/packages/Modernizr.2.5.3.nupkg b/data/templates/packages/Modernizr.2.5.3.nupkg
new file mode 100644
index 0000000000..98ade6d191
Binary files /dev/null and b/data/templates/packages/Modernizr.2.5.3.nupkg differ
diff --git a/data/templates/packages/jQuery.1.6.1.nupkg b/data/templates/packages/jQuery.1.6.1.nupkg
deleted file mode 100644
index 7591b33c89..0000000000
Binary files a/data/templates/packages/jQuery.1.6.1.nupkg and /dev/null differ
diff --git a/data/templates/packages/jQuery.1.7.2.nupkg b/data/templates/packages/jQuery.1.7.2.nupkg
new file mode 100644
index 0000000000..033bae95d0
Binary files /dev/null and b/data/templates/packages/jQuery.1.7.2.nupkg differ
diff --git a/data/templates/project/CSharp/MvcRazorProject.xpt b/data/templates/project/CSharp/MvcRazorProject.xpt
index 37e610e87b..d517855fe8 100644
--- a/data/templates/project/CSharp/MvcRazorProject.xpt
+++ b/data/templates/project/CSharp/MvcRazorProject.xpt
@@ -273,8 +273,8 @@ Aliquam suscipit tellus vel nunc elementum fringilla.
@ViewBag.Title
-
-
+
+
@@ -300,8 +300,8 @@ Aliquam suscipit tellus vel nunc elementum fringilla.
-
-
+
+
]]>
diff --git a/data/templates/project/CSharp/MvcWebProject.xpt b/data/templates/project/CSharp/MvcWebProject.xpt
index bd14354e5e..93d614f7d1 100644
--- a/data/templates/project/CSharp/MvcWebProject.xpt
+++ b/data/templates/project/CSharp/MvcWebProject.xpt
@@ -280,8 +280,8 @@ namespace ${StandardNamespace}
" rel="stylesheet" type="text/css">
-
-
+
+
@@ -307,8 +307,8 @@ namespace ${StandardNamespace}
-
-
+
+
]]>
diff --git a/data/templates/project/VB/MvcRazorProject.xpt b/data/templates/project/VB/MvcRazorProject.xpt
index bd94faf848..87ba3a7275 100644
--- a/data/templates/project/VB/MvcRazorProject.xpt
+++ b/data/templates/project/VB/MvcRazorProject.xpt
@@ -265,8 +265,8 @@ Aliquam suscipit tellus vel nunc elementum fringilla.
@ViewData("Title")
-
-
+
+
@@ -292,8 +292,8 @@ Aliquam suscipit tellus vel nunc elementum fringilla.
-
-
+
+
]]>
diff --git a/data/templates/project/VB/MvcWebProject.xpt b/data/templates/project/VB/MvcWebProject.xpt
index f472bafb05..5be3b65b5a 100644
--- a/data/templates/project/VB/MvcWebProject.xpt
+++ b/data/templates/project/VB/MvcWebProject.xpt
@@ -272,8 +272,8 @@ End Class
" rel="stylesheet" type="text/css">
-
-
+
+
@@ -299,8 +299,8 @@ End Class
-
-
+
+
]]>
diff --git a/samples/MSTest/MSTest.SharpDevelop.Tests/MSTest.SharpDevelop.Tests.csproj b/samples/MSTest/MSTest.SharpDevelop.Tests/MSTest.SharpDevelop.Tests.csproj
new file mode 100644
index 0000000000..8334f2708a
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop.Tests/MSTest.SharpDevelop.Tests.csproj
@@ -0,0 +1,69 @@
+
+
+
+ {51D56190-67B7-4A49-BA0A-24010460CCC6}
+ Debug
+ x86
+ Library
+ MSTest.SharpDevelop.Tests
+ MSTest.SharpDevelop.Tests
+ v4.0
+ Properties
+
+
+ x86
+
+
+ bin\Debug\
+ True
+ Full
+ False
+ True
+ DEBUG;TRACE
+
+
+ bin\Release\
+ False
+ None
+ True
+ False
+ TRACE
+
+
+
+ ..\..\..\bin\ICSharpCode.Core.dll
+
+
+ ..\..\..\bin\ICSharpCode.SharpDevelop.dll
+
+
+ ..\..\..\bin\ICSharpCode.SharpDevelop.Dom.dll
+
+
+ ..\..\..\src\Tools\NUnit\nunit.framework.dll
+
+
+ ..\..\..\src\Libraries\RhinoMocks\Rhino.Mocks.dll
+
+
+
+ 3.5
+
+
+
+ ..\..\..\AddIns\Analysis\UnitTesting\UnitTesting.dll
+
+
+
+
+
+
+
+
+
+ {8DF3A610-47F9-4448-B455-952BD57CB5CC}
+ MSTest.SharpDevelop
+
+
+
+
\ No newline at end of file
diff --git a/samples/MSTest/MSTest.SharpDevelop.Tests/MSTestFrameworkTests.cs b/samples/MSTest/MSTest.SharpDevelop.Tests/MSTestFrameworkTests.cs
new file mode 100644
index 0000000000..be70c9d48c
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop.Tests/MSTestFrameworkTests.cs
@@ -0,0 +1,338 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+
+using ICSharpCode.MSTest;
+using ICSharpCode.SharpDevelop.Dom;
+using ICSharpCode.SharpDevelop.Project;
+using ICSharpCode.UnitTesting;
+using NUnit.Framework;
+using Rhino.Mocks;
+
+namespace MSTest.SharpDevelop.Tests
+{
+ [TestFixture]
+ public class MSTestFrameworkTests
+ {
+ MSTestFramework testFramework;
+ IProject fakeProject;
+
+ [SetUp]
+ public void Init()
+ {
+ testFramework = new MSTestFramework();
+
+ fakeProject = MockRepository.GenerateStub();
+ fakeProject.Stub(p => p.SyncRoot).Return(fakeProject);
+ }
+
+ void AddReferencesToProject(params string[] referenceNames)
+ {
+ List projectItems = referenceNames
+ .Select(name => new ReferenceProjectItem(fakeProject, name) as ProjectItem)
+ .ToList();
+
+ AddItemsToProject(projectItems);
+ }
+
+ void AddItemsToProject(List projectItems)
+ {
+ fakeProject
+ .Stub(project => project.Items)
+ .Return(new ReadOnlyCollection(projectItems));
+ }
+
+ void AddFileAndReferenceToProject(string fileName, string reference)
+ {
+ var projectItems = new List();
+ projectItems.Add(new FileProjectItem(fakeProject, ItemType.Compile, fileName));
+ projectItems.Add(new ReferenceProjectItem(fakeProject, reference));
+
+ AddItemsToProject(projectItems);
+ }
+
+ void NoItemsInProject()
+ {
+ AddReferencesToProject();
+ }
+
+ IClass CreateClassWithoutAnyAttributes()
+ {
+ IClass fakeClass = MockRepository.GenerateStub();
+ AddAttributesToClass(fakeClass, new List());
+ return fakeClass;
+ }
+
+ void AddAttributesToClass(IClass fakeClass, List attributes)
+ {
+ fakeClass.Stub(c => c.Attributes).Return(attributes);
+ }
+
+ IClass CreateClassWithAttributes(params string[] attributeNames)
+ {
+ IClass fakeClass = MockRepository.GenerateStub();
+
+ List attributes = CreateAttributes(attributeNames);
+
+ AddAttributesToClass(fakeClass, attributes);
+
+ return fakeClass;
+ }
+
+ List CreateAttributes(params string[] attributeNames)
+ {
+ return attributeNames.Select(name => CreateAttribute(name)).ToList();
+ }
+
+ IAttribute CreateAttribute(string name)
+ {
+ IReturnType returnType = MockRepository.GenerateStub();
+ returnType.Stub(t => t.FullyQualifiedName).Return(name);
+
+ IAttribute attribute = MockRepository.GenerateStub();
+ attribute.Stub(a => a.AttributeType).Return(returnType);
+ return attribute;
+ }
+
+ void MakeClassAbstract(IClass fakeClass)
+ {
+ fakeClass.Stub(c => c.IsAbstract).Return(true);
+ }
+
+ IMethod CreateMethodWithoutAnyAttributes()
+ {
+ IMethod fakeMethod = MockRepository.GenerateStub();
+ AddAttributesToMethod(fakeMethod, new List());
+ return fakeMethod;
+ }
+
+ IMethod CreateMethodWithAttributes(params string[] attributeNames)
+ {
+ IMethod fakeMethod = MockRepository.GenerateStub();
+ List attributes = CreateAttributes(attributeNames);
+ AddAttributesToMethod(fakeMethod, attributes);
+ return fakeMethod;
+ }
+
+ void AddAttributesToMethod(IMethod method, List attributes)
+ {
+ method.Stub(m => m.Attributes).Return(attributes);
+ }
+
+ List GetTestMembersFor(IClass fakeClass)
+ {
+ return testFramework.GetTestMembersFor(fakeClass).ToList();
+ }
+
+ void AddMethodsToClass(IClass fakeClass, List methods)
+ {
+ fakeClass.Stub(c => c.Methods).Return(methods);
+ }
+
+ [Test]
+ public void IsTestProject_NullProject_ReturnsFalse()
+ {
+ bool result = testFramework.IsTestProject(null);
+
+ Assert.IsFalse(result);
+ }
+
+ [Test]
+ public void IsTestProject_ProjectWithMSTestAssemblyReference_ReturnsTrue()
+ {
+ AddReferencesToProject("System", "Microsoft.VisualStudio.QualityTools.UnitTestFramework");
+
+ bool result = testFramework.IsTestProject(fakeProject);
+
+ Assert.IsTrue(result);
+ }
+
+ [Test]
+ public void IsTestProject_ProjectWithoutMSTestAssemblyReference_ReturnsFalse()
+ {
+ NoItemsInProject();
+ bool result = testFramework.IsTestProject(fakeProject);
+
+ Assert.IsFalse(result);
+ }
+
+ [Test]
+ public void IsTestProject_ProjectWithMSTestAssemblyReferenceInUpperCase_ReturnsTrue()
+ {
+ AddReferencesToProject("MICROSOFT.VISUALSTUDIO.QUALITYTOOLS.UNITTESTFRAMEWORK");
+
+ bool result = testFramework.IsTestProject(fakeProject);
+
+ Assert.IsTrue(result);
+ }
+
+ [Test]
+ public void IsTestProject_ProjectWithMSTestAssemblyReferenceAndFileProjectItem_ReturnsTrue()
+ {
+ AddFileAndReferenceToProject("test.cs", "Microsoft.VisualStudio.QualityTools.UnitTestFramework");
+
+ bool result = testFramework.IsTestProject(fakeProject);
+
+ Assert.IsTrue(result);
+ }
+
+ [Test]
+ public void IsTestProject_ProjectWithMSTestAssemblyReferenceUsingFullName_ReturnsTrue()
+ {
+ AddReferencesToProject("Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=2.5.3.9345, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77");
+
+ bool result = testFramework.IsTestProject(fakeProject);
+
+ Assert.IsTrue(result);
+ }
+
+ [Test]
+ public void IsTestClass_ClassHasNoAttributes_ReturnsFalse()
+ {
+ IClass fakeClass = CreateClassWithoutAnyAttributes();
+
+ bool result = testFramework.IsTestClass(fakeClass);
+
+ Assert.IsFalse(result);
+ }
+
+ [Test]
+ public void IsTestClass_ClassHasTestFixtureAttributeMissingAttributePart_ReturnsTrue()
+ {
+ IClass fakeClass = CreateClassWithAttributes("TestClass");
+
+ bool result = testFramework.IsTestClass(fakeClass);
+
+ Assert.IsTrue(result);
+ }
+
+ [Test]
+ public void IsTestClass_ClassHasTestClassAttributeAndIsAbstract_ReturnsFalse()
+ {
+ IClass fakeClass = CreateClassWithAttributes("TestClass");
+ MakeClassAbstract(fakeClass);
+
+ bool result = testFramework.IsTestClass(fakeClass);
+
+ Assert.IsFalse(result);
+ }
+
+ [Test]
+ public void IsTestClass_ClassHasTestClassAttributeIncludingAttributePart_ReturnsTrue()
+ {
+ IClass fakeClass = CreateClassWithAttributes("TestClassAttribute");
+
+ bool result = testFramework.IsTestClass(fakeClass);
+
+ Assert.IsTrue(result);
+ }
+
+ [Test]
+ public void IsTestClass_ClassHasFullyQualifiedMSTestClassAttribute_ReturnsTrue()
+ {
+ IClass fakeClass = CreateClassWithAttributes("Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute");
+
+ bool result = testFramework.IsTestClass(fakeClass);
+
+ Assert.IsTrue(result);
+ }
+
+ [Test]
+ public void IsTestClass_ClassIsNull_ReturnsFalse()
+ {
+ bool result = testFramework.IsTestClass(null);
+
+ Assert.IsFalse(result);
+ }
+
+ [Test]
+ public void IsTestMember_MethodHasNoAttributes_ReturnsFalse()
+ {
+ IMethod method = CreateMethodWithoutAnyAttributes();
+
+ bool result = testFramework.IsTestMember(method);
+
+ Assert.IsFalse(result);
+ }
+
+ [Test]
+ public void IsTestMember_MethodHasTestMethodAttributeWithoutAttributePart_ReturnsTrue()
+ {
+ IMethod method = CreateMethodWithAttributes("TestMethod");
+
+ bool result = testFramework.IsTestMember(method);
+
+ Assert.IsTrue(result);
+ }
+
+ [Test]
+ public void IsTestMember_MethodHasTestMethodAttributeAttribute_ReturnsTrue()
+ {
+ IMethod method = CreateMethodWithAttributes("TestMethodAttribute");
+
+ bool result = testFramework.IsTestMember(method);
+
+ Assert.IsTrue(result);
+ }
+
+ [Test]
+ public void IsTestMember_MethodHasFullyQualifiedMSTestTestMethodAttribute_ReturnsTrue()
+ {
+ IMethod method = CreateMethodWithAttributes("Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute");
+
+ bool result = testFramework.IsTestMember(method);
+
+ Assert.IsTrue(result);
+ }
+
+ [Test]
+ public void IsTestMember_MethodIsNull_ReturnsFalse()
+ {
+ bool result = testFramework.IsTestMember(null);
+
+ Assert.IsFalse(result);
+ }
+
+ [Test]
+ public void IsTestMember_MemberNotMethod_ReturnsFalse()
+ {
+ IMember member = MockRepository.GenerateStub();
+
+ bool result = testFramework.IsTestMember(member);
+
+ Assert.IsFalse(result);
+ }
+
+ [Test]
+ public void GetTestMembersFor_ClassHasNoMethods_ReturnsFalse()
+ {
+ IClass fakeClass = CreateClassWithAttributes("TestClass");
+ AddMethodsToClass(fakeClass, new List());
+
+ List testMembers = GetTestMembersFor(fakeClass);
+
+ Assert.AreEqual(0, testMembers.Count);
+ }
+
+ [Test]
+ public void GetTestMembersFor_ClassHasTwoMethodsAndSecondOneIsTestMethod_ReturnsSecondTestMethodOnly()
+ {
+ IClass fakeClass = CreateClassWithAttributes("TestClass");
+
+ var methods = new List();
+ methods.Add(CreateMethodWithoutAnyAttributes());
+ IMethod testMethod = CreateMethodWithAttributes("TestMethod");
+ methods.Add(testMethod);
+ AddMethodsToClass(fakeClass, methods);
+
+ List testMembers = GetTestMembersFor(fakeClass);
+
+ Assert.AreEqual(1, testMembers.Count);
+ Assert.AreEqual(testMethod, testMembers[0].Member);
+ }
+ }
+}
diff --git a/samples/MSTest/MSTest.SharpDevelop.Tests/MSTestResultsTests.cs b/samples/MSTest/MSTest.SharpDevelop.Tests/MSTestResultsTests.cs
new file mode 100644
index 0000000000..c5304011f6
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop.Tests/MSTestResultsTests.cs
@@ -0,0 +1,184 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Xml;
+using ICSharpCode.MSTest;
+using ICSharpCode.SharpDevelop.Dom;
+using ICSharpCode.UnitTesting;
+using NUnit.Framework;
+
+namespace MSTest.SharpDevelop.Tests
+{
+ [TestFixture]
+ public class MSTestResultsTests
+ {
+ MSTestResults testResults;
+
+ void CreateMSTestResults(string xml)
+ {
+ using (var reader = new XmlTextReader(new StringReader(xml))) {
+ testResults = new MSTestResults(reader);
+ }
+ }
+
+ void AssertTestResultsAreEqual(TestResult[] expectedResults)
+ {
+ List expectedResultsAsString = ConvertToStrings(expectedResults);
+ List actualResultsAsString = ConvertToStrings(testResults);
+ CollectionAssert.AreEqual(expectedResultsAsString, actualResultsAsString);
+ }
+
+ List ConvertToStrings(IEnumerable results)
+ {
+ return results.Select(
+ result => String.Format(
+ "Name: {0}, Result: {1}, Message: '{2}', StackTrace: '{3}', StackPosition: {4}",
+ result.Name,
+ result.ResultType,
+ result.Message,
+ result.StackTrace,
+ result.StackTraceFilePosition))
+ .ToList();
+ }
+
+ [Test]
+ public void Results_OneClassWithTwoPassingTestMethods_ReturnsTwoResults()
+ {
+ CreateMSTestResults(oneClassWithTwoPassingTestMethods);
+
+ var expectedResults = new TestResult[] {
+ new TestResult("FooTest.UnitTest1.TestMethod1") {
+ ResultType = TestResultType.Success
+ },
+ new TestResult("FooTest.UnitTest1.TestMethod2") {
+ ResultType = TestResultType.Success
+ },
+ };
+ AssertTestResultsAreEqual(expectedResults);
+ }
+
+ string oneClassWithTwoPassingTestMethods =
+
+@"
+
+
+ These are default test settings for a local test run.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+";
+
+ [Test]
+ public void Results_OneTestMethodThrowsException_ReturnsOneErrorResultWithStackTrace()
+ {
+ CreateMSTestResults(oneTestMethodThrowsException);
+
+ var expectedResults = new TestResult[] {
+ new TestResult("FooTest.UnitTest1.TestMethod1") {
+ ResultType = TestResultType.Failure,
+ Message = "System.ApplicationException: asdfafds",
+ StackTrace = " at FooTest.UnitTest1.TestMethod1() in d:\\projects\\FooTest\\UnitTest1.cs:line 21\r\n",
+ StackTraceFilePosition = new FilePosition(@"d:\projects\FooTest\UnitTest1.cs", 21, 1)
+ }
+ };
+ AssertTestResultsAreEqual(expectedResults);
+ }
+
+ string oneTestMethodThrowsException =
+
+@"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+";
+ }
+}
diff --git a/samples/MSTest/MSTest.SharpDevelop.Tests/Properties/AssemblyInfo.cs b/samples/MSTest/MSTest.SharpDevelop.Tests/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..cdff605abd
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop.Tests/Properties/AssemblyInfo.cs
@@ -0,0 +1,31 @@
+#region Using directives
+
+using System;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+#endregion
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("MSTest.SharpDevelop.Tests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("MSTest.SharpDevelop.Tests")]
+[assembly: AssemblyCopyright("Copyright 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// This sets the default COM visibility of types in the assembly to invisible.
+// If you need to expose a type to COM, use [ComVisible(true)] on that type.
+[assembly: ComVisible(false)]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all the values or you can use the default the Revision and
+// Build Numbers by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0")]
diff --git a/samples/MSTest/MSTest.SharpDevelop.sln b/samples/MSTest/MSTest.SharpDevelop.sln
new file mode 100644
index 0000000000..6166e73ff1
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop.sln
@@ -0,0 +1,24 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+# SharpDevelop 4.2.0.8749-Beta 2
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSTest.SharpDevelop", "MSTest.SharpDevelop\MSTest.SharpDevelop.csproj", "{8DF3A610-47F9-4448-B455-952BD57CB5CC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSTest.SharpDevelop.Tests", "MSTest.SharpDevelop.Tests\MSTest.SharpDevelop.Tests.csproj", "{51D56190-67B7-4A49-BA0A-24010460CCC6}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x86 = Debug|x86
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {8DF3A610-47F9-4448-B455-952BD57CB5CC}.Debug|x86.Build.0 = Debug|x86
+ {8DF3A610-47F9-4448-B455-952BD57CB5CC}.Debug|x86.ActiveCfg = Debug|x86
+ {8DF3A610-47F9-4448-B455-952BD57CB5CC}.Release|x86.Build.0 = Release|x86
+ {8DF3A610-47F9-4448-B455-952BD57CB5CC}.Release|x86.ActiveCfg = Release|x86
+ {51D56190-67B7-4A49-BA0A-24010460CCC6}.Debug|x86.Build.0 = Debug|x86
+ {51D56190-67B7-4A49-BA0A-24010460CCC6}.Debug|x86.ActiveCfg = Debug|x86
+ {51D56190-67B7-4A49-BA0A-24010460CCC6}.Release|x86.Build.0 = Release|x86
+ {51D56190-67B7-4A49-BA0A-24010460CCC6}.Release|x86.ActiveCfg = Release|x86
+ EndGlobalSection
+EndGlobal
diff --git a/samples/MSTest/MSTest.SharpDevelop/MSTest.SharpDevelop.csproj b/samples/MSTest/MSTest.SharpDevelop/MSTest.SharpDevelop.csproj
new file mode 100644
index 0000000000..05165c7eb6
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop/MSTest.SharpDevelop.csproj
@@ -0,0 +1,103 @@
+
+
+
+ {8DF3A610-47F9-4448-B455-952BD57CB5CC}
+ Debug
+ x86
+ Library
+ ICSharpCode.MSTest
+ MSTest.SharpDevelop
+ v4.0
+ Properties
+ ..\..\..\AddIns\Samples\MSTest
+ False
+ False
+ 4
+ false
+
+
+ x86
+ False
+ Auto
+ 4194304
+ 4096
+
+
+ true
+ Full
+ False
+ True
+ DEBUG;TRACE
+
+
+ False
+ None
+ True
+ False
+ TRACE
+
+
+
+ ..\..\..\bin\ICSharpCode.Core.dll
+ False
+
+
+ ..\..\..\bin\ICSharpCode.Core.Presentation.dll
+ False
+
+
+ ..\..\..\bin\ICSharpCode.SharpDevelop.dll
+ False
+
+
+ ..\..\..\bin\ICSharpCode.SharpDevelop.Dom.dll
+ False
+
+
+ ..\..\..\bin\ICSharpCode.SharpDevelop.Widgets.dll
+ False
+
+
+
+
+
+ 3.5
+
+
+ 4.0
+
+
+
+ ..\..\..\AddIns\Analysis\UnitTesting\UnitTesting.dll
+ False
+
+
+
+
+
+
+
+
+
+
+ MSTestOptionsPanel.xaml
+ Code
+
+
+
+
+
+
+
+
+
+
+
+ Always
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/MSTest/MSTest.SharpDevelop/MSTest.addin b/samples/MSTest/MSTest.SharpDevelop/MSTest.addin
new file mode 100644
index 0000000000..3049a6c8d0
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop/MSTest.addin
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/MSTest/MSTest.SharpDevelop/MSTestApplication.cs b/samples/MSTest/MSTest.SharpDevelop/MSTestApplication.cs
new file mode 100644
index 0000000000..62e3985228
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop/MSTestApplication.cs
@@ -0,0 +1,46 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Diagnostics;
+
+using ICSharpCode.UnitTesting;
+
+namespace ICSharpCode.MSTest
+{
+ public class MSTestApplication
+ {
+ SelectedTests selectedTests;
+ string resultsFileName;
+
+ public MSTestApplication(SelectedTests selectedTests, string resultsFileName)
+ {
+ this.selectedTests = selectedTests;
+ this.resultsFileName = resultsFileName;
+ GetProcessStartInfo();
+ }
+
+ void GetProcessStartInfo()
+ {
+ ProcessStartInfo = new ProcessStartInfo(MSTestOptions.MSTestPath, GetCommandLine());
+ }
+
+ string GetCommandLine()
+ {
+ var commandLine = new MSTestApplicationCommandLine();
+ commandLine.AppendQuoted("testcontainer", selectedTests.Project.OutputAssemblyFullPath);
+ commandLine.AppendQuoted("resultsfile", resultsFileName);
+ commandLine.Append("detail", "errorstacktrace");
+ if (selectedTests.NamespaceFilter != null) {
+ commandLine.Append("test", selectedTests.NamespaceFilter);
+ } else if (selectedTests.Member != null) {
+ commandLine.Append("test", selectedTests.Member.FullyQualifiedName);
+ } else if (selectedTests.Class != null) {
+ commandLine.Append("test", selectedTests.Class.FullyQualifiedName);
+ }
+ return commandLine.ToString();
+ }
+
+ public ProcessStartInfo ProcessStartInfo { get; private set; }
+ }
+}
diff --git a/samples/MSTest/MSTest.SharpDevelop/MSTestApplicationCommandLine.cs b/samples/MSTest/MSTest.SharpDevelop/MSTestApplicationCommandLine.cs
new file mode 100644
index 0000000000..669d88bba7
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop/MSTestApplicationCommandLine.cs
@@ -0,0 +1,37 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Text;
+
+namespace ICSharpCode.MSTest
+{
+ public class MSTestApplicationCommandLine
+ {
+ StringBuilder commandLine = new StringBuilder();
+
+ public MSTestApplicationCommandLine()
+ {
+ }
+
+ public void Append(string argument, string value)
+ {
+ AppendFormat("/{0}:{1} ", argument, value);
+ }
+
+ public void AppendQuoted(string argument, string value)
+ {
+ AppendFormat("/{0}:\"{1}\" ", argument, value);
+ }
+
+ void AppendFormat(string format, string argument, string value)
+ {
+ commandLine.AppendFormat(format, argument, value);
+ }
+
+ public override string ToString()
+ {
+ return commandLine.ToString();
+ }
+ }
+}
diff --git a/samples/MSTest/MSTest.SharpDevelop/MSTestDebugger.cs b/samples/MSTest/MSTest.SharpDevelop/MSTestDebugger.cs
new file mode 100644
index 0000000000..aa4ad68eee
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop/MSTestDebugger.cs
@@ -0,0 +1,134 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Diagnostics;
+using System.IO;
+
+using ICSharpCode.SharpDevelop.Debugging;
+using ICSharpCode.UnitTesting;
+
+namespace ICSharpCode.MSTest
+{
+ public class MSTestDebugger : TestRunnerBase
+ {
+ IUnitTestDebuggerService debuggerService;
+ IUnitTestMessageService messageService;
+ IDebugger debugger;
+ string resultsFileName;
+
+ public MSTestDebugger()
+ : this(
+ new UnitTestDebuggerService(),
+ new UnitTestMessageService())
+ {
+ }
+
+ public MSTestDebugger(
+ IUnitTestDebuggerService debuggerService,
+ IUnitTestMessageService messageService)
+ {
+ this.debuggerService = debuggerService;
+ this.messageService = messageService;
+ this.debugger = debuggerService.CurrentDebugger;
+ }
+
+ public override void Start(SelectedTests selectedTests)
+ {
+ ProcessStartInfo startInfo = GetProcessStartInfo(selectedTests);
+ if (IsDebuggerRunning) {
+ if (CanStopDebugging()) {
+ debugger.Stop();
+ Start(startInfo);
+ }
+ } else {
+ Start(startInfo);
+ }
+ }
+
+ protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests)
+ {
+ resultsFileName = new MSTestResultsFileName(selectedTests).FileName;
+ CreateDirectoryForResultsFile();
+ var mstestApplication = new MSTestApplication(selectedTests, resultsFileName);
+ return mstestApplication.ProcessStartInfo;
+ }
+
+ public bool IsDebuggerRunning {
+ get { return debuggerService.IsDebuggerLoaded && debugger.IsDebugging; }
+ }
+
+ bool CanStopDebugging()
+ {
+ string question = "${res:XML.MainMenu.RunMenu.Compile.StopDebuggingQuestion}";
+ string caption = "${res:XML.MainMenu.RunMenu.Compile.StopDebuggingTitle}";
+ return messageService.AskQuestion(question, caption);
+ }
+
+ void CreateDirectoryForResultsFile()
+ {
+ string path = Path.GetDirectoryName(resultsFileName);
+ if (!Directory.Exists(path)) {
+ Directory.CreateDirectory(path);
+ }
+ }
+
+ void Start(ProcessStartInfo startInfo)
+ {
+ StartDebugger(startInfo);
+ }
+
+ void StartDebugger(ProcessStartInfo startInfo)
+ {
+ LogCommandLine(startInfo);
+
+ bool running = false;
+ debugger.DebugStopped += DebugStopped;
+ try {
+ debugger.Start(startInfo);
+ running = true;
+ } finally {
+ if (!running) {
+ debugger.DebugStopped -= DebugStopped;
+ }
+ }
+ }
+
+ void DebugStopped(object source, EventArgs e)
+ {
+ debugger.DebugStopped -= DebugStopped;
+
+ if (File.Exists(resultsFileName)) {
+ var testResults = new MSTestResults(resultsFileName);
+ var workbench = new UnitTestWorkbench();
+ workbench.SafeThreadAsyncCall(() => UpdateTestResults(testResults));
+ } else {
+ messageService.ShowFormattedErrorMessage("Unable to find test results file: '{0}'.", resultsFileName);
+ OnAllTestsFinished(source, e);
+ }
+ }
+
+ void UpdateTestResults(MSTestResults testResults)
+ {
+ foreach (TestResult result in testResults) {
+ OnTestFinished(this, new TestFinishedEventArgs(result));
+ }
+ OnAllTestsFinished(this, new EventArgs());
+ }
+
+ public override void Stop()
+ {
+ if (debugger.IsDebugging) {
+ debugger.Stop();
+ }
+ }
+
+ public override void Dispose()
+ {
+ Stop();
+ try {
+ File.Delete(resultsFileName);
+ } catch { }
+ }
+ }
+}
diff --git a/samples/MSTest/MSTest.SharpDevelop/MSTestFramework.cs b/samples/MSTest/MSTest.SharpDevelop/MSTestFramework.cs
new file mode 100644
index 0000000000..50e7d4eb59
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop/MSTestFramework.cs
@@ -0,0 +1,109 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using ICSharpCode.SharpDevelop.Dom;
+using ICSharpCode.SharpDevelop.Project;
+using ICSharpCode.UnitTesting;
+
+namespace ICSharpCode.MSTest
+{
+ public class MSTestFramework : ITestFramework
+ {
+ public bool IsBuildNeededBeforeTestRun {
+ get { return true; }
+ }
+
+ public bool IsTestMember(IMember member)
+ {
+ var method = member as IMethod;
+ if (method == null)
+ return false;
+
+ return IsTestMethod(method);
+ }
+
+ bool IsTestMethod(IMethod method)
+ {
+ foreach (IAttribute attribute in method.Attributes) {
+ if (IsMSTestMethodAttribute(attribute)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ bool IsMSTestMethodAttribute(IAttribute attribute)
+ {
+ return IsMSTestMethodAttribute(attribute.AttributeType.FullyQualifiedName);
+ }
+
+ bool IsMSTestMethodAttribute(string name)
+ {
+ return
+ name == "TestMethod" ||
+ name == "TestMethodAttribute" ||
+ name == "Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute";
+ }
+
+ public bool IsTestClass(IClass c)
+ {
+ if ((c == null) || (c.IsAbstract))
+ return false;
+
+ foreach (IAttribute attribute in c.Attributes) {
+ if (IsMSTestClassAttribute(attribute)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ bool IsMSTestClassAttribute(IAttribute attribute)
+ {
+ return IsMSTestClassAttribute(attribute.AttributeType.FullyQualifiedName);
+ }
+
+ bool IsMSTestClassAttribute(string name)
+ {
+ return
+ name == "TestClass" ||
+ name == "TestClassAttribute" ||
+ name == "Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute";
+ }
+
+ public bool IsTestProject(IProject project)
+ {
+ if (project == null)
+ return false;
+
+ foreach (ProjectItem item in project.Items) {
+ if (item.IsMSTestAssemblyReference()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public IEnumerable GetTestMembersFor(IClass c)
+ {
+ return c.Methods
+ .Where(IsTestMethod)
+ .Select(method => new TestMember(method));
+ }
+
+ public ITestRunner CreateTestRunner()
+ {
+ return new MSTestRunner();
+ }
+
+ public ITestRunner CreateTestDebugger()
+ {
+ return new MSTestDebugger();
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/MSTest/MSTest.SharpDevelop/MSTestOptions.cs b/samples/MSTest/MSTest.SharpDevelop/MSTestOptions.cs
new file mode 100644
index 0000000000..f60a73467b
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop/MSTestOptions.cs
@@ -0,0 +1,26 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.IO;
+using ICSharpCode.Core;
+
+namespace ICSharpCode.MSTest
+{
+ public static class MSTestOptions
+ {
+ static Properties properties = PropertyService.Get("MSTestOptions", new Properties());
+
+ public static string MSTestPath {
+ get { return properties.Get("MSTestPath", GetDefaultMSTestPath()); }
+ set { properties.Set("MSTestPath", value); }
+ }
+
+ static string GetDefaultMSTestPath()
+ {
+ return Path.Combine(
+ Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
+ @"Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe");
+ }
+ }
+}
diff --git a/samples/MSTest/MSTest.SharpDevelop/MSTestOptionsPanel.xaml b/samples/MSTest/MSTest.SharpDevelop/MSTestOptionsPanel.xaml
new file mode 100644
index 0000000000..57da7506a1
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop/MSTestOptionsPanel.xaml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/MSTest/MSTest.SharpDevelop/MSTestOptionsPanel.xaml.cs b/samples/MSTest/MSTest.SharpDevelop/MSTestOptionsPanel.xaml.cs
new file mode 100644
index 0000000000..e4fca61cf0
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop/MSTestOptionsPanel.xaml.cs
@@ -0,0 +1,64 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.ComponentModel;
+using System.Windows.Controls;
+using System.Windows.Input;
+
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.SharpDevelop.Widgets;
+using Microsoft.Win32;
+
+namespace ICSharpCode.MSTest
+{
+ public partial class MSTestOptionsPanel : OptionPanel, INotifyPropertyChanged
+ {
+ string msTestPath;
+ bool changed;
+
+ public MSTestOptionsPanel()
+ {
+ InitializeComponent();
+ BrowseCommand = new RelayCommand(Browse);
+ msTestPath = MSTestOptions.MSTestPath;
+ DataContext = this;
+ }
+
+ public ICommand BrowseCommand { get; private set; }
+
+ void Browse()
+ {
+ var dialog = new OpenFileDialog();
+ if (dialog.ShowDialog() ?? false) {
+ MSTestPath = dialog.FileName;
+ }
+ }
+
+ public string MSTestPath {
+ get { return msTestPath; }
+ set {
+ msTestPath = value;
+ changed = true;
+ OnPropertyChanged("MSTestPath");
+ }
+ }
+
+ public override bool SaveOptions()
+ {
+ if (changed) {
+ MSTestOptions.MSTestPath = msTestPath;
+ }
+ return true;
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ void OnPropertyChanged(string name)
+ {
+ if (PropertyChanged != null) {
+ PropertyChanged(this, new PropertyChangedEventArgs(name));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/MSTest/MSTest.SharpDevelop/MSTestQualifiedClassName.cs b/samples/MSTest/MSTest.SharpDevelop/MSTestQualifiedClassName.cs
new file mode 100644
index 0000000000..5fa3fdc4ee
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop/MSTestQualifiedClassName.cs
@@ -0,0 +1,31 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+
+namespace ICSharpCode.MSTest
+{
+ public class MSTestQualifiedClassName
+ {
+ public MSTestQualifiedClassName(string qualifiedClassName)
+ {
+ ClassName = GetClassName(qualifiedClassName);
+ }
+
+ string GetClassName(string qualifiedClassName)
+ {
+ int index = qualifiedClassName.IndexOf(',');
+ if (index > 0) {
+ return qualifiedClassName.Substring(0, index);
+ }
+ return qualifiedClassName;
+ }
+
+ public string ClassName { get; private set; }
+
+ public string GetQualifiedMethodName(string methodName)
+ {
+ return String.Format("{0}.{1}", ClassName, methodName);
+ }
+ }
+}
diff --git a/samples/MSTest/MSTest.SharpDevelop/MSTestResult.cs b/samples/MSTest/MSTest.SharpDevelop/MSTestResult.cs
new file mode 100644
index 0000000000..51674abe68
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop/MSTestResult.cs
@@ -0,0 +1,93 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.IO;
+using ICSharpCode.SharpDevelop.Dom;
+using ICSharpCode.SharpDevelop.Gui;
+using ICSharpCode.UnitTesting;
+
+namespace ICSharpCode.MSTest
+{
+ public class MSTestResult
+ {
+ public MSTestResult(string id)
+ {
+ this.Id = id;
+ }
+
+ public string Id { get; private set; }
+ public string Name { get; private set; }
+ public TestResultType ResultType { get; private set; }
+ public string StackTrace { get; set; }
+ public string Message { get; set; }
+
+ public void UpdateTestName(string qualifiedClassName, string methodName)
+ {
+ UpdateTestName(new MSTestQualifiedClassName(qualifiedClassName), methodName);
+ }
+
+ public void UpdateTestName(MSTestQualifiedClassName qualifiedClassName, string methodName)
+ {
+ this.Name = qualifiedClassName.GetQualifiedMethodName(methodName);
+ }
+
+ public void UpdateResult(string result)
+ {
+ if (result == "Passed") {
+ this.ResultType = TestResultType.Success;
+ } else if (result == "Failed") {
+ this.ResultType = TestResultType.Failure;
+ }
+ }
+
+ public bool IsError {
+ get { return ResultType == TestResultType.Failure; }
+ }
+
+ public TestResult ToTestResult()
+ {
+ return new TestResult(Name) {
+ ResultType = ResultType,
+ Message = GetMessage(),
+ StackTrace = StackTrace,
+ StackTraceFilePosition = GetStackTraceFilePosition()
+ };
+ }
+
+ string GetMessage()
+ {
+ if (String.IsNullOrEmpty(Message))
+ return String.Empty;
+
+ int index = Message.IndexOf('\n');
+ if (index > 0) {
+ return Message.Substring(index + 1);
+ }
+ return Message;
+ }
+
+ FilePosition GetStackTraceFilePosition()
+ {
+ if (!String.IsNullOrEmpty(StackTrace)) {
+ return ParseFilePositionFromStackTrace();
+ }
+ return FilePosition.Empty;
+ }
+
+ FilePosition ParseFilePositionFromStackTrace()
+ {
+ FileLineReference fileLineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(StackTrace, true);
+ if (fileLineRef != null) {
+ return CreateFilePosition(fileLineRef);
+ }
+ return FilePosition.Empty;
+ }
+
+ FilePosition CreateFilePosition(FileLineReference fileLineRef)
+ {
+ string fileName = Path.GetFullPath(fileLineRef.FileName);
+ return new FilePosition(fileName, fileLineRef.Line, fileLineRef.Column + 1);
+ }
+ }
+}
diff --git a/samples/MSTest/MSTest.SharpDevelop/MSTestResults.cs b/samples/MSTest/MSTest.SharpDevelop/MSTestResults.cs
new file mode 100644
index 0000000000..c02fff240d
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop/MSTestResults.cs
@@ -0,0 +1,91 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using System.Xml;
+
+using ICSharpCode.UnitTesting;
+
+namespace ICSharpCode.MSTest
+{
+ public class MSTestResults : List
+ {
+ Dictionary testDefinitions = new Dictionary();
+
+ public MSTestResults(string fileName)
+ : this(new XmlTextReader(fileName))
+ {
+ }
+
+ public MSTestResults(XmlTextReader reader)
+ {
+ ReadResults(reader);
+ }
+
+ void ReadResults(XmlTextReader reader)
+ {
+ while (reader.Read()) {
+ switch (reader.NodeType) {
+ case XmlNodeType.Element:
+ if (reader.Name == "UnitTest") {
+ ReadUnitTest(reader);
+ } else if (reader.Name == "UnitTestResult") {
+ ReadUnitTestResult(reader);
+ }
+ break;
+ }
+ }
+ }
+
+ void ReadUnitTest(XmlTextReader reader)
+ {
+ var testResult = new MSTestResult(reader.GetAttribute("id"));
+ testDefinitions.Add(testResult.Id, testResult);
+
+ if (reader.ReadToDescendant("TestMethod")) {
+ testResult.UpdateTestName(reader.GetAttribute("className"), reader.GetAttribute("name"));
+ }
+ }
+
+ void ReadUnitTestResult(XmlTextReader reader)
+ {
+ string testId = reader.GetAttribute("testId");
+ MSTestResult testResult = FindTestResult(testId);
+ if (testResult != null) {
+ testResult.UpdateResult(reader.GetAttribute("outcome"));
+ if (testResult.IsError) {
+ ReadErrorInformation(testResult, reader);
+ }
+ Add(testResult.ToTestResult());
+ }
+ }
+
+ void ReadErrorInformation(MSTestResult testResult, XmlTextReader reader)
+ {
+ while (reader.Read()) {
+ switch (reader.NodeType) {
+ case XmlNodeType.EndElement:
+ if (reader.Name == "UnitTestResult") {
+ return;
+ }
+ break;
+ case XmlNodeType.Element:
+ if (reader.Name == "Message") {
+ testResult.Message = reader.ReadElementContentAsString();
+ } else if (reader.Name == "StackTrace") {
+ testResult.StackTrace = reader.ReadElementContentAsString();
+ }
+ break;
+ }
+ }
+ }
+
+ MSTestResult FindTestResult(string testId)
+ {
+ MSTestResult testResult = null;
+ testDefinitions.TryGetValue(testId, out testResult);
+ return testResult;
+ }
+ }
+}
diff --git a/samples/MSTest/MSTest.SharpDevelop/MSTestResultsFileName.cs b/samples/MSTest/MSTest.SharpDevelop/MSTestResultsFileName.cs
new file mode 100644
index 0000000000..51c1fdd1a3
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop/MSTestResultsFileName.cs
@@ -0,0 +1,27 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.IO;
+using ICSharpCode.UnitTesting;
+
+namespace ICSharpCode.MSTest
+{
+ public class MSTestResultsFileName
+ {
+ public MSTestResultsFileName(SelectedTests selectedTests)
+ {
+ FileName = GetFileName(selectedTests);
+ }
+
+ public string FileName { get; private set; }
+
+ string GetFileName(SelectedTests selectedTests)
+ {
+ return Path.Combine(
+ Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
+ "Temp",
+ selectedTests.Project.Name + "-Results.trx");
+ }
+ }
+}
diff --git a/samples/MSTest/MSTest.SharpDevelop/MSTestRunner.cs b/samples/MSTest/MSTest.SharpDevelop/MSTestRunner.cs
new file mode 100644
index 0000000000..a5fb6be9be
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop/MSTestRunner.cs
@@ -0,0 +1,138 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Diagnostics;
+using System.IO;
+
+using ICSharpCode.SharpDevelop.Util;
+using ICSharpCode.UnitTesting;
+
+namespace ICSharpCode.MSTest
+{
+ public class MSTestRunner : TestRunnerBase
+ {
+ IUnitTestProcessRunner processRunner;
+ IFileSystem fileSystem;
+ IUnitTestMessageService messageService;
+ string resultsFileName;
+
+ public MSTestRunner()
+ : this(new UnitTestProcessRunner(),
+ new UnitTestFileService(),
+ new UnitTestMessageService())
+ {
+ }
+
+ public MSTestRunner(
+ IUnitTestProcessRunner processRunner,
+ IFileSystem fileSystem,
+ IUnitTestMessageService messageService)
+ {
+ this.processRunner = processRunner;
+ this.fileSystem = fileSystem;
+ this.messageService = messageService;
+
+ processRunner.LogStandardOutputAndError = false;
+ processRunner.OutputLineReceived += OutputLineReceived;
+ processRunner.ErrorLineReceived += OutputLineReceived;
+ processRunner.ProcessExited += ProcessRunnerExited;
+ }
+
+ void ProcessRunnerExited(object source, EventArgs e)
+ {
+ // Read all tests.
+ if (FileExists(resultsFileName)) {
+ var testResults = new MSTestResults(resultsFileName);
+ var workbench = new UnitTestWorkbench();
+ workbench.SafeThreadAsyncCall(() => UpdateTestResults(testResults));
+ } else {
+ messageService.ShowFormattedErrorMessage("Unable to find test results file: '{0}'.", resultsFileName);
+ OnAllTestsFinished(source, e);
+ }
+ }
+
+ void UpdateTestResults(MSTestResults testResults)
+ {
+ foreach (TestResult result in testResults) {
+ OnTestFinished(this, new TestFinishedEventArgs(result));
+ }
+ OnAllTestsFinished(this, new EventArgs());
+ }
+
+ void OutputLineReceived(object source, LineReceivedEventArgs e)
+ {
+ OnMessageReceived(e.Line);
+ }
+
+ public override void Start(SelectedTests selectedTests)
+ {
+ ProcessStartInfo startInfo = GetProcessStartInfo(selectedTests);
+ TryDeleteResultsFile();
+ Start(startInfo);
+ }
+
+ protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests)
+ {
+ resultsFileName = new MSTestResultsFileName(selectedTests).FileName;
+ CreateDirectoryForResultsFile();
+ var mstestApplication = new MSTestApplication(selectedTests, resultsFileName);
+ return mstestApplication.ProcessStartInfo;
+ }
+
+ void Start(ProcessStartInfo processStartInfo)
+ {
+ LogCommandLine(processStartInfo);
+
+ if (FileExists(processStartInfo.FileName)) {
+ processRunner.WorkingDirectory = processStartInfo.WorkingDirectory;
+ processRunner.Start(processStartInfo.FileName, processStartInfo.Arguments);
+ } else {
+ ShowApplicationDoesNotExistMessage(processStartInfo.FileName);
+ }
+ }
+
+ void CreateDirectoryForResultsFile()
+ {
+ string path = Path.GetDirectoryName(resultsFileName);
+ if (!Directory.Exists(path)) {
+ Directory.CreateDirectory(path);
+ }
+ }
+
+ bool FileExists(string fileName)
+ {
+ return fileSystem.FileExists(fileName);
+ }
+
+ void ShowApplicationDoesNotExistMessage(string fileName)
+ {
+ string resourceString = "${res:ICSharpCode.UnitTesting.TestRunnerNotFoundMessageFormat}";
+ messageService.ShowFormattedErrorMessage(resourceString, fileName);
+ }
+
+ public override void Stop()
+ {
+ processRunner.Kill();
+ }
+
+ public override void Dispose()
+ {
+ processRunner.ErrorLineReceived -= OutputLineReceived;
+ processRunner.OutputLineReceived -= OutputLineReceived;
+ processRunner.ProcessExited -= ProcessRunnerExited;
+
+ TryDeleteResultsFile();
+ }
+
+ void TryDeleteResultsFile()
+ {
+ try {
+ Console.WriteLine("Deleting results file: " + resultsFileName);
+ File.Delete(resultsFileName);
+ } catch (Exception ex) {
+ Console.WriteLine(ex.Message);
+ }
+ }
+ }
+}
diff --git a/samples/MSTest/MSTest.SharpDevelop/ProjectItemExtensions.cs b/samples/MSTest/MSTest.SharpDevelop/ProjectItemExtensions.cs
new file mode 100644
index 0000000000..c88914e902
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop/ProjectItemExtensions.cs
@@ -0,0 +1,28 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using ICSharpCode.SharpDevelop.Project;
+
+namespace ICSharpCode.MSTest
+{
+ public static class ProjectItemExtensions
+ {
+ public static bool IsMSTestAssemblyReference(this ProjectItem item)
+ {
+ var referenceItem = item as ReferenceProjectItem;
+ if (referenceItem == null)
+ return false;
+
+ return IsMSTestAssemblyReference(referenceItem);
+ }
+
+ public static bool IsMSTestAssemblyReference(this ReferenceProjectItem item)
+ {
+ return String.Equals(
+ item.ShortName,
+ "Microsoft.VisualStudio.QualityTools.UnitTestFramework",
+ StringComparison.OrdinalIgnoreCase);
+ }
+ }
+}
diff --git a/samples/MSTest/MSTest.SharpDevelop/Properties/AssemblyInfo.cs b/samples/MSTest/MSTest.SharpDevelop/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..8ab66e9a48
--- /dev/null
+++ b/samples/MSTest/MSTest.SharpDevelop/Properties/AssemblyInfo.cs
@@ -0,0 +1,31 @@
+#region Using directives
+
+using System;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+#endregion
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("MSTest.SharpDevelop")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("MSTest.SharpDevelop")]
+[assembly: AssemblyCopyright("Copyright 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// This sets the default COM visibility of types in the assembly to invisible.
+// If you need to expose a type to COM, use [ComVisible(true)] on that type.
+[assembly: ComVisible(false)]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all the values or you can use the default the Revision and
+// Build Numbers by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0")]
diff --git a/src/AddIns/BackendBindings/AspNet.Mvc/Project/AspNet.Mvc.csproj b/src/AddIns/BackendBindings/AspNet.Mvc/Project/AspNet.Mvc.csproj
index 5fdddc6f26..34524f74cd 100644
--- a/src/AddIns/BackendBindings/AspNet.Mvc/Project/AspNet.Mvc.csproj
+++ b/src/AddIns/BackendBindings/AspNet.Mvc/Project/AspNet.Mvc.csproj
@@ -231,7 +231,6 @@
-
diff --git a/src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/ViewInBrowser.cs b/src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/ViewInBrowser.cs
deleted file mode 100644
index 4a89a3e636..0000000000
--- a/src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/ViewInBrowser.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
-//// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
-//
-//using System;
-//using System.IO;
-//using System.Linq;
-//
-//using ICSharpCode.Core;
-//using ICSharpCode.SharpDevelop.Gui.OptionPanels;
-//using ICSharpCode.SharpDevelop.Project;
-//using ICSharpCode.SharpDevelop.Project.Commands;
-//
-//namespace ICSharpCode.AspNet.Mvc
-//{
-// public class ViewInBrowser : AbstractMenuCommand
-// {
-// public override void Run()
-// {
-// var node = ProjectBrowserPad.Instance.SelectedNode as FileNode;
-// if (node == null) {
-// return;
-// }
-//
-// var project = ProjectService.CurrentProject as CompilableProject;
-// if (project == null) {
-// return;
-// }
-//
-// if (!project.IsWebProject) {
-// MessageService.ShowError("${res:ProjectComponent.ContextMenu.NotAWebProject}");
-// return;
-// }
-//
-// if (!WebProjectService.IsIISOrIISExpressInstalled) {
-// MessageService.ShowError("${res:ICSharpCode.WebProjectOptionsPanel.IISNotFound}");
-// return;
-// }
-//
-// string fileName = node.FileName;
-//
-//// // set project options
-//// project.StartAction = StartAction.StartURL;
-//// string directoryName = Path.GetDirectoryName(project.FileName) + "\\";
-//// project.StartUrl = fileName.Replace(directoryName, "/").Replace("\\", "/");
-//
-// // set web server options
-// string projectName = project.Name;
-// WebProjectOptions existingOptions = WebProjectsOptions.Instance.GetWebProjectOptions(projectName);
-//
-// var options = new WebProjectOptions {
-// Data = new WebProjectDebugData {
-// WebServer = WebProjectService.IsIISExpressInstalled ? WebServer.IISExpress : WebServer.IIS,
-// Port = (existingOptions != null && existingOptions.Data != null) ? existingOptions.Data.Port : "8080", //TODO: port collision detection
-// ProjectUrl = string.Format("{0}/{1}", WebBehavior.LocalHost, project.Name)
-// },
-// ProjectName = projectName
-// };
-//
-// if (options.Data.WebServer == WebServer.IISExpress) {
-// options.Data.ProjectUrl = string.Format(
-// @"{0}:{1}/{2}", WebBehavior.LocalHost, options.Data.Port, projectName);
-// }
-//
-// WebProjectsOptions.Instance.SetWebProjectOptions(projectName, options);
-//
-// // create virtual directory
-// string error = WebProjectService.CreateVirtualDirectory(
-// options.Data.WebServer,
-// projectName,
-// Path.GetDirectoryName(ProjectService.CurrentProject.FileName));
-// LoggingService.Info(error ?? string.Empty);
-//
-// // RunProject
-// new RunProject().Run();
-// }
-// }
-//}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonResolverContext.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonResolverContext.cs
index c98cdfe6f3..c8f6129d3e 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonResolverContext.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonResolverContext.cs
@@ -4,6 +4,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
+
+using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.PythonBinding
@@ -118,7 +120,7 @@ namespace ICSharpCode.PythonBinding
public bool PartialNamespaceExistsInProjectReferences(string name)
{
- foreach (IProjectContent referencedContent in projectContent.ReferencedContents) {
+ foreach (IProjectContent referencedContent in projectContent.ThreadSafeGetReferencedContents()) {
if (PartialNamespaceExists(referencedContent, name)) {
return true;
}
diff --git a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/OptionPanels/ProjectImports.cs b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/OptionPanels/ProjectImports.cs
index f189be0d58..766ef099d3 100644
--- a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/OptionPanels/ProjectImports.cs
+++ b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/OptionPanels/ProjectImports.cs
@@ -35,7 +35,7 @@ namespace ICSharpCode.VBNetBinding.OptionPanels
}
IProjectContent projectContent = ParserService.GetProjectContent(project);
- foreach(IProjectContent refProjectContent in projectContent.ReferencedContents) {
+ foreach(IProjectContent refProjectContent in projectContent.ThreadSafeGetReferencedContents()) {
AddNamespaces(refProjectContent);
}
diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs
new file mode 100644
index 0000000000..6ab91827e8
--- /dev/null
+++ b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs
@@ -0,0 +1,1389 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.Linq;
+using System.Windows.Media;
+
+using ICSharpCode.AvalonEdit.Xml;
+using ICSharpCode.SharpDevelop;
+using ICSharpCode.SharpDevelop.Dom;
+using ICSharpCode.SharpDevelop.Editor;
+using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
+using ICSharpCode.SharpDevelop.Project;
+
+namespace ICSharpCode.XamlBinding
+{
+ public static class CompletionDataHelper
+ {
+ static readonly List standardElements = new List {
+ new SpecialCompletionItem("!--"),
+ new SpecialCompletionItem("![CDATA["),
+ new SpecialCompletionItem("?")
+ };
+
+ // [XAML 2009]
+ static readonly List xamlBuiltInTypes = new List {
+ "Object", "Boolean", "Char", "String", "Decimal", "Single", "Double",
+ "Int16", "Int32", "Int64", "TimeSpan", "Uri", "Byte", "Array", "List", "Dictionary",
+ // This is no built in type, but a markup extension
+ "Reference"
+ };
+
+ static readonly List standardAttributes = new List {
+ new SpecialCompletionItem("xmlns:"),
+ new XamlCompletionItem("xml", "", "space"),
+ new XamlCompletionItem("xml", "", "lang")
+ };
+
+ public static readonly ReadOnlyCollection XamlNamespaceAttributes = new List {
+ "Class", "ClassModifier", "FieldModifier", "Name", "Subclass", "TypeArguments", "Uid", "Key"
+ }.AsReadOnly();
+
+ public static readonly ReadOnlyCollection RootOnlyElements = new List {
+ "Class", "ClassModifier", "Subclass"
+ }.AsReadOnly();
+
+ public static readonly ReadOnlyCollection ChildOnlyElements = new List {
+ "FieldModifier"
+ }.AsReadOnly();
+
+ static readonly List emptyList = new List();
+
+ ///
+ /// value: http://schemas.microsoft.com/winfx/2006/xaml
+ ///
+ public const string XamlNamespace = "http://schemas.microsoft.com/winfx/2006/xaml";
+
+ ///
+ /// values: http://schemas.microsoft.com/winfx/2006/xaml/presentation,
+ /// http://schemas.microsoft.com/netfx/2007/xaml/presentation
+ ///
+ public static readonly string[] WpfXamlNamespaces = new[] {
+ "http://schemas.microsoft.com/winfx/2006/xaml/presentation",
+ "http://schemas.microsoft.com/netfx/2007/xaml/presentation"
+ };
+
+ ///
+ /// value: http://schemas.openxmlformats.org/markup-compatibility/2006
+ ///
+ public const string MarkupCompatibilityNamespace = "http://schemas.openxmlformats.org/markup-compatibility/2006";
+
+ public const bool EnableXaml2009 = true;
+
+ public static XamlContext ResolveContext(string text, string fileName, int offset)
+ {
+ return ResolveContext(new StringTextBuffer(text), fileName, offset);
+ }
+
+ public static XamlContext ResolveContext(ITextBuffer fileContent, string fileName, int offset)
+ {
+ //using (new DebugTimerObject("ResolveContext")) {
+ XamlParser parser = string.IsNullOrEmpty(fileName) ? new XamlParser() : ParserService.GetParser(fileName) as XamlParser;
+ ParseInformation info = string.IsNullOrEmpty(fileName) ? null : ParserService.GetParseInformation(fileName);
+
+ using (parser.ParseAndLock(fileContent)) {
+
+ AXmlDocument document = parser.LastDocument;
+ AXmlObject currentData = document.GetChildAtOffset(offset);
+
+ string attribute = string.Empty, attributeValue = string.Empty;
+ bool inAttributeValue = false;
+ AttributeValue value = null;
+ bool isRoot = false;
+ bool wasAXmlElement = false;
+ int offsetFromValueStart = -1;
+
+ List ancestors = new List();
+ Dictionary xmlns = new Dictionary();
+ List ignored = new List();
+ string xamlNamespacePrefix = string.Empty;
+
+ var item = currentData;
+
+ while (item != document) {
+ if (item is AXmlElement) {
+ AXmlElement element = item as AXmlElement;
+ ancestors.Add(element);
+ foreach (var attr in element.Attributes) {
+ if (attr.IsNamespaceDeclaration) {
+ string prefix = (attr.Name == "xmlns") ? "" : attr.LocalName;
+ if (!xmlns.ContainsKey(prefix))
+ xmlns.Add(prefix, attr.Value);
+ }
+
+ if (attr.LocalName == "Ignorable" && attr.Namespace == MarkupCompatibilityNamespace)
+ ignored.AddRange(attr.Value.Split(' ', '\t'));
+
+ if (string.IsNullOrEmpty(xamlNamespacePrefix) && attr.Value == XamlNamespace)
+ xamlNamespacePrefix = attr.LocalName;
+ }
+
+ if (!wasAXmlElement && item.Parent is AXmlDocument)
+ isRoot = true;
+
+ wasAXmlElement = true;
+ }
+
+ item = item.Parent;
+ }
+
+ XamlContextDescription description = XamlContextDescription.None;
+
+ AXmlElement active = null;
+ AXmlElement parent = null;
+
+ if (currentData.Parent is AXmlTag) {
+ AXmlTag tag = currentData.Parent as AXmlTag;
+ if (tag.IsStartOrEmptyTag)
+ description = XamlContextDescription.InTag;
+ else if (tag.IsComment)
+ description = XamlContextDescription.InComment;
+ else if (tag.IsCData)
+ description = XamlContextDescription.InCData;
+ active = tag.Parent as AXmlElement;
+ }
+
+ if (currentData is AXmlAttribute) {
+ AXmlAttribute a = currentData as AXmlAttribute;
+ int valueStartOffset = a.StartOffset + (a.Name ?? "").Length + (a.EqualsSign ?? "").Length + 1;
+ attribute = a.Name;
+ attributeValue = a.Value;
+ value = MarkupExtensionParser.ParseValue(attributeValue);
+
+ inAttributeValue = offset >= valueStartOffset && offset < a.EndOffset;
+ if (inAttributeValue) {
+ offsetFromValueStart = offset - valueStartOffset;
+
+ description = XamlContextDescription.InAttributeValue;
+
+ if (value != null && !value.IsString)
+ description = XamlContextDescription.InMarkupExtension;
+ if (attributeValue.StartsWith("{}", StringComparison.Ordinal) && attributeValue.Length > 2)
+ description = XamlContextDescription.InAttributeValue;
+ } else
+ description = XamlContextDescription.InTag;
+ }
+
+ if (currentData is AXmlTag) {
+ AXmlTag tag = currentData as AXmlTag;
+ if (tag.IsStartOrEmptyTag || tag.IsEndTag)
+ description = XamlContextDescription.AtTag;
+ else if (tag.IsComment)
+ description = XamlContextDescription.InComment;
+ else if (tag.IsCData)
+ description = XamlContextDescription.InCData;
+ active = tag.Parent as AXmlElement;
+ }
+
+ if (active != ancestors.FirstOrDefault())
+ parent = ancestors.FirstOrDefault();
+ else
+ parent = ancestors.Skip(1).FirstOrDefault();
+
+ if (active == null)
+ active = parent;
+
+ var xAttribute = currentData as AXmlAttribute;
+
+ var context = new XamlContext() {
+ Description = description,
+ ActiveElement = (active == null) ? null : active.ToWrapper(),
+ ParentElement = (parent == null) ? null : parent.ToWrapper(),
+ Ancestors = ancestors.Select(ancestor => ancestor.ToWrapper()).ToList(),
+ Attribute = (xAttribute != null) ? xAttribute.ToWrapper() : null,
+ InRoot = isRoot,
+ AttributeValue = value,
+ RawAttributeValue = attributeValue,
+ ValueStartOffset = offsetFromValueStart,
+ XmlnsDefinitions = xmlns,
+ ParseInformation = info,
+ IgnoredXmlns = ignored.AsReadOnly(),
+ XamlNamespacePrefix = xamlNamespacePrefix
+ };
+
+ return context;
+ }
+ //}
+ }
+
+ public static XamlCompletionContext ResolveCompletionContext(ITextEditor editor, char typedValue)
+ {
+ var binding = editor.GetService(typeof(XamlLanguageBinding)) as XamlLanguageBinding;
+
+ if (binding == null)
+ throw new InvalidOperationException("Can only use ResolveCompletionContext with a XamlLanguageBinding.");
+
+ var context = new XamlCompletionContext(ResolveContext(editor.Document.CreateSnapshot(), editor.FileName, editor.Caret.Offset)) {
+ PressedKey = typedValue,
+ Editor = editor
+ };
+
+ return context;
+ }
+
+ public static XamlCompletionContext ResolveCompletionContext(ITextEditor editor, char typedValue, int offset)
+ {
+ var binding = editor.GetService(typeof(XamlLanguageBinding)) as XamlLanguageBinding;
+
+ if (binding == null)
+ throw new InvalidOperationException("Can only use ResolveCompletionContext with a XamlLanguageBinding.");
+
+ var context = new XamlCompletionContext(ResolveContext(editor.Document.CreateSnapshot(), editor.FileName, offset)) {
+ PressedKey = typedValue,
+ Editor = editor
+ };
+
+ return context;
+ }
+
+ static List CreateAttributeList(XamlCompletionContext context, bool includeEvents)
+ {
+ ElementWrapper lastElement = context.ActiveElement;
+ if (context.ParseInformation == null)
+ return emptyList;
+ XamlCompilationUnit cu = context.ParseInformation.CompilationUnit as XamlCompilationUnit;
+ if (cu == null)
+ return emptyList;
+ IReturnType rt = cu.CreateType(lastElement.Namespace, lastElement.LocalName.Trim('.'));
+
+ var list = new List();
+
+ string xamlPrefix = context.XamlNamespacePrefix;
+ string xKey = string.IsNullOrEmpty(xamlPrefix) ? "" : xamlPrefix + ":";
+
+ if (xamlBuiltInTypes.Concat(XamlNamespaceAttributes).Select(s => xKey + s).Contains(lastElement.Name))
+ return emptyList;
+
+ if (lastElement.LocalName.EndsWith(".", StringComparison.OrdinalIgnoreCase) || context.PressedKey == '.') {
+ if (rt == null)
+ return list;
+
+ string key = string.IsNullOrEmpty(lastElement.Prefix) ? "" : lastElement.Prefix + ":";
+
+ if (context.ParentElement != null && context.ParentElement.LocalName.StartsWith(lastElement.LocalName.TrimEnd('.'), StringComparison.OrdinalIgnoreCase)) {
+ AddAttributes(rt, list, includeEvents);
+ AddAttachedProperties(rt.GetUnderlyingClass(), list, key, lastElement.Name.Trim('.'));
+ } else
+ AddAttachedProperties(rt.GetUnderlyingClass(), list, key, lastElement.Name.Trim('.'));
+ } else {
+ if (rt == null) {
+ list.Add(new XamlCompletionItem(xamlPrefix, XamlNamespace, "Uid"));
+ } else {
+ AddAttributes(rt, list, includeEvents);
+ list.AddRange(GetListOfAttached(context, string.Empty, string.Empty, includeEvents, true));
+ foreach (string item in XamlNamespaceAttributes.Where(item => AllowedInElement(context.InRoot, item)))
+ list.Add(new XamlCompletionItem(xamlPrefix, XamlNamespace, item));
+ }
+ }
+
+ return list;
+ }
+
+ static void AddAttributes(IReturnType rt, IList list, bool includeEvents)
+ {
+ if (rt == null)
+ return;
+
+ foreach (IProperty p in rt.GetProperties()) {
+ if (p.IsPublic && (p.IsPubliclySetable() || p.ReturnType.IsCollectionReturnType()))
+ list.Add(new XamlCodeCompletionItem(p));
+ }
+
+ if (includeEvents) {
+ foreach (IEvent e in rt.GetEvents()) {
+ if (e.IsPublic) {
+ list.Add(new XamlCodeCompletionItem(e));
+ }
+ }
+ }
+ }
+
+ static bool AllowedInElement(bool inRoot, string item)
+ {
+ return inRoot ? !ChildOnlyElements.Contains(item) : !RootOnlyElements.Contains(item);
+ }
+
+ public static IEnumerable CreateListForXmlnsCompletion(IProjectContent projectContent)
+ {
+ List list = new List();
+
+ foreach (IProjectContent content in projectContent.ThreadSafeGetReferencedContents()) {
+ foreach (IAttribute att in content.GetAssemblyAttributes()) {
+ if (att.PositionalArguments.Count == 2
+ && att.AttributeType.FullyQualifiedName == "System.Windows.Markup.XmlnsDefinitionAttribute") {
+ list.Add(new XmlnsCompletionItem(att.PositionalArguments[0] as string, true));
+ }
+ }
+
+ foreach (string @namespace in content.NamespaceNames) {
+ if (!string.IsNullOrEmpty(@namespace))
+ list.Add(new XmlnsCompletionItem(@namespace, content.AssemblyName));
+ }
+ }
+
+ foreach (string @namespace in projectContent.NamespaceNames) {
+ if (!string.IsNullOrEmpty(@namespace))
+ list.Add(new XmlnsCompletionItem(@namespace, false));
+ }
+
+ list.Add(new XmlnsCompletionItem(MarkupCompatibilityNamespace, true));
+
+ return list
+ .Distinct(new XmlnsEqualityComparer())
+ .OrderBy(item => item, new XmlnsComparer());
+ }
+
+ static string GetContentPropertyName(IReturnType type)
+ {
+ if (type == null)
+ return string.Empty;
+
+ IClass c = type.GetUnderlyingClass();
+
+ if (c == null)
+ return string.Empty;
+
+ IAttribute contentProperty = c.Attributes
+ .FirstOrDefault(attribute => attribute.AttributeType.FullyQualifiedName == "System.Windows.Markup.ContentPropertyAttribute");
+ if (contentProperty != null) {
+ return contentProperty.PositionalArguments.FirstOrDefault() as string
+ ?? (contentProperty.NamedArguments.ContainsKey("Name") ? contentProperty.NamedArguments["Name"] as string : string.Empty);
+ }
+
+ return string.Empty;
+ }
+
+ public static IList CreateElementList(XamlCompletionContext context, bool classesOnly, bool includeAbstract)
+ {
+ var items = GetClassesFromContext(context);
+ var result = new List();
+ var last = context.ParentElement;
+
+ if (context.ParseInformation == null)
+ return emptyList;
+
+ XamlCompilationUnit cu = context.ParseInformation.CompilationUnit as XamlCompilationUnit;
+
+ IReturnType rt = null;
+
+ if (last != null && cu != null) {
+ if (!last.Name.Contains(".") || last.Name.EndsWith(".", StringComparison.OrdinalIgnoreCase)) {
+ rt = cu.CreateType(last.Namespace, last.LocalName.Trim('.'));
+ string contentPropertyName = GetContentPropertyName(rt);
+ if (!string.IsNullOrEmpty(contentPropertyName)) {
+ string fullName = last.Name + "." + contentPropertyName;
+ MemberResolveResult mrr = XamlResolver.Resolve(fullName, context) as MemberResolveResult;
+
+ if (mrr != null) {
+ rt = mrr.ResolvedType;
+ }
+ }
+ } else {
+ MemberResolveResult mrr = XamlResolver.Resolve(last.Name, context) as MemberResolveResult;
+
+ if (mrr != null) {
+ rt = mrr.ResolvedType;
+ }
+ }
+ }
+
+ bool isList = rt != null && rt.IsListReturnType();
+
+ bool parentAdded = false;
+
+ foreach (var ns in items) {
+ foreach (var c in ns.Value) {
+ if (includeAbstract) {
+ if (c.ClassType == ClassType.Class) {
+ if (c.IsStatic || c.DerivesFrom("System.Attribute"))
+ continue;
+ } else if (c.ClassType == ClassType.Interface) {
+ } else {
+ continue;
+ }
+ } else {
+ if (!(c.ClassType == ClassType.Class && c.IsAbstract == includeAbstract && !c.IsStatic &&
+ // TODO : use c.DefaultReturnType.GetConstructors(ctor => ctor.IsAccessible(context.ParseInformation.CompilationUnit.Classes.FirstOrDefault(), false)) after DOM rewrite
+ !c.DerivesFrom("System.Attribute") && (c.AddDefaultConstructorIfRequired || c.Methods.Any(m => m.IsConstructor && m.IsAccessible(context.ParseInformation.CompilationUnit.Classes.FirstOrDefault(), false)))))
+ continue;
+ }
+
+ if (last != null && isList) {
+ var possibleTypes = rt.GetMethods()
+ .Where(a => a.Parameters.Count == 1 && a.Name == "Add")
+ .Select(method => method.Parameters.First().ReturnType.GetUnderlyingClass()).Where(p => p != null);
+
+ if (!possibleTypes.Any(t => c.ClassInheritanceTreeClassesOnly.Any(c2 => c2.FullyQualifiedName == t.FullyQualifiedName)))
+ continue;
+ }
+
+ XamlCodeCompletionItem item = new XamlCodeCompletionItem(c, ns.Key);
+
+ parentAdded = parentAdded || (last != null && item.Text == last.Name);
+
+ result.Add(new XamlCodeCompletionItem(c, ns.Key));
+ }
+ }
+
+ if (!parentAdded && last != null && !last.Name.Contains(".")) {
+ IClass itemClass = cu.CreateType(last.Namespace, last.LocalName.Trim('.')).GetUnderlyingClass();
+ if (itemClass != null)
+ result.Add(new XamlCodeCompletionItem(itemClass, last.Prefix));
+ }
+
+ var xamlItems = XamlNamespaceAttributes.AsEnumerable();
+
+ if (EnableXaml2009)
+ xamlItems = xamlBuiltInTypes.Concat(XamlNamespaceAttributes);
+
+ foreach (string item in xamlItems)
+ result.Add(new XamlCompletionItem(context.XamlNamespacePrefix, XamlNamespace, item));
+
+ return result;
+ }
+
+ public static IEnumerable GetAllTypes(XamlCompletionContext context)
+ {
+ var items = GetClassesFromContext(context);
+
+ foreach (var ns in items) {
+ foreach (var c in ns.Value) {
+ if (c.ClassType == ClassType.Class && !c.DerivesFrom("System.Attribute"))
+ yield return new XamlCodeCompletionItem(c, ns.Key);
+ }
+ }
+ }
+
+ public static IEnumerable CreateListOfMarkupExtensions(XamlCompletionContext context)
+ {
+ var list = CreateElementList(context, true, false);
+
+ var neededItems = list.OfType()
+ .Where(i => (i.Entity as IClass).DerivesFrom("System.Windows.Markup.MarkupExtension"));
+ foreach (XamlCodeCompletionItem it in neededItems) {
+ string text = it.Text;
+ if (it.Text.EndsWith("Extension", StringComparison.Ordinal))
+ text = text.Remove(it.Text.Length - "Extension".Length);
+ it.Text = text;
+ }
+
+ return neededItems.Cast().Add(new XamlCompletionItem(context.XamlNamespacePrefix, XamlNamespace, "Reference"));
+ }
+
+ public static XamlCompletionItemList CreateListForContext(XamlCompletionContext context)
+ {
+ XamlCompletionItemList list = new XamlCompletionItemList(context);
+
+ ParseInformation info = context.ParseInformation;
+ ITextEditor editor = context.Editor;
+
+ switch (context.Description) {
+ case XamlContextDescription.None:
+ if (context.Forced) {
+ list.Items.AddRange(standardElements);
+ list.Items.AddRange(CreateElementList(context, false, false));
+ AddClosingTagCompletion(context, list);
+ }
+ break;
+ case XamlContextDescription.AtTag:
+ if ((editor.Caret.Offset > 0 && editor.Document.GetCharAt(editor.Caret.Offset - 1) == '.') || context.PressedKey == '.') {
+ list.Items.AddRange(CreateAttributeList(context, false));
+ } else {
+ list.Items.AddRange(standardElements);
+ list.Items.AddRange(CreateElementList(context, false, false));
+ AddClosingTagCompletion(context, list);
+ }
+ break;
+ case XamlContextDescription.InTag:
+ DebugTimer.Start();
+
+ string word = context.Editor.GetWordBeforeCaretExtended();
+
+ if (context.PressedKey == '.' || word.Contains(".")) {
+ string ns = "";
+ int pos = word.IndexOf(':');
+ if (pos > -1)
+ ns = word.Substring(0, pos);
+
+ string element = word.Substring(pos + 1, word.Length - pos - 1);
+ string className = word;
+ int propertyStart = element.IndexOf('.');
+ if (propertyStart != -1) {
+ element = element.Substring(0, propertyStart).TrimEnd('.');
+ className = className.Substring(0, propertyStart + pos + 1).TrimEnd('.');
+ }
+ TypeResolveResult trr = XamlResolver.Resolve(className, context) as TypeResolveResult;
+ IClass typeClass = (trr != null && trr.ResolvedType != null) ? trr.ResolvedType.GetUnderlyingClass() : null;
+
+ if (typeClass != null && typeClass.HasAttached(true, true))
+ list.Items.AddRange(GetListOfAttached(context, element, ns, true, true));
+ } else {
+ QualifiedNameWithLocation last = context.ActiveElement.ToQualifiedName();
+ TypeResolveResult trr = XamlResolver.Resolve(last.Name, context) as TypeResolveResult;
+ IClass typeClass = (trr != null && trr.ResolvedType != null) ? trr.ResolvedType.GetUnderlyingClass() : null;
+ list.Items.AddRange(CreateAttributeList(context, true));
+ list.Items.AddRange(standardAttributes);
+ }
+
+ DebugTimer.Stop("CreateListForContext - InTag");
+ break;
+ case XamlContextDescription.InAttributeValue:
+ new XamlCodeCompletionBinding().CtrlSpace(editor);
+ break;
+ }
+
+ list.SortItems();
+
+ return list;
+ }
+
+ static void AddClosingTagCompletion(XamlCompletionContext context, XamlCompletionItemList list)
+ {
+ if (context.ParentElement != null && !context.InRoot) {
+ ResolveResult rr = XamlResolver.Resolve(context.ParentElement.Name, context);
+ TypeResolveResult trr = rr as TypeResolveResult;
+ MemberResolveResult mrr = rr as MemberResolveResult;
+
+ if (trr != null) {
+ if (trr.ResolvedClass == null)
+ return;
+ list.Items.Add(new XamlCodeCompletionItem("/" + context.ParentElement.Name, trr.ResolvedClass));
+ } else if (mrr != null) {
+ if (mrr.ResolvedMember == null)
+ return;
+ list.Items.Add(new XamlCodeCompletionItem("/" + context.ParentElement.Name, mrr.ResolvedMember));
+ }
+ }
+ }
+
+ public static IEnumerable CreateMarkupExtensionInsight(XamlCompletionContext context)
+ {
+ var markup = Utils.GetMarkupExtensionAtPosition(context.AttributeValue.ExtensionValue, context.ValueStartOffset);
+ var type = ResolveType(markup.ExtensionType, context) ?? ResolveType(markup.ExtensionType + "Extension", context);
+
+ if (type != null) {
+ var ctors = type.GetMethods()
+ .Where(m => m.IsPublic && m.IsConstructor && m.Parameters.Count >= markup.PositionalArguments.Count)
+ .OrderBy(m => m.Parameters.Count);
+
+ foreach (var ctor in ctors)
+ yield return new MarkupExtensionInsightItem(ctor);
+ }
+ }
+
+ public static ICompletionItemList CreateMarkupExtensionCompletion(XamlCompletionContext context)
+ {
+ var list = new XamlCompletionItemList(context);
+ string visibleValue = context.RawAttributeValue.Substring(0, Utils.MinMax(context.ValueStartOffset, 0, context.RawAttributeValue.Length));
+ if (context.PressedKey == '=')
+ visibleValue += "=";
+// context.RawAttributeValue = visibleValue;
+// context.AttributeValue = MarkupExtensionParser.ParseValue(visibleValue);
+ var markup = Utils.GetMarkupExtensionAtPosition(context.AttributeValue.ExtensionValue, context.ValueStartOffset);
+ var type = ResolveType(markup.ExtensionType, context) ?? ResolveType(markup.ExtensionType + "Extension", context);
+
+ if (type == null) {
+ list.Items.AddRange(CreateListOfMarkupExtensions(context));
+ list.PreselectionLength = markup.ExtensionType.Length;
+ } else {
+ if (markup.NamedArguments.Count == 0) {
+ if (DoPositionalArgsCompletion(list, context, markup, type))
+ DoNamedArgsCompletion(list, context, type, markup);
+ } else
+ DoNamedArgsCompletion(list, context, type, markup);
+ }
+
+ list.SortItems();
+
+ return list;
+ }
+
+ static void DoNamedArgsCompletion(XamlCompletionItemList list, XamlCompletionContext context, IReturnType type, MarkupExtensionInfo markup)
+ {
+ if (markup.NamedArguments.Count > 0 && !context.Editor.GetWordBeforeCaret().StartsWith(",", StringComparison.OrdinalIgnoreCase)) {
+ int lastStart = markup.NamedArguments.Max(i => i.Value.StartOffset);
+ var item = markup.NamedArguments.First(p => p.Value.StartOffset == lastStart);
+
+ if (context.RawAttributeValue.EndsWith("=", StringComparison.OrdinalIgnoreCase) ||
+ (item.Value.IsString && item.Value.StringValue.EndsWith(context.Editor.GetWordBeforeCaretExtended(), StringComparison.Ordinal))) {
+ MemberResolveResult mrr = XamlResolver.ResolveMember(item.Key, context) as MemberResolveResult;
+ if (mrr != null && mrr.ResolvedMember != null && mrr.ResolvedMember.ReturnType != null) {
+ IReturnType memberType = mrr.ResolvedMember.ReturnType;
+ list.Items.AddRange(MemberCompletion(context, memberType, string.Empty));
+ }
+ return;
+ }
+ }
+
+ list.Items.AddRange(type.GetProperties().Where(p => p.CanSet && p.IsPublic).Select(p => new XamlCodeCompletionItem(p.Name + "=", p)));
+ }
+
+ /// returns true if elements from named args completion should be added afterwards.
+ static bool DoPositionalArgsCompletion(XamlCompletionItemList list, XamlCompletionContext context, MarkupExtensionInfo markup, IReturnType type)
+ {
+ switch (type.FullyQualifiedName) {
+ case "System.Windows.Markup.ArrayExtension":
+ case "System.Windows.Markup.NullExtension":
+ // x:Null/x:Array does not need completion, ignore it
+ break;
+ case "System.Windows.Markup.StaticExtension":
+ if (context.AttributeValue.ExtensionValue.PositionalArguments.Count <= 1)
+ return DoStaticExtensionCompletion(list, context);
+ break;
+ case "System.Windows.Markup.TypeExtension":
+ if (context.AttributeValue.ExtensionValue.PositionalArguments.Count <= 1) {
+ list.Items.AddRange(GetClassesFromContext(context).FlattenToList());
+ AttributeValue selItem = Utils.GetMarkupExtensionAtPosition(context.AttributeValue.ExtensionValue, context.ValueStartOffset)
+ .PositionalArguments.LastOrDefault();
+ string word = context.Editor.GetWordBeforeCaret().TrimEnd();
+ if (selItem != null && selItem.IsString && word == selItem.StringValue) {
+ list.PreselectionLength = selItem.StringValue.Length;
+ }
+ }
+ break;
+ default:
+ var ctors = type.GetMethods()
+ .Where(m => m.IsPublic && m.IsConstructor && m.Parameters.Count >= markup.PositionalArguments.Count + 1);
+ if (context.Forced)
+ return true;
+ if (ctors.Any() || markup.PositionalArguments.Count == 0)
+ return false;
+ break;
+ }
+
+ return true;
+ }
+
+ static IEnumerable FlattenToList(this IDictionary> data)
+ {
+ foreach (var item in data) {
+ foreach (IClass c in item.Value) {
+ yield return new XamlCodeCompletionItem(c, item.Key);
+ }
+ }
+ }
+
+ public static IEnumerable MemberInsight(MemberResolveResult result)
+ {
+ switch (result.ResolvedType.FullyQualifiedName) {
+ case "System.Windows.Thickness":
+ yield return new MemberInsightItem(result.ResolvedMember, "uniformLength");
+ yield return new MemberInsightItem(result.ResolvedMember, "left, top");
+ yield return new MemberInsightItem(result.ResolvedMember, "left, top, right, bottom");
+ break;
+ case "System.Windows.Size":
+ yield return new MemberInsightItem(result.ResolvedMember, "width, height");
+ break;
+ case "System.Windows.Point":
+ yield return new MemberInsightItem(result.ResolvedMember, "x, y");
+ break;
+ case "System.Windows.Rect":
+ yield return new MemberInsightItem(result.ResolvedMember, "x, y, width, height");
+ break;
+ }
+ }
+
+ public static string LookForTargetTypeValue(XamlCompletionContext context, out bool isExplicit, params string[] elementName) {
+ var ancestors = context.Ancestors;
+
+ isExplicit = false;
+
+ for (int i = 0; i < ancestors.Count; i++) {
+ if (ancestors[i].LocalName == "Style" && WpfXamlNamespaces.Contains(ancestors[i].Namespace)) {
+ isExplicit = true;
+ return ancestors[i].GetAttributeValue("TargetType") ?? string.Empty;
+ }
+
+ if (ancestors[i].Name.EndsWithAny(elementName.Select(s => "." + s + "s"), StringComparison.Ordinal)
+ && !ancestors[i].Name.StartsWith("Style.", StringComparison.Ordinal)) {
+ return ancestors[i].Name.Remove(ancestors[i].Name.IndexOf('.'));
+ }
+ }
+
+ return null;
+ }
+
+ public static string GetTypeNameFromTypeExtension(MarkupExtensionInfo info, XamlCompletionContext context)
+ {
+ IReturnType type = CompletionDataHelper.ResolveType(info.ExtensionType, context)
+ ?? CompletionDataHelper.ResolveType(info.ExtensionType + "Extension", context);
+
+ if (type == null || type.FullyQualifiedName != "System.Windows.Markup.TypeExtension")
+ return string.Empty;
+
+ var item = info.PositionalArguments.FirstOrDefault();
+ if (item != null && item.IsString) {
+ return item.StringValue;
+ } else {
+ if (info.NamedArguments.TryGetValue("typename", out item)) {
+ if (item.IsString)
+ return item.StringValue;
+ }
+ }
+
+ return string.Empty;
+ }
+
+ public static bool EndsWithAny(this string thisValue, IEnumerable items, StringComparison comparison)
+ {
+ foreach (string item in items) {
+ if (thisValue.EndsWith(item, comparison))
+ return true;
+ }
+
+ return false;
+ }
+
+ public static bool EndsWithAny(this string thisValue, params char[] items)
+ {
+ foreach (char item in items) {
+ if (thisValue.EndsWith(item.ToString()))
+ return true;
+ }
+
+ return false;
+ }
+
+ static IReturnType GetType(XamlCompletionContext context, out bool isExplicit)
+ {
+ AttributeValue value = MarkupExtensionParser.ParseValue(LookForTargetTypeValue(context, out isExplicit, "Trigger", "Setter") ?? string.Empty);
+
+ IReturnType typeName = null;
+ string typeNameString = null;
+
+ if (!value.IsString) {
+ typeNameString = GetTypeNameFromTypeExtension(value.ExtensionValue, context);
+ typeName = CompletionDataHelper.ResolveType(typeNameString, context);
+ } else {
+ typeNameString = value.StringValue;
+ typeName = CompletionDataHelper.ResolveType(value.StringValue, context);
+ }
+
+ return typeName;
+ }
+
+ public static IEnumerable MemberCompletion(XamlCompletionContext context, IReturnType type, string textPrefix)
+ {
+ if (type == null || type.GetUnderlyingClass() == null)
+ yield break;
+
+ var c = type.GetUnderlyingClass();
+
+ if (type is ConstructedReturnType && type.TypeArgumentCount > 0 && c.FullyQualifiedName == "System.Nullable") {
+ ConstructedReturnType rt = type as ConstructedReturnType;
+ string nullExtensionName = "Null";
+ if (!string.IsNullOrEmpty(context.XamlNamespacePrefix))
+ nullExtensionName = context.XamlNamespacePrefix + ":" + nullExtensionName;
+ yield return new SpecialCompletionItem("{" + nullExtensionName + "}");
+ c = rt.TypeArguments.First().GetUnderlyingClass();
+ if (c == null)
+ yield break;
+ }
+
+ bool isExplicit, showFull = false;
+ IReturnType typeName;
+
+ string valueBeforeCaret = (context.ValueStartOffset > 0) ?
+ context.RawAttributeValue.Substring(0, context.ValueStartOffset) : "";
+
+ switch (c.ClassType) {
+ case ClassType.Class:
+ switch (c.FullyQualifiedName) {
+ case "System.String":
+ // return nothing
+ break;
+ case "System.Type":
+ foreach (var item in CreateElementList(context, true, true))
+ yield return item;
+ break;
+ case "System.Windows.PropertyPath":
+ foreach (var item in CreatePropertyPathCompletion(context))
+ yield return item;
+ break;
+ case "System.Windows.DependencyProperty":
+ typeName = GetType(context, out isExplicit);
+
+ bool isReadOnly = context.ActiveElement.Name.EndsWith("Trigger");
+
+ if (!isExplicit && valueBeforeCaret.Contains("."))
+ showFull = true;
+
+ if (typeName != null) {
+ foreach (var item in typeName.GetDependencyProperties(true, !isExplicit, !isReadOnly, showFull))
+ yield return item;
+ }
+ break;
+ case "System.Windows.RoutedEvent":
+ typeName = GetType(context, out isExplicit);
+
+ if (!isExplicit && valueBeforeCaret.Contains("."))
+ showFull = true;
+
+ if (typeName != null) {
+ foreach (var item in typeName.GetRoutedEvents(true, !isExplicit, showFull))
+ yield return item;
+ }
+ break;
+ case "System.Windows.Media.FontFamily":
+ foreach (var font in Fonts.SystemFontFamilies)
+ yield return new SpecialValueCompletionItem(font.FamilyNames.First().Value);
+ break;
+ default:
+ if (context.Description == XamlContextDescription.InMarkupExtension) {
+ foreach (IField f in c.Fields)
+ yield return new XamlCodeCompletionItem(textPrefix + f.Name, f);
+ foreach (IProperty p in c.Properties.Where(pr => pr.IsPublic && pr.IsStatic && pr.CanGet))
+ yield return new XamlCodeCompletionItem(textPrefix + p.Name, p);
+ }
+ break;
+ }
+ break;
+ case ClassType.Enum:
+ foreach (IField f in c.Fields)
+ yield return new XamlCodeCompletionItem(textPrefix + f.Name, f);
+ foreach (IProperty p in c.Properties.Where(pr => pr.IsPublic && pr.IsStatic && pr.CanGet))
+ yield return new XamlCodeCompletionItem(textPrefix + p.Name, p);
+ break;
+ case ClassType.Struct:
+ switch (c.FullyQualifiedName) {
+ case "System.Boolean":
+ yield return new SpecialValueCompletionItem("True");
+ yield return new SpecialValueCompletionItem("False");
+ break;
+ case "System.Windows.GridLength":
+ yield return new SpecialValueCompletionItem("Auto");
+ yield return new SpecialValueCompletionItem("*");
+ break;
+ }
+ break;
+ case ClassType.Delegate:
+ foreach (var item in CreateEventCompletion(context, c))
+ yield return item;
+ break;
+ }
+
+ var classes = c.ProjectContent.Classes.Where(
+ cla => (cla.FullyQualifiedName == c.FullyQualifiedName + "s" ||
+ cla.FullyQualifiedName == c.FullyQualifiedName + "es"));
+ foreach (var coll in classes) {
+ foreach (var item in coll.Properties)
+ yield return new SpecialValueCompletionItem(item.Name);
+ foreach (var item in coll.Fields.Where(f => f.IsPublic && f.IsStatic && f.ReturnType.FullyQualifiedName == c.FullyQualifiedName))
+ yield return new SpecialValueCompletionItem(item.Name);
+ }
+ }
+
+ static IList CreatePropertyPathCompletion(XamlCompletionContext context)
+ {
+ bool isExplicit;
+ IReturnType typeName = GetType(context, out isExplicit);
+ IList list = new List();
+
+ string value = context.ValueStartOffset > -1 ? context.RawAttributeValue.Substring(0, Math.Min(context.ValueStartOffset + 1, context.RawAttributeValue.Length)) : "";
+
+ if (value.EndsWithAny(']', ')'))
+ return list;
+
+ var segments = PropertyPathParser.Parse(value).ToList();
+
+ int completionStart;
+ bool isAtDot = false;
+
+ IReturnType propertyPathType = ResolvePropertyPath(segments, context, typeName, out completionStart);
+ if (completionStart < segments.Count) {
+ PropertyPathSegment seg = segments[completionStart];
+ switch (seg.Kind) {
+ case SegmentKind.ControlChar:
+ if (seg.Content == ".") {
+ AddAttributes(propertyPathType, list, false);
+ isAtDot = true;
+ }
+ break;
+ case SegmentKind.AttachedProperty:
+ AddAttributes(seg.Resolve(context, propertyPathType), list, false);
+ isAtDot = seg.Content.Contains(".");
+ break;
+ case SegmentKind.PropertyOrType:
+ AddAttributes(propertyPathType, list, false);
+ isAtDot = true;
+ break;
+ }
+ } else if (typeName != null) {
+ AddAttributes(typeName, list, false);
+ }
+
+ if (!isAtDot) {
+ foreach (var item in GetAllTypes(context))
+ list.Add(item);
+ }
+
+ return list;
+ }
+
+ static IReturnType ResolvePropertyPath(IList segments, XamlCompletionContext context, IReturnType parentType, out int lastIndex)
+ {
+ IReturnType type = parentType;
+
+ for (lastIndex = 0; lastIndex < segments.Count - 1; lastIndex++) {
+ PropertyPathSegment segment = segments[lastIndex];
+ switch (segment.Kind) {
+ case SegmentKind.AttachedProperty:
+ // do we need to take account of previous results?
+ type = segment.Resolve(context, null);
+ break;
+ case SegmentKind.ControlChar:
+ if (segment.Content == "[" || segment.Content == "(" || segment.Content == "/")
+ return null;
+ return type;
+ case SegmentKind.PropertyOrType:
+ type = segment.Resolve(context, type);
+ break;
+ case SegmentKind.Indexer:
+ if (type != null) {
+ IProperty prop = type.GetProperties().FirstOrDefault(p => p.IsIndexer);
+ if (prop != null) {
+ type = prop.ReturnType;
+ }
+ }
+ break;
+ case SegmentKind.SourceTraversal:
+ // ignore
+ return null;
+ }
+ }
+
+ return type;
+ }
+
+ static IReturnType Resolve(this PropertyPathSegment segment, XamlCompletionContext context, IReturnType previousType)
+ {
+ if (segment.Kind == SegmentKind.SourceTraversal)
+ return previousType;
+ if (segment.Kind == SegmentKind.ControlChar)
+ return previousType;
+
+ string content = segment.Content;
+
+ if (segment.Kind == SegmentKind.AttachedProperty && content.StartsWith("(")) {
+ content = content.TrimStart('(');
+ if (content.Contains("."))
+ content = content.Remove(content.IndexOf('.'));
+ }
+
+ XamlContextDescription tmp = context.Description;
+ context.Description = XamlContextDescription.InTag;
+
+ ResolveResult rr = XamlResolver.Resolve(content, context);
+ IReturnType type = null;
+
+ if (rr is TypeResolveResult)
+ type = (rr as TypeResolveResult).ResolvedType;
+
+ if (previousType != null) {
+ IMember member = previousType.GetMemberByName(content);
+ if (member != null)
+ type = member.ReturnType;
+ } else {
+ if (rr is MemberResolveResult) {
+ MemberResolveResult mrr = rr as MemberResolveResult;
+ if (mrr.ResolvedMember != null)
+ type = mrr.ResolvedMember.ReturnType;
+ }
+ if (rr is TypeResolveResult)
+ type = (rr as TypeResolveResult).ResolvedType;
+ }
+
+ context.Description = tmp;
+ return type;
+ }
+
+ static IMember GetMemberByName(this IReturnType type, string name)
+ {
+ if (type == null)
+ throw new ArgumentNullException("type");
+
+ foreach (IMember member in type.GetFields()) {
+ if (member.Name == name)
+ return member;
+ }
+
+ foreach (IMember member in type.GetProperties()) {
+ if (member.Name == name)
+ return member;
+ }
+
+ return null;
+ }
+
+ static IEnumerable CreateEventCompletion(XamlCompletionContext context, IClass c)
+ {
+ IMethod invoker = c.Methods.Where(method => method.Name == "Invoke").FirstOrDefault();
+ if (invoker != null && context.ActiveElement != null) {
+ var item = context.ActiveElement;
+ var evt = ResolveAttribute(context.Attribute.ToQualifiedName(), context) as IEvent;
+ if (evt == null)
+ return Enumerable.Empty();
+
+ int offset = XmlEditor.XmlParser.GetActiveElementStartIndex(context.Editor.Document.Text, context.Editor.Caret.Offset);
+
+ if (offset == -1)
+ return Enumerable.Empty();
+
+ var loc = context.Editor.Document.OffsetToPosition(offset);
+
+ string name = context.ActiveElement.GetAttributeValue("Name");
+ if (string.IsNullOrEmpty(name))
+ name = context.ActiveElement.GetAttributeValue(XamlNamespace, "Name");
+
+ IList list = new List();
+ list.Add(new NewEventCompletionItem(evt, (string.IsNullOrEmpty(name) ? item.Name : name)));
+
+ return CompletionDataHelper.AddMatchingEventHandlers(context, invoker).Concat(list);
+ }
+
+ return Enumerable.Empty();
+ }
+
+ static IMember ResolveAttribute(QualifiedNameWithLocation attribute, XamlCompletionContext context)
+ {
+ if (attribute == null)
+ return null;
+
+ return ResolveAttribute(attribute.FullXmlName, context);
+ }
+
+ static IMember ResolveAttribute(string attribute, XamlCompletionContext context)
+ {
+ MemberResolveResult mrr = XamlResolver.Resolve(attribute, context) as MemberResolveResult;
+
+ if (mrr == null)
+ return null;
+
+ return mrr.ResolvedMember;
+ }
+
+ static bool DoStaticExtensionCompletion(XamlCompletionItemList list, XamlCompletionContext context)
+ {
+ AttributeValue selItem = Utils.GetMarkupExtensionAtPosition(context.AttributeValue.ExtensionValue, context.ValueStartOffset)
+ .PositionalArguments.LastOrDefault();
+ if (context.PressedKey == '.') {
+ if (selItem != null && selItem.IsString) {
+ var rr = XamlResolver.Resolve(selItem.StringValue, context) as TypeResolveResult;
+ if (rr != null)
+ list.Items.AddRange(MemberCompletion(context, rr.ResolvedType, string.Empty));
+ return false;
+ }
+ } else {
+ if (selItem != null && selItem.IsString) {
+ int index = selItem.StringValue.IndexOf('.');
+ string s = (index > -1) ? selItem.StringValue.Substring(0, index) : selItem.StringValue;
+ var rr = XamlResolver.Resolve(s, context) as TypeResolveResult;
+ if (rr != null) {
+ list.Items.AddRange(MemberCompletion(context, rr.ResolvedType, (index == -1) ? "." : string.Empty));
+
+ list.PreselectionLength = (index > -1) ? selItem.StringValue.Length - index - 1 : 0;
+
+ return false;
+ } else
+ DoStaticTypeCompletion(selItem, list, context);
+ } else {
+ DoStaticTypeCompletion(selItem, list, context);
+ }
+ }
+
+ return true;
+ }
+
+ static void DoStaticTypeCompletion(AttributeValue selItem, XamlCompletionItemList list, XamlCompletionContext context)
+ {
+ var items = GetClassesFromContext(context);
+ foreach (var ns in items) {
+ list.Items.AddRange(ns.Value.Where(c => c.Fields.Any(f => f.IsStatic) || c.Properties.Any(p => p.IsStatic))
+ .Select(c => new XamlCodeCompletionItem(c, ns.Key)));
+ }
+ if (selItem != null && selItem.IsString) {
+ list.PreselectionLength = selItem.StringValue.Length;
+ }
+ }
+
+ public static IReturnType ResolveType(string typeName, XamlContext context)
+ {
+ if (context.ParseInformation == null)
+ return null;
+
+ XamlCompilationUnit cu = context.ParseInformation.CompilationUnit as XamlCompilationUnit;
+ if (cu == null)
+ return null;
+ string prefix = "";
+ int len = typeName.IndexOf(':');
+ string name = typeName;
+ if (len > 0) {
+ prefix = typeName.Substring(0, len);
+ name = typeName.Substring(len + 1, name.Length - len - 1);
+ }
+ string namespaceName = "";
+ if (context.XmlnsDefinitions.TryGetValue(prefix, out namespaceName)) {
+ IReturnType rt = cu.CreateType(namespaceName, name);
+ if (rt != null && rt.GetUnderlyingClass() != null)
+ return rt;
+ }
+ return null;
+ }
+
+ public static IEnumerable AddMatchingEventHandlers(XamlCompletionContext context, IMethod delegateInvoker)
+ {
+ if (context.ParseInformation == null)
+ yield break;
+
+ var unit = context.ParseInformation.CompilationUnit;
+ var loc = context.Editor.Caret.Position;
+ IClass c = unit.GetInnermostClass(loc.Line, loc.Column);
+ if (c == null)
+ yield break;
+ CompoundClass compound = c.GetCompoundClass() as CompoundClass;
+ if (compound != null) {
+ foreach (IClass part in compound.Parts) {
+ foreach (IMethod m in part.Methods) {
+ if (m.Parameters.Count != delegateInvoker.Parameters.Count)
+ continue;
+
+ if ((m.ReturnType != null && delegateInvoker.ReturnType != null) && m.ReturnType.DotNetName != delegateInvoker.ReturnType.DotNetName)
+ continue;
+
+ bool equal = m.Parameters.SequenceEqual(delegateInvoker.Parameters, new ParameterComparer());
+ if (equal) {
+ yield return new XamlCodeCompletionItem(m);
+ }
+ }
+ }
+ }
+ }
+
+ public static bool Compare(this IParameter p1, IParameter p2)
+ {
+ return (p1.ReturnType.DotNetName == p2.ReturnType.DotNetName) &&
+ (p1.IsOut == p2.IsOut) && (p1.IsParams == p2.IsParams) && (p1.IsRef == p2.IsRef);
+ }
+
+ static IDictionary> GetClassesFromContext(XamlCompletionContext context)
+ {
+ var result = new Dictionary>();
+
+ if (context.ParseInformation == null)
+ return result;
+
+ IProjectContent pc = context.ProjectContent;
+
+ foreach (var ns in context.XmlnsDefinitions) {
+ result.Add(ns.Key, XamlCompilationUnit.GetNamespaceMembers(pc, ns.Value));
+ }
+
+ return result;
+ }
+
+ public static bool IsPubliclySetable(this IProperty thisValue)
+ {
+ return thisValue.CanSet &&
+ (thisValue.SetterModifiers == ModifierEnum.None ||
+ (thisValue.SetterModifiers & ModifierEnum.Public) == ModifierEnum.Public);
+ }
+
+ public static IEnumerable GetDependencyProperties(this IReturnType type, bool excludeSuffix, bool addType, bool requiresSetable, bool showFull)
+ {
+ foreach (var field in type.GetFields()) {
+ if (field.ReturnType.FullyQualifiedName != "System.Windows.DependencyProperty")
+ continue;
+ if (field.Name.Length <= "Property".Length || !field.Name.EndsWith("Property", StringComparison.Ordinal))
+ continue;
+ string fieldName = field.Name.Remove(field.Name.Length - "Property".Length);
+ IProperty property = type.GetProperties().FirstOrDefault(p => p.Name == fieldName);
+ if (property == null)
+ continue;
+ if (requiresSetable && !property.IsPubliclySetable())
+ continue;
+
+ if (!excludeSuffix)
+ fieldName = field.Name;
+
+ if (showFull) {
+ addType = false;
+
+ fieldName = field.DeclaringType.Name + "." + fieldName;
+ }
+
+ yield return new XamlLazyValueCompletionItem(field, fieldName, addType);
+ }
+ }
+
+ public static IEnumerable GetRoutedEvents(this IReturnType type, bool excludeSuffix, bool addType, bool showFull)
+ {
+ foreach (var field in type.GetFields()) {
+ if (field.ReturnType.FullyQualifiedName != "System.Windows.RoutedEvent")
+ continue;
+ if (field.Name.Length <= "Event".Length || !field.Name.EndsWith("Event", StringComparison.Ordinal))
+ continue;
+ string fieldName = field.Name.Remove(field.Name.Length - "Event".Length);
+ if (!type.GetEvents().Any(p => p.Name == fieldName))
+ continue;
+
+ if (!excludeSuffix)
+ fieldName = field.Name;
+
+ if (showFull) {
+ addType = false;
+
+ fieldName = field.DeclaringType.Name + "." + fieldName;
+ }
+
+ yield return new XamlLazyValueCompletionItem(field, fieldName, addType);
+ }
+ }
+
+ internal static List GetListOfAttached(XamlCompletionContext context, string prefixClassName, string prefixNamespace, bool events, bool properties)
+ {
+ List result = new List();
+
+ if (context.ParseInformation == null)
+ return result;
+
+ IProjectContent pc = context.ProjectContent;
+
+ if (!string.IsNullOrEmpty(prefixClassName)) {
+ var ns = context.XmlnsDefinitions[prefixNamespace];
+ IClass c = XamlCompilationUnit.GetNamespaceMembers(pc, ns).FirstOrDefault(item => item.Name == prefixClassName);
+ if (c != null && c.ClassType == ClassType.Class) {
+ if (!c.ClassInheritanceTree.Any(b => b.FullyQualifiedName == "System.Attribute")) {
+ prefixNamespace = string.IsNullOrEmpty(prefixNamespace) ? prefixNamespace : prefixNamespace + ":";
+ if (properties)
+ AddAttachedProperties(c, result, prefixNamespace, prefixNamespace + prefixClassName);
+ if (events)
+ AddAttachedEvents(c, result, prefixNamespace, prefixNamespace + prefixClassName);
+ }
+ }
+ } else {
+ foreach (var ns in context.XmlnsDefinitions) {
+ string key = string.IsNullOrEmpty(ns.Key) ? "" : ns.Key + ":";
+
+ foreach (IClass c in XamlCompilationUnit.GetNamespaceMembers(pc, ns.Value)) {
+ if (c.ClassType != ClassType.Class)
+ continue;
+ if (c.HasAttached(properties, events))
+ result.Add(new XamlCodeCompletionItem(c, ns.Key));
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public static void AddAttachedProperties(IClass c, List result, string key, string prefix)
+ {
+ if (c == null)
+ return;
+
+ var attachedProperties = c.Fields.Where(f => f.IsAttached(true, false));
+
+ int prefixLength = (prefix.Length > 0) ? prefix.Length + 1 : 0;
+
+ result.AddRange(
+ attachedProperties.Select(
+ item => {
+ string property = item.Name.Remove(item.Name.Length - "Property".Length);
+ string name = key + c.Name + "." + item.Name.Remove(item.Name.Length - "Property".Length);
+ return new XamlCodeCompletionItem(name.Remove(0, prefixLength), new DefaultProperty(c, property) { ReturnType = GetAttachedPropertyType(item, c) });
+ }
+ )
+ );
+ }
+
+ static void AddAttachedEvents(IClass c, List result, string key, string prefix)
+ {
+ var attachedEvents = c.Fields.Where(f => f.IsAttached(false, true));
+
+ int prefixLength = (prefix.Length > 0) ? prefix.Length + 1 : 0;
+
+ result.AddRange(
+ attachedEvents.Select(
+ item => {
+ string @event = item.Name.Remove(item.Name.Length - "Event".Length);
+ string name = key + c.Name + "." + item.Name.Remove(item.Name.Length - "Event".Length);
+ return new XamlCodeCompletionItem(name.Remove(0, prefixLength), new DefaultEvent(c, @event) { ReturnType = GetAttachedEventDelegateType(item, c) });
+ }
+ )
+ );
+ }
+
+ static IReturnType GetAttachedEventDelegateType(IField field, IClass c)
+ {
+ if (c == null || field == null)
+ return null;
+
+ string eventName = field.Name.Remove(field.Name.Length - "Event".Length);
+
+ IMethod method = c.Methods
+ .Where(m =>
+ m.IsPublic &&
+ m.IsStatic &&
+ m.Parameters.Count == 2 &&
+ (m.Name == "Add" + eventName + "Handler" ||
+ m.Name == "Remove" + eventName + "Handler"))
+ .FirstOrDefault();
+
+ if (method == null)
+ return null;
+
+ return method.Parameters[1].ReturnType;
+ }
+
+ static IReturnType GetAttachedPropertyType(IField field, IClass c)
+ {
+ if (c == null || field == null)
+ return null;
+
+ string propertyName = field.Name.Remove(field.Name.Length - "Property".Length);
+
+ IMethod method = c.Methods
+ .Where(m =>
+ m.IsPublic &&
+ m.IsStatic &&
+ m.Name == "Get" + propertyName)
+ .FirstOrDefault();
+
+ if (method == null)
+ return null;
+
+ return method.ReturnType;
+ }
+
+ static string GetEventNameFromMethod(IMethod m)
+ {
+ string mName = m.Name;
+ if (mName.StartsWith("Add", StringComparison.Ordinal))
+ mName = mName.Remove(0, 3);
+ else if (mName.StartsWith("Remove", StringComparison.Ordinal))
+ mName = mName.Remove(0, 6);
+ if (mName.EndsWith("Handler", StringComparison.Ordinal))
+ mName = mName.Remove(mName.Length - "Handler".Length);
+
+ return mName;
+ }
+
+ static string GetEventNameFromField(IField f)
+ {
+ string fName = f.Name;
+ if (fName.EndsWith("Event", StringComparison.Ordinal))
+ fName = fName.Remove(fName.Length - "Event".Length);
+
+ return fName;
+ }
+
+ static bool IsMethodFromEvent(IField f, IMethod m)
+ {
+ return GetEventNameFromField(f) == GetEventNameFromMethod(m);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCompilationUnit.cs b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCompilationUnit.cs
new file mode 100644
index 0000000000..dbba1cbb8b
--- /dev/null
+++ b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCompilationUnit.cs
@@ -0,0 +1,145 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+
+using ICSharpCode.SharpDevelop;
+using ICSharpCode.SharpDevelop.Dom;
+
+namespace ICSharpCode.XamlBinding
+{
+ ///
+ /// Description of XamlCompilationUnit.
+ ///
+ public class XamlCompilationUnit : DefaultCompilationUnit
+ {
+ public XamlCompilationUnit(IProjectContent projectContent)
+ : base(projectContent)
+ {
+ }
+
+ public NodeWrapper TreeRootNode { get; set; }
+
+ ///
+ /// Creates a IReturnType looking for a class referenced in XAML.
+ ///
+ /// The XML namespace
+ /// The class name
+ /// A new IReturnType that will search the referenced type on demand.
+ public IReturnType CreateType(string xmlNamespace, string className)
+ {
+ if (string.IsNullOrEmpty(className) || className.Contains("."))
+ return null;
+
+ if (xmlNamespace.StartsWith("clr-namespace:", StringComparison.OrdinalIgnoreCase)) {
+ return CreateClrNamespaceType(this.ProjectContent, xmlNamespace, className);
+ } else {
+ return new XamlClassReturnType(this, xmlNamespace, className);
+ }
+ }
+
+ static IReturnType CreateClrNamespaceType(IProjectContent pc, string xmlNamespace, string className)
+ {
+ string namespaceName = GetNamespaceNameFromClrNamespace(xmlNamespace);
+ return new GetClassReturnType(pc, namespaceName + "." + className, 0);
+ }
+
+ static string GetNamespaceNameFromClrNamespace(string xmlNamespace)
+ {
+ string namespaceName = xmlNamespace.Substring("clr-namespace:".Length);
+ int pos = namespaceName.IndexOf(';');
+ if (pos >= 0) {
+ // we expect that the target type is also a reference of the project, so we
+ // can ignore the assembly part after the ;
+ namespaceName = namespaceName.Substring(0, pos);
+ }
+ return namespaceName;
+ }
+
+ ///
+ /// Finds a type referenced in XAML.
+ ///
+ /// The XML namespace
+ /// The class name
+ /// Returns the referenced type, or null if it cannot be found.
+ public IReturnType FindType(string xmlNamespace, string className)
+ {
+ return FindType(this.ProjectContent, xmlNamespace, className);
+ }
+
+ public static IReturnType FindType(IProjectContent pc, string xmlNamespace, string className)
+ {
+ if (pc == null)
+ throw new ArgumentNullException("pc");
+ if (xmlNamespace == null || className == null)
+ return null;
+ if (xmlNamespace.StartsWith("clr-namespace:", StringComparison.OrdinalIgnoreCase)) {
+ return CreateClrNamespaceType(pc, xmlNamespace, className);
+ }
+ else {
+ IReturnType type = FindTypeInAssembly(pc, xmlNamespace, className);
+ if (type != null)
+ return type;
+ foreach (IProjectContent p in pc.ThreadSafeGetReferencedContents()) {
+ type = FindTypeInAssembly(p, xmlNamespace, className);
+ if (type != null)
+ return type;
+ }
+ return null;
+ }
+ }
+
+ static IReturnType FindTypeInAssembly(IProjectContent projectContent, string xmlNamespace, string className)
+ {
+ foreach (IAttribute att in projectContent.GetAssemblyAttributes()) {
+ if (att.PositionalArguments.Count == 2
+ && att.AttributeType.FullyQualifiedName == "System.Windows.Markup.XmlnsDefinitionAttribute") {
+ string namespaceName = att.PositionalArguments[1] as string;
+ if (xmlNamespace.Equals(att.PositionalArguments[0]) && namespaceName != null) {
+ IClass c = projectContent.GetClass(namespaceName + "." + className, 0);
+ if (c != null)
+ return c.DefaultReturnType;
+ }
+ }
+ }
+ return null;
+ }
+
+ public static IEnumerable GetNamespaceMembers(IProjectContent pc, string xmlNamespace)
+ {
+ if (pc == null)
+ throw new ArgumentNullException("pc");
+
+ if (!string.IsNullOrEmpty(xmlNamespace)) {
+ if (xmlNamespace.StartsWith("clr-namespace:", StringComparison.OrdinalIgnoreCase))
+ return pc.GetNamespaceContents(GetNamespaceNameFromClrNamespace(xmlNamespace)).OfType();
+ else {
+ var list = new List();
+ AddNamespaceMembersInAssembly(pc, xmlNamespace, list);
+ foreach (IProjectContent p in pc.ThreadSafeGetReferencedContents()) {
+ AddNamespaceMembersInAssembly(p, xmlNamespace, list);
+ }
+ return list.OfType();
+ }
+ }
+
+ return Enumerable.Empty();
+ }
+
+ static void AddNamespaceMembersInAssembly(IProjectContent projectContent, string xmlNamespace, List list)
+ {
+ foreach (IAttribute att in projectContent.GetAssemblyAttributes()) {
+ if (att.PositionalArguments.Count == 2
+ && att.AttributeType.FullyQualifiedName == "System.Windows.Markup.XmlnsDefinitionAttribute") {
+ string namespaceName = att.PositionalArguments[1] as string;
+ if (xmlNamespace.Equals(att.PositionalArguments[0]) && namespaceName != null) {
+ projectContent.AddNamespaceContents(list, namespaceName, projectContent.Language, false);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/TreeNodeWrapper.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/TreeNodeWrapper.cs
index 6c8dd6ac22..048c0a26b2 100644
--- a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/TreeNodeWrapper.cs
+++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/TreeNodeWrapper.cs
@@ -39,6 +39,16 @@ namespace Debugger.AddIn.Pads.Controls
get { return Node.HasChildNodes; }
}
+ public override bool CanDelete()
+ {
+ return Parent is WatchRootNode;
+ }
+
+ public override void Delete()
+ {
+ Parent.Children.Remove(this);
+ }
+
protected override void LoadChildren()
{
if (Node.HasChildNodes) {
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchListAutoCompleteCell.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchListAutoCompleteCell.cs
index 4b26e798e4..4cf639972f 100644
--- a/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchListAutoCompleteCell.cs
+++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchListAutoCompleteCell.cs
@@ -25,7 +25,7 @@ namespace Debugger.AddIn.Pads.Controls
{
public partial class WatchListAutoCompleteCell : UserControl
{
- private string language;
+ string language;
protected ConsoleControl console;
@@ -33,7 +33,7 @@ namespace Debugger.AddIn.Pads.Controls
DependencyProperty.Register("CommandText", typeof(string), typeof(WatchListAutoCompleteCell),
new UIPropertyMetadata(null, new PropertyChangedCallback(OnCommandTextChanged)));
- private NRefactoryResolver resolver;
+ NRefactoryResolver resolver;
public event EventHandler CommandEntered;
@@ -72,7 +72,7 @@ namespace Debugger.AddIn.Pads.Controls
this.Process = debugger.DebuggedProcess;
}
- private Process Process { get; set; }
+ Process Process { get; set; }
///
/// Gets/sets the command text displayed at the command prompt.
@@ -82,13 +82,13 @@ namespace Debugger.AddIn.Pads.Controls
set { console.CommandText = value; }
}
- private ITextEditor TextEditor {
+ ITextEditor TextEditor {
get {
return console.TextEditor;
}
}
- private void console_TextAreaPreviewKeyDown(object sender, KeyEventArgs e)
+ void console_TextAreaPreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return || e.Key == Key.Escape) {
@@ -106,7 +106,7 @@ namespace Debugger.AddIn.Pads.Controls
}
}
- private void console_LostFocus(object sender, RoutedEventArgs e)
+ void console_LostFocus(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(CommandText) || !this.CheckSyntax())
return;
@@ -115,7 +115,7 @@ namespace Debugger.AddIn.Pads.Controls
CommandEntered(this, EventArgs.Empty);
}
- private bool CheckSyntax()
+ bool CheckSyntax()
{
string command = CommandText;
@@ -139,7 +139,7 @@ namespace Debugger.AddIn.Pads.Controls
return true;
}
- private void consoleControl_TextAreaTextEntered(object sender, TextCompositionEventArgs e)
+ void consoleControl_TextAreaTextEntered(object sender, TextCompositionEventArgs e)
{
foreach (char ch in e.Text) {
if (ch == '.') {
@@ -148,21 +148,15 @@ namespace Debugger.AddIn.Pads.Controls
}
}
- private void ShowDotCompletion(string currentText)
+ void ShowDotCompletion(string currentText)
{
var seg = Process.SelectedStackFrame.NextStatement;
-
var expressionFinder = ParserService.GetExpressionFinder(seg.Filename);
var info = ParserService.GetParseInformation(seg.Filename);
-
string text = ParserService.GetParseableFileContent(seg.Filename).Text;
-
int currentOffset = TextEditor.Caret.Offset - console.CommandOffset - 1;
-
var expr = expressionFinder.FindExpression(currentText, currentOffset);
-
expr.Region = new DomRegion(seg.StartLine, seg.StartColumn, seg.EndLine, seg.EndColumn);
-
var rr = resolver.Resolve(expr, info, text);
if (rr != null) {
@@ -170,9 +164,12 @@ namespace Debugger.AddIn.Pads.Controls
}
}
- private static void OnCommandTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
+ static void OnCommandTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
var cell = d as WatchListAutoCompleteCell;
- cell.CommandText = e.NewValue.ToString();
+ if (cell != null && e.NewValue != null) {
+ cell.CommandText = e.NewValue.ToString();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs
index 77da1ed9f5..f4b9e6241f 100644
--- a/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs
+++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs
@@ -55,12 +55,11 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
watchList = new WatchList(WatchListType.Watch);
watchList.ContextMenu = MenuService.CreateContextMenu(this, "/SharpDevelop/Pads/WatchPad/ContextMenu");
- watchList.MouseDoubleClick += watchList_DoubleClick;
- watchList.KeyUp += watchList_KeyUp;
+ watchList.MouseDoubleClick += WatchListDoubleClick;
watchList.WatchItems.CollectionChanged += OnWatchItemsCollectionChanged;
panel.Children.Add(watchList);
- panel.KeyUp += new KeyEventHandler(panel_KeyUp);
+ panel.KeyDown += PanelKeyDown;
// wire events that influence the items
LoadSavedNodes();
@@ -122,23 +121,15 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
#endregion
- void panel_KeyUp(object sender, KeyEventArgs e)
+ void PanelKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Insert) {
AddNewWatch();
e.Handled = true;
}
}
-
- void watchList_KeyUp(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Delete) {
- RemoveWatchCommand cmd = new RemoveWatchCommand { Owner = this };
- cmd.Run();
- }
- }
- void watchList_DoubleClick(object sender, MouseEventArgs e)
+ void WatchListDoubleClick(object sender, MouseEventArgs e)
{
if (watchList.SelectedNode == null)
{
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Commands/FoldingCommands.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Commands/FoldingCommands.cs
index db9c792c6a..21d819ae5d 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Commands/FoldingCommands.cs
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Commands/FoldingCommands.cs
@@ -5,6 +5,7 @@ using System;
using System.Linq;
using ICSharpCode.AvalonEdit.Folding;
using ICSharpCode.Core;
+using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
@@ -16,14 +17,14 @@ namespace ICSharpCode.AvalonEdit.AddIn.Commands
{
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider;
ITextEditor editor = provider.TextEditor;
- ParserFoldingStrategy strategy = editor.GetService(typeof(ParserFoldingStrategy)) as ParserFoldingStrategy;
+ FoldingManager foldingManager = editor.GetService(typeof(FoldingManager)) as FoldingManager;
- if (strategy != null) {
+ if (foldingManager != null) {
// look for folding on this line:
- FoldingSection folding = strategy.FoldingManager.GetNextFolding(editor.Document.GetOffset(editor.Caret.Line, 1));
- if (folding == null || editor.Document.GetLineByOffset(folding.StartOffset).LineNumber != editor.Caret.Line) {
+ FoldingSection folding = foldingManager.GetNextFolding(editor.Document.PositionToOffset(editor.Caret.Line, 1));
+ if (folding == null || editor.Document.GetLineForOffset(folding.StartOffset).LineNumber != editor.Caret.Line) {
// no folding found on current line: find innermost folding containing the caret
- folding = strategy.FoldingManager.GetFoldingsContaining(editor.Caret.Offset).LastOrDefault();
+ folding = foldingManager.GetFoldingsContaining(editor.Caret.Offset).LastOrDefault();
}
if (folding != null) {
folding.IsFolded = !folding.IsFolded;
@@ -38,17 +39,17 @@ namespace ICSharpCode.AvalonEdit.AddIn.Commands
{
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider;
ITextEditor editor = provider.TextEditor;
- ParserFoldingStrategy strategy = editor.GetService(typeof(ParserFoldingStrategy)) as ParserFoldingStrategy;
+ FoldingManager foldingManager = editor.GetService(typeof(FoldingManager)) as FoldingManager;
- if (strategy != null) {
+ if (foldingManager != null) {
bool doFold = true;
- foreach (FoldingSection fm in strategy.FoldingManager.AllFoldings) {
+ foreach (FoldingSection fm in foldingManager.AllFoldings) {
if (fm.IsFolded) {
doFold = false;
break;
}
}
- foreach (FoldingSection fm in strategy.FoldingManager.AllFoldings) {
+ foreach (FoldingSection fm in foldingManager.AllFoldings) {
fm.IsFolded = doFold;
}
}
@@ -61,10 +62,10 @@ namespace ICSharpCode.AvalonEdit.AddIn.Commands
{
ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent as ITextEditorProvider;
ITextEditor editor = provider.TextEditor;
- ParserFoldingStrategy strategy = editor.GetService(typeof(ParserFoldingStrategy)) as ParserFoldingStrategy;
+ FoldingManager foldingManager = editor.GetService(typeof(FoldingManager)) as FoldingManager;
- if (strategy != null) {
- foreach (FoldingSection fm in strategy.FoldingManager.AllFoldings) {
+ if (foldingManager != null) {
+ foreach (FoldingSection fm in foldingManager.AllFoldings) {
fm.IsFolded = ParserFoldingStrategy.IsDefinition(fm);
}
}
diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/QuickClassBrowser.xaml b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/QuickClassBrowser.xaml
index c17d8f8748..049069b662 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/QuickClassBrowser.xaml
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/QuickClassBrowser.xaml
@@ -6,7 +6,7 @@
-
+
diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/AbstractDesignerGenerator.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/AbstractDesignerGenerator.cs
index cda90f1c2e..9a9c4214f8 100644
--- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/AbstractDesignerGenerator.cs
+++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/AbstractDesignerGenerator.cs
@@ -344,8 +344,11 @@ namespace ICSharpCode.FormsDesigner
continue;
if (expr.TargetType.BaseType != "System.ComponentModel.ISupportInitialize")
continue;
- CodeMemberField field = formClass.Members.OfType().First(f => this.formClass.ProjectContent.Language.NameComparer.Equals(fieldRef.FieldName, f.Name));
- IClass fieldType = this.formClass.ProjectContent.GetClass(field.Type.BaseType, 0);
+ IField field = this.formClass.DefaultReturnType.GetFields()
+ .First(f => this.formClass.ProjectContent.Language.NameComparer.Equals(fieldRef.FieldName, f.Name));
+ if (field.ReturnType == null)
+ continue;
+ IClass fieldType = field.ReturnType.GetUnderlyingClass();
if (fieldType == null)
continue;
if (!fieldType.IsTypeInInheritanceTree(iSupportInitializeInterface))
diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs
index 943c8c39aa..3b484f99e6 100644
--- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs
+++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs
@@ -128,7 +128,7 @@ namespace ICSharpCode.FormsDesigner.Services
try {
// load dependencies of current assembly
- foreach (IProjectContent rpc in pc.ReferencedContents) {
+ foreach (IProjectContent rpc in pc.ThreadSafeGetReferencedContents()) {
if (rpc is ParseProjectContent) {
LoadAssembly(rpc);
} else if (rpc is ReflectionProjectContent) {
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/IdeChooseClassService.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/IdeChooseClassService.cs
index 7714a4b85b..1c575877da 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/IdeChooseClassService.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/IdeChooseClassService.cs
@@ -43,7 +43,7 @@ namespace ICSharpCode.WpfDesign.AddIn
var pc = ParserService.CurrentProjectContent;
var a = GetAssembly(pc);
if (a != null) yield return a;
- foreach (var r in pc.ReferencedContents) {
+ foreach (var r in pc.ThreadSafeGetReferencedContents()) {
a = GetAssembly(r);
if (a != null) yield return a;
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs
index 507b8215d6..82a6b0f8a8 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs
@@ -52,7 +52,7 @@ namespace ICSharpCode.WpfDesign.AddIn
Assembly FindAssemblyInProjectReferences(IProjectContent pc, string name)
{
- foreach (IProjectContent referencedProjectContent in pc.ReferencedContents) {
+ foreach (IProjectContent referencedProjectContent in pc.ThreadSafeGetReferencedContents()) {
if (name == referencedProjectContent.AssemblyName) {
return this.typeResolutionService.LoadAssembly(referencedProjectContent);
}
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewContainerControl.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewContainerControl.cs
index a9d5668e5d..80c563eb32 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewContainerControl.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewContainerControl.cs
@@ -200,7 +200,7 @@ namespace ICSharpCode.XmlEditor
/// comment node currently on display.
///
public string TextContent {
- get { return textBox.Text; }
+ get { return textBox.Text.Replace("\n", "\r\n"); }
set { textBox.Text = value; }
}
@@ -740,6 +740,7 @@ namespace ICSharpCode.XmlEditor
//
this.textBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBox.Location = new System.Drawing.Point(0, 0);
+ this.textBox.Multiline = true;
this.textBox.Name = "textBox";
this.textBox.Size = new System.Drawing.Size(375, 326);
this.textBox.TabIndex = 2;
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs
index 40f9bd9d50..d328fd17f2 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs
+++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs
@@ -142,8 +142,9 @@ namespace ICSharpCode.XmlEditor
{
if (editor == null) return false;
try {
- XmlDocument Document = new XmlDocument();
- Document.LoadXml(editor.Document.Text);
+ XmlDocument document = new XmlDocument();
+ document.XmlResolver = null;
+ document.LoadXml(editor.Document.Text);
return true;
} catch (XmlException ex) {
AddTask(editor.FileName, ex.Message, ex.LinePosition, ex.LineNumber, TaskType.Error);
diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/XmlEditor.addin b/src/AddIns/DisplayBindings/XmlEditor/Project/XmlEditor.addin
index b43777fd26..016ab367c6 100644
--- a/src/AddIns/DisplayBindings/XmlEditor/Project/XmlEditor.addin
+++ b/src/AddIns/DisplayBindings/XmlEditor/Project/XmlEditor.addin
@@ -24,7 +24,7 @@
@@ -55,7 +55,7 @@
+ extensions=".xml;.xsl;.xslt;.xsd;.manifest;.config;.addin;.xshd;.wxs;.wxi;.wxl;.proj;.csproj;.vbproj;.ilproj;.build;.xfrm;.targets;.xpt;.xft;.map;.wsdl;.disco;.nuspec;.booproj;.fsproj;.pyproj;.rbproj;.vcxproj;.wixproj;.ps1xml" />
@@ -68,7 +68,7 @@
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/AvalonEdit.Sample.4.1.0.8000.nupkg b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/AvalonEdit.Sample.4.1.0.8000.nupkg
deleted file mode 100644
index 6e29f74289..0000000000
Binary files a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/AvalonEdit.Sample.4.1.0.8000.nupkg and /dev/null differ
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/AvalonEdit.Sample.nuspec b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/AvalonEdit.Sample.nuspec
index e000423510..71e2f88146 100644
--- a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/AvalonEdit.Sample.nuspec
+++ b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit.Sample/AvalonEdit.Sample.nuspec
@@ -2,7 +2,7 @@
AvalonEdit.Sample
- 4.1.0.8000
+ 4.2.0.8783Daniel GrunwaldSharpDevelophttp://www.opensource.org/licenses/mit-license.php
@@ -16,7 +16,7 @@ StartupUri="/Samples/AvalonEdit/Window1.xaml"
Sample code for AvalonEdit the WPF-based text editor used in SharpDevelop 4.0.en-US
-
+
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.1.0.8000.nupkg b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.1.0.8000.nupkg
deleted file mode 100644
index 2c307fee6c..0000000000
Binary files a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.1.0.8000.nupkg and /dev/null differ
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.1.0.8000.symbols.nupkg b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.1.0.8000.symbols.nupkg
deleted file mode 100644
index f753371459..0000000000
Binary files a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.4.1.0.8000.symbols.nupkg and /dev/null differ
diff --git a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.nuspec b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.nuspec
index 933dab9b9d..ccd43f3278 100644
--- a/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.nuspec
+++ b/src/AddIns/Misc/PackageManagement/Packages/AvalonEdit/AvalonEdit.nuspec
@@ -2,7 +2,7 @@
AvalonEdit
- 4.1.0.8000
+ 4.2.0.8783Daniel GrunwaldSharpDevelophttp://www.opensource.org/licenses/lgpl-2.1.php
diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/DTE.cs b/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/DTE.cs
index b190eb47e9..e2205ee818 100644
--- a/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/DTE.cs
+++ b/src/AddIns/Misc/PackageManagement/Project/Src/EnvDTE/DTE.cs
@@ -29,6 +29,10 @@ namespace ICSharpCode.PackageManagement.EnvDTE
ItemOperations = new ItemOperations(fileService);
}
+ public string Version {
+ get { return "10.0"; }
+ }
+
public Solution Solution {
get {
if (IsSolutionOpen) {
diff --git a/src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/DTETests.cs b/src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/DTETests.cs
index b93e25ef91..bf21b84213 100644
--- a/src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/DTETests.cs
+++ b/src/AddIns/Misc/PackageManagement/Test/Src/EnvDTE/DTETests.cs
@@ -137,5 +137,15 @@ namespace PackageManagement.Tests.EnvDTE
Assert.AreEqual("ProjectA", name);
}
+
+ [Test]
+ public void Version_CheckVersion_Returns10()
+ {
+ CreateDTE();
+
+ string version = dte.Version;
+
+ Assert.AreEqual("10.0", version);
+ }
}
}
diff --git a/src/AddIns/Misc/SharpRefactoring/Project/Src/ContextActions/AddUsing.cs b/src/AddIns/Misc/SharpRefactoring/Project/Src/ContextActions/AddUsing.cs
index 7c4a1dd317..b119c4b4f6 100644
--- a/src/AddIns/Misc/SharpRefactoring/Project/Src/ContextActions/AddUsing.cs
+++ b/src/AddIns/Misc/SharpRefactoring/Project/Src/ContextActions/AddUsing.cs
@@ -48,7 +48,7 @@ namespace SharpRefactoring.ContextActions
IProjectContent pc = context.ProjectContent;
SearchAllExtensionMethodsWithName(results, pc, rr.CallName);
- foreach (IProjectContent content in pc.ReferencedContents)
+ foreach (IProjectContent content in pc.ThreadSafeGetReferencedContents())
SearchAllExtensionMethodsWithName(results, content, rr.CallName);
foreach (IClass c in results) {
@@ -99,7 +99,7 @@ namespace SharpRefactoring.ContextActions
public string Search(UnknownMethodResolveResult rr, IProjectContent pc, List results)
{
SearchAttributesWithName(results, pc, rr.CallName);
- foreach (IProjectContent content in pc.ReferencedContents)
+ foreach (IProjectContent content in pc.ThreadSafeGetReferencedContents())
SearchAttributesWithName(results, content, rr.CallName);
return rr.CallName;
}
@@ -107,7 +107,7 @@ namespace SharpRefactoring.ContextActions
public string Search(UnknownIdentifierResolveResult rr, IProjectContent pc, List results)
{
SearchAttributesWithName(results, pc, rr.Identifier);
- foreach (IProjectContent content in pc.ReferencedContents)
+ foreach (IProjectContent content in pc.ThreadSafeGetReferencedContents())
SearchAttributesWithName(results, content, rr.Identifier);
return rr.Identifier;
}
diff --git a/src/AddIns/Misc/SharpRefactoring/Project/Src/MenuItemFactories/ResolveAttribute.cs b/src/AddIns/Misc/SharpRefactoring/Project/Src/MenuItemFactories/ResolveAttribute.cs
index 9c1e6aa7f3..2578f994b5 100644
--- a/src/AddIns/Misc/SharpRefactoring/Project/Src/MenuItemFactories/ResolveAttribute.cs
+++ b/src/AddIns/Misc/SharpRefactoring/Project/Src/MenuItemFactories/ResolveAttribute.cs
@@ -42,7 +42,7 @@ namespace SharpRefactoring
var rr = context.ResolveResult as UnknownMethodResolveResult;
SearchAttributesWithName(results, pc, rr.CallName);
- foreach (IProjectContent content in pc.ReferencedContents)
+ foreach (IProjectContent content in pc.ThreadSafeGetReferencedContents())
SearchAttributesWithName(results, content, rr.CallName);
name = rr.CallName;
@@ -52,7 +52,7 @@ namespace SharpRefactoring
var rr = context.ResolveResult as UnknownIdentifierResolveResult;
SearchAttributesWithName(results, pc, rr.Identifier);
- foreach (IProjectContent content in pc.ReferencedContents)
+ foreach (IProjectContent content in pc.ThreadSafeGetReferencedContents())
SearchAttributesWithName(results, content, rr.Identifier);
name = rr.Identifier;
diff --git a/src/AddIns/Misc/SharpRefactoring/Project/Src/MenuItemFactories/ResolveExtensionMethod.cs b/src/AddIns/Misc/SharpRefactoring/Project/Src/MenuItemFactories/ResolveExtensionMethod.cs
index 24cdadfdf2..c37a3afe72 100644
--- a/src/AddIns/Misc/SharpRefactoring/Project/Src/MenuItemFactories/ResolveExtensionMethod.cs
+++ b/src/AddIns/Misc/SharpRefactoring/Project/Src/MenuItemFactories/ResolveExtensionMethod.cs
@@ -38,7 +38,7 @@ namespace SharpRefactoring
SearchAllExtensionMethodsWithName(results, context.ProjectContent, rr.CallName);
- foreach (IProjectContent content in context.ProjectContent.ReferencedContents)
+ foreach (IProjectContent content in context.ProjectContent.ThreadSafeGetReferencedContents())
SearchAllExtensionMethodsWithName(results, content, rr.CallName);
if (!results.Any())
diff --git a/src/Libraries/AvalonEdit/Documentation/ICSharpCode.AvalonEdit.shfbproj b/src/Libraries/AvalonEdit/Documentation/ICSharpCode.AvalonEdit.shfbproj
index ad51dbd9a2..88c48fea83 100644
--- a/src/Libraries/AvalonEdit/Documentation/ICSharpCode.AvalonEdit.shfbproj
+++ b/src/Libraries/AvalonEdit/Documentation/ICSharpCode.AvalonEdit.shfbproj
@@ -33,26 +33,26 @@
.NET 4.0.30319AvalonEdit
- Copyright 2008-2011, Daniel Grunwald
+ Copyright 2008-2012, Daniel GrunwaldPrototype
- 4.1.0.0
+ 4.2.0.0
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
{@HelpFormatOutputPaths}
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{@CachedFrameworkCommentList}
{@CommentFileList}
-
-
+
+
+
+
diff --git a/src/Libraries/AvalonEdit/Documentation/Welcome.aml b/src/Libraries/AvalonEdit/Documentation/Welcome.aml
index a384c467d6..243e435bb0 100644
--- a/src/Libraries/AvalonEdit/Documentation/Welcome.aml
+++ b/src/Libraries/AvalonEdit/Documentation/Welcome.aml
@@ -41,13 +41,13 @@
System requirements
- AvalonEdit requires the
+ There are two versions of AvalonEdit - the normal one requires
- .NET Framework 3.5 SP1
- http://www.microsoft.com/downloads/details.aspx?FamilyID=ab99342f-5d1a-413d-8319-81da479ab0d7&DisplayLang=en
+ .NET Framework 4.0
+ http://msdn.microsoft.com/en-us/library/w0x726c2.aspx_blank
- .
- For compiling AvalonEdit inside Visual Studio 2008, VS08 SP1 is required.
+ or higher; but we also offer a modified version for .NET 3.5 SP1.
+ For compiling AvalonEdit, you will need a C# 4.0 compiler (SharpDevelop 4.x or Visual Studio 2010).
AvalonEdit requires FullTrust and will not run as XBAP.
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs
index de309b7b4b..c91b20e5cd 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs
@@ -23,6 +23,7 @@ namespace ICSharpCode.AvalonEdit.Editing
{
readonly TextArea textArea;
readonly TextView textView;
+ readonly ImeSupport ime;
readonly CaretLayer caretAdorner;
bool visible;
@@ -31,6 +32,7 @@ namespace ICSharpCode.AvalonEdit.Editing
this.textArea = textArea;
this.textView = textArea.TextView;
position = new TextViewPosition(1, 1, 0);
+ ime = new ImeSupport(textArea);
caretAdorner = new CaretLayer(textView);
textView.InsertLayer(caretAdorner, KnownLayer.Caret, LayerInsertionPosition.Replace);
@@ -442,6 +444,7 @@ namespace ICSharpCode.AvalonEdit.Editing
} else {
caretAdorner.Hide();
}
+ ime.UpdateCompositionWindow();
}
}
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/CaretNavigationCommandHandler.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/CaretNavigationCommandHandler.cs
index 036e57f59d..210878a229 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/CaretNavigationCommandHandler.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/CaretNavigationCommandHandler.cs
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Linq;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Input;
@@ -41,21 +42,28 @@ namespace ICSharpCode.AvalonEdit.Editing
const ModifierKeys None = ModifierKeys.None;
const ModifierKeys Ctrl = ModifierKeys.Control;
const ModifierKeys Shift = ModifierKeys.Shift;
+ const ModifierKeys Alt = ModifierKeys.Alt;
AddBinding(EditingCommands.MoveLeftByCharacter, None, Key.Left, OnMoveCaret(CaretMovementType.CharLeft));
AddBinding(EditingCommands.SelectLeftByCharacter, Shift, Key.Left, OnMoveCaretExtendSelection(CaretMovementType.CharLeft));
+ AddBinding(RectangleSelection.BoxSelectLeftByCharacter, Alt | Shift, Key.Left, OnMoveCaretBoxSelection(CaretMovementType.CharLeft));
AddBinding(EditingCommands.MoveRightByCharacter, None, Key.Right, OnMoveCaret(CaretMovementType.CharRight));
AddBinding(EditingCommands.SelectRightByCharacter, Shift, Key.Right, OnMoveCaretExtendSelection(CaretMovementType.CharRight));
+ AddBinding(RectangleSelection.BoxSelectRightByCharacter, Alt | Shift, Key.Right, OnMoveCaretBoxSelection(CaretMovementType.CharRight));
AddBinding(EditingCommands.MoveLeftByWord, Ctrl, Key.Left, OnMoveCaret(CaretMovementType.WordLeft));
AddBinding(EditingCommands.SelectLeftByWord, Ctrl | Shift, Key.Left, OnMoveCaretExtendSelection(CaretMovementType.WordLeft));
+ AddBinding(RectangleSelection.BoxSelectLeftByWord, Ctrl | Alt | Shift, Key.Left, OnMoveCaretBoxSelection(CaretMovementType.WordLeft));
AddBinding(EditingCommands.MoveRightByWord, Ctrl, Key.Right, OnMoveCaret(CaretMovementType.WordRight));
AddBinding(EditingCommands.SelectRightByWord, Ctrl | Shift, Key.Right, OnMoveCaretExtendSelection(CaretMovementType.WordRight));
+ AddBinding(RectangleSelection.BoxSelectRightByWord, Ctrl | Alt | Shift, Key.Right, OnMoveCaretBoxSelection(CaretMovementType.WordRight));
AddBinding(EditingCommands.MoveUpByLine, None, Key.Up, OnMoveCaret(CaretMovementType.LineUp));
AddBinding(EditingCommands.SelectUpByLine, Shift, Key.Up, OnMoveCaretExtendSelection(CaretMovementType.LineUp));
+ AddBinding(RectangleSelection.BoxSelectUpByLine, Alt | Shift, Key.Up, OnMoveCaretBoxSelection(CaretMovementType.LineUp));
AddBinding(EditingCommands.MoveDownByLine, None, Key.Down, OnMoveCaret(CaretMovementType.LineDown));
AddBinding(EditingCommands.SelectDownByLine, Shift, Key.Down, OnMoveCaretExtendSelection(CaretMovementType.LineDown));
+ AddBinding(RectangleSelection.BoxSelectDownByLine, Alt | Shift, Key.Down, OnMoveCaretBoxSelection(CaretMovementType.LineDown));
AddBinding(EditingCommands.MoveDownByPage, None, Key.PageDown, OnMoveCaret(CaretMovementType.PageDown));
AddBinding(EditingCommands.SelectDownByPage, Shift, Key.PageDown, OnMoveCaretExtendSelection(CaretMovementType.PageDown));
@@ -64,8 +72,10 @@ namespace ICSharpCode.AvalonEdit.Editing
AddBinding(EditingCommands.MoveToLineStart, None, Key.Home, OnMoveCaret(CaretMovementType.LineStart));
AddBinding(EditingCommands.SelectToLineStart, Shift, Key.Home, OnMoveCaretExtendSelection(CaretMovementType.LineStart));
+ AddBinding(RectangleSelection.BoxSelectToLineStart, Alt | Shift, Key.Home, OnMoveCaretBoxSelection(CaretMovementType.LineStart));
AddBinding(EditingCommands.MoveToLineEnd, None, Key.End, OnMoveCaret(CaretMovementType.LineEnd));
AddBinding(EditingCommands.SelectToLineEnd, Shift, Key.End, OnMoveCaretExtendSelection(CaretMovementType.LineEnd));
+ AddBinding(RectangleSelection.BoxSelectToLineEnd, Alt | Shift, Key.End, OnMoveCaretBoxSelection(CaretMovementType.LineEnd));
AddBinding(EditingCommands.MoveToDocumentStart, Ctrl, Key.Home, OnMoveCaret(CaretMovementType.DocumentStart));
AddBinding(EditingCommands.SelectToDocumentStart, Ctrl | Shift, Key.Home, OnMoveCaretExtendSelection(CaretMovementType.DocumentStart));
@@ -135,6 +145,31 @@ namespace ICSharpCode.AvalonEdit.Editing
};
}
+ static ExecutedRoutedEventHandler OnMoveCaretBoxSelection(CaretMovementType direction)
+ {
+ return (target, args) => {
+ TextArea textArea = GetTextArea(target);
+ if (textArea != null && textArea.Document != null) {
+ args.Handled = true;
+ // First, convert the selection into a rectangle selection
+ // (this is required so that virtual space gets enabled for the caret movement)
+ if (textArea.Options.EnableRectangularSelection && !(textArea.Selection is RectangleSelection)) {
+ if (textArea.Selection.IsEmpty) {
+ textArea.Selection = new RectangleSelection(textArea, textArea.Caret.Position, textArea.Caret.Position);
+ } else {
+ // Convert normal selection to rectangle selection
+ textArea.Selection = new RectangleSelection(textArea, textArea.Selection.StartPosition, textArea.Caret.Position);
+ }
+ }
+ // Now move the caret and extend the selection
+ TextViewPosition oldPosition = textArea.Caret.Position;
+ MoveCaret(textArea, direction);
+ textArea.Selection = textArea.Selection.StartSelectionOrSetEndpoint(oldPosition, textArea.Caret.Position);
+ textArea.Caret.BringCaretToView();
+ }
+ };
+ }
+
#region Caret movement
static void MoveCaret(TextArea textArea, CaretMovementType direction)
{
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EmptySelection.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EmptySelection.cs
index 17e64ce251..396e51b13a 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EmptySelection.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/EmptySelection.cs
@@ -7,6 +7,7 @@ using System.Runtime.CompilerServices;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Utils;
+using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Editor;
namespace ICSharpCode.AvalonEdit.Editing
@@ -22,6 +23,14 @@ namespace ICSharpCode.AvalonEdit.Editing
return this;
}
+ public override TextViewPosition StartPosition {
+ get { return new TextViewPosition(TextLocation.Empty); }
+ }
+
+ public override TextViewPosition EndPosition {
+ get { return new TextViewPosition(TextLocation.Empty); }
+ }
+
public override ISegment SurroundingSegment {
get { return null; }
}
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/ImeNativeWrapper.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/ImeNativeWrapper.cs
new file mode 100644
index 0000000000..1e81993239
--- /dev/null
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/ImeNativeWrapper.cs
@@ -0,0 +1,178 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Security;
+using System.Windows;
+using System.Windows.Input;
+using System.Windows.Interop;
+using System.Windows.Media;
+using System.Windows.Media.TextFormatting;
+
+using ICSharpCode.AvalonEdit;
+using ICSharpCode.AvalonEdit.Document;
+using ICSharpCode.AvalonEdit.Rendering;
+using ICSharpCode.AvalonEdit.Utils;
+using Draw = System.Drawing;
+
+namespace ICSharpCode.AvalonEdit.Editing
+{
+ ///
+ /// Native API required for IME support.
+ ///
+ static class ImeNativeWrapper
+ {
+ [StructLayout(LayoutKind.Sequential)]
+ struct CompositionForm
+ {
+ public int dwStyle;
+ public POINT ptCurrentPos;
+ public RECT rcArea;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ struct POINT
+ {
+ public int x;
+ public int y;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ struct RECT
+ {
+ public int left;
+ public int top;
+ public int right;
+ public int bottom;
+ }
+
+ [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
+ class LOGFONT
+ {
+ public int lfHeight = 0;
+ public int lfWidth = 0;
+ public int lfEscapement = 0;
+ public int lfOrientation = 0;
+ public int lfWeight = 0;
+ public byte lfItalic = 0;
+ public byte lfUnderline = 0;
+ public byte lfStrikeOut = 0;
+ public byte lfCharSet = 0;
+ public byte lfOutPrecision = 0;
+ public byte lfClipPrecision = 0;
+ public byte lfQuality = 0;
+ public byte lfPitchAndFamily = 0;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)] public string lfFaceName = null;
+ }
+
+ const int CPS_CANCEL = 0x4;
+ const int NI_COMPOSITIONSTR = 0x15;
+ const int GCS_COMPSTR = 0x0008;
+
+ public const int WM_IME_COMPOSITION = 0x10F;
+ public const int WM_INPUTLANGCHANGE = 0x51;
+
+ [DllImport("imm32.dll")]
+ static extern IntPtr ImmAssociateContext(IntPtr hWnd, IntPtr hIMC);
+ [DllImport("imm32.dll")]
+ static extern IntPtr ImmGetContext(IntPtr hWnd);
+ [DllImport("imm32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ static extern bool ImmNotifyIME(IntPtr hIMC, int dwAction, int dwIndex, int dwValue = 0);
+ [DllImport("imm32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ static extern bool ImmReleaseContext(IntPtr hWnd, IntPtr hIMC);
+ [DllImport("imm32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ static extern bool ImmSetCompositionWindow(IntPtr hIMC, ref CompositionForm form);
+ [DllImport("imm32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ static extern bool ImmSetCompositionFont(IntPtr hIMC, ref LOGFONT font);
+ [DllImport("imm32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ static extern bool ImmGetCompositionFont(IntPtr hIMC, out LOGFONT font);
+
+ public static IntPtr AssociateContext(HwndSource source, IntPtr hIMC)
+ {
+ if (source == null)
+ throw new ArgumentNullException("source");
+ return ImmAssociateContext(source.Handle, hIMC);
+ }
+
+ public static bool NotifyIme(IntPtr hIMC)
+ {
+ return ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_CANCEL);
+ }
+
+ public static IntPtr GetContext(HwndSource source)
+ {
+ if (source == null)
+ return IntPtr.Zero;
+ return ImmGetContext(source.Handle);
+ }
+
+ public static bool ReleaseContext(HwndSource source, IntPtr hIMC)
+ {
+ return source != null && hIMC != IntPtr.Zero && ImmReleaseContext(source.Handle, hIMC);
+ }
+
+ public static bool SetCompositionWindow(HwndSource source, IntPtr hIMC, TextArea textArea)
+ {
+ if (textArea == null)
+ throw new ArgumentNullException("textArea");
+ Rect textViewBounds = textArea.TextView.GetBounds();
+ Rect characterBounds = textArea.TextView.GetCharacterBounds(textArea.Caret.Position, source);
+ if (source != null) {
+ Matrix transformToDevice = source.CompositionTarget.TransformToDevice;
+ textViewBounds.Transform(transformToDevice);
+ characterBounds.Transform(transformToDevice);
+ }
+ CompositionForm form = new CompositionForm();
+ form.dwStyle = 0x0020;
+ form.ptCurrentPos.x = (int)Math.Max(characterBounds.Left, textViewBounds.Left);
+ form.ptCurrentPos.y = (int)Math.Max(characterBounds.Top, textViewBounds.Top);
+ form.rcArea.left = (int)textViewBounds.Left;
+ form.rcArea.top = (int)textViewBounds.Top;
+ form.rcArea.right = (int)textViewBounds.Right;
+ form.rcArea.bottom = (int)textViewBounds.Bottom;
+ return ImmSetCompositionWindow(hIMC, ref form);
+ }
+
+ public static bool SetCompositionFont(HwndSource source, IntPtr hIMC, TextArea textArea)
+ {
+ if (textArea == null)
+ throw new ArgumentNullException("textArea");
+// LOGFONT font = new LOGFONT();
+// ImmGetCompositionFont(hIMC, out font);
+ return false;
+ }
+
+ static Rect GetBounds(this TextView textView)
+ {
+ Point location = textView.TranslatePoint(new Point(0,0), textView);
+ return new Rect(location, new Size(textView.ActualWidth, textView.ActualHeight));
+ }
+
+ static readonly Rect EMPTY_RECT = new Rect(0, 0, 0, 0);
+
+ static Rect GetCharacterBounds(this TextView textView, TextViewPosition pos, HwndSource source)
+ {
+ VisualLine vl = textView.GetVisualLine(pos.Line);
+ if (vl == null) return EMPTY_RECT;
+ TextLine line = vl.GetTextLine(pos.VisualColumn);
+ double offset = vl.GetTextLineVisualYPosition(line, VisualYPosition.LineTop) - textView.ScrollOffset.Y;
+ Rect r = line.GetTextBounds(pos.VisualColumn, 1).First().Rectangle;
+ r.Offset(-textView.ScrollOffset.X, offset);
+ // this may happen during layout changes in AvalonDock, so we just return an empty rectangle
+ // in those cases. It should be refreshed immediately.
+ if (!source.RootVisual.IsAncestorOf(textView)) return EMPTY_RECT;
+ Point pointOnRootVisual = textView.TransformToAncestor(source.RootVisual).Transform(r.Location);
+ Point pointOnHwnd = pointOnRootVisual.TransformToDevice(source.RootVisual);
+ r.Location = pointOnHwnd;
+ return r;
+ }
+ }
+}
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/ImeSupport.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/ImeSupport.cs
new file mode 100644
index 0000000000..934c546210
--- /dev/null
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/ImeSupport.cs
@@ -0,0 +1,125 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.ComponentModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Security;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Windows.Interop;
+using System.Windows.Media;
+using System.Windows.Media.TextFormatting;
+using ICSharpCode.AvalonEdit;
+using ICSharpCode.AvalonEdit.Document;
+using ICSharpCode.AvalonEdit.Rendering;
+
+namespace ICSharpCode.AvalonEdit.Editing
+{
+ class ImeSupport : IDisposable
+ {
+ TextArea textArea;
+ IntPtr currentContext;
+ IntPtr previousContext;
+ HwndSource hwndSource;
+
+ public ImeSupport(TextArea textArea)
+ {
+ if (textArea == null)
+ throw new ArgumentNullException("textArea");
+ this.textArea = textArea;
+ InputMethod.SetIsInputMethodSuspended(this.textArea, true);
+ textArea.GotKeyboardFocus += TextAreaGotKeyboardFocus;
+ textArea.LostKeyboardFocus += TextAreaLostKeyboardFocus;
+ textArea.OptionChanged += TextAreaOptionChanged;
+ currentContext = IntPtr.Zero;
+ previousContext = IntPtr.Zero;
+ }
+
+ void TextAreaOptionChanged(object sender, PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName == "EnableImeSupport" && textArea.IsKeyboardFocusWithin) {
+ CreateContext();
+ }
+ }
+
+ public void Dispose()
+ {
+ if (textArea != null) {
+ textArea.GotKeyboardFocus -= TextAreaGotKeyboardFocus;
+ textArea.LostKeyboardFocus -= TextAreaLostKeyboardFocus;
+ textArea = null;
+ }
+ ClearContext();
+ }
+
+ void ClearContext()
+ {
+ if (hwndSource != null) {
+ hwndSource.RemoveHook(WndProc);
+ ImeNativeWrapper.AssociateContext(hwndSource, previousContext);
+ previousContext = IntPtr.Zero;
+ ImeNativeWrapper.ReleaseContext(hwndSource, currentContext);
+ hwndSource = null;
+ currentContext = IntPtr.Zero;
+ }
+ }
+
+ void TextAreaGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
+ {
+ if (this.textArea == null)
+ return;
+ if (e.OriginalSource != this.textArea)
+ return;
+ CreateContext();
+ }
+
+ void CreateContext()
+ {
+ if (this.textArea == null)
+ return;
+ if (!textArea.Options.EnableImeSupport)
+ return;
+ hwndSource = (HwndSource)PresentationSource.FromVisual(this.textArea);
+ if (hwndSource != null) {
+ currentContext = ImeNativeWrapper.GetContext(hwndSource);
+ previousContext = ImeNativeWrapper.AssociateContext(hwndSource, currentContext);
+// ImeNativeWrapper.SetCompositionFont(hwndSource, currentContext, textArea);
+ hwndSource.AddHook(WndProc);
+ }
+ }
+
+ void TextAreaLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
+ {
+ if (e.OriginalSource != this.textArea)
+ return;
+ if (currentContext != IntPtr.Zero)
+ ImeNativeWrapper.NotifyIme(currentContext);
+ ClearContext();
+ }
+
+ IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
+ {
+ switch (msg) {
+ case ImeNativeWrapper.WM_INPUTLANGCHANGE:
+ ClearContext();
+ CreateContext();
+ break;
+ case ImeNativeWrapper.WM_IME_COMPOSITION:
+ UpdateCompositionWindow();
+ break;
+ }
+ return IntPtr.Zero;
+ }
+
+ public void UpdateCompositionWindow()
+ {
+ if (currentContext != IntPtr.Zero && textArea != null) {
+ ImeNativeWrapper.SetCompositionWindow(hwndSource, currentContext, textArea);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/RectangleSelection.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/RectangleSelection.cs
index 75920fdd78..4edc062c80 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/RectangleSelection.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/RectangleSelection.cs
@@ -7,8 +7,9 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
+using System.Windows.Documents;
+using System.Windows.Input;
using System.Windows.Media.TextFormatting;
-
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.AvalonEdit.Utils;
@@ -22,20 +23,70 @@ namespace ICSharpCode.AvalonEdit.Editing
///
public sealed class RectangleSelection : Selection
{
+ #region Commands
+ ///
+ /// Expands the selection left by one character, creating a rectangular selection.
+ /// Key gesture: Alt+Shift+Left
+ ///
+ public static readonly RoutedUICommand BoxSelectLeftByCharacter = Command("BoxSelectLeftByCharacter");
+
+ ///
+ /// Expands the selection right by one character, creating a rectangular selection.
+ /// Key gesture: Alt+Shift+Right
+ ///
+ public static readonly RoutedUICommand BoxSelectRightByCharacter = Command("BoxSelectRightByCharacter");
+
+ ///
+ /// Expands the selection left by one word, creating a rectangular selection.
+ /// Key gesture: Ctrl+Alt+Shift+Left
+ ///
+ public static readonly RoutedUICommand BoxSelectLeftByWord = Command("BoxSelectLeftByWord");
+
+ ///
+ /// Expands the selection left by one word, creating a rectangular selection.
+ /// Key gesture: Ctrl+Alt+Shift+Right
+ ///
+ public static readonly RoutedUICommand BoxSelectRightByWord = Command("BoxSelectRightByWord");
+
+ ///
+ /// Expands the selection up by one line, creating a rectangular selection.
+ /// Key gesture: Alt+Shift+Up
+ ///
+ public static readonly RoutedUICommand BoxSelectUpByLine = Command("BoxSelectUpByLine");
+
+ ///
+ /// Expands the selection up by one line, creating a rectangular selection.
+ /// Key gesture: Alt+Shift+Down
+ ///
+ public static readonly RoutedUICommand BoxSelectDownByLine = Command("BoxSelectDownByLine");
+
+ ///
+ /// Expands the selection to the start of the line, creating a rectangular selection.
+ /// Key gesture: Alt+Shift+Home
+ ///
+ public static readonly RoutedUICommand BoxSelectToLineStart = Command("BoxSelectToLineStart");
+
+ ///
+ /// Expands the selection to the end of the line, creating a rectangular selection.
+ /// Key gesture: Alt+Shift+End
+ ///
+ public static readonly RoutedUICommand BoxSelectToLineEnd = Command("BoxSelectToLineEnd");
+
+ static RoutedUICommand Command(string name)
+ {
+ return new RoutedUICommand(name, name, typeof(RectangleSelection));
+ }
+ #endregion
+
TextDocument document;
readonly int startLine, endLine;
readonly double startXPos, endXPos;
readonly int topLeftOffset, bottomRightOffset;
+ readonly TextViewPosition start, end;
readonly List segments = new List();
- void InitDocument()
- {
- document = textArea.Document;
- if (document == null)
- throw ThrowUtil.NoDocumentAssigned();
- }
-
+ #region Constructors
///
/// Creates a new rectangular selection.
///
@@ -50,6 +101,9 @@ namespace ICSharpCode.AvalonEdit.Editing
CalculateSegments();
this.topLeftOffset = this.segments.First().StartOffset;
this.bottomRightOffset = this.segments.Last().EndOffset;
+
+ this.start = start;
+ this.end = end;
}
private RectangleSelection(TextArea textArea, int startLine, double startXPos, TextViewPosition end)
@@ -63,6 +117,9 @@ namespace ICSharpCode.AvalonEdit.Editing
CalculateSegments();
this.topLeftOffset = this.segments.First().StartOffset;
this.bottomRightOffset = this.segments.Last().EndOffset;
+
+ this.start = GetStart();
+ this.end = end;
}
private RectangleSelection(TextArea textArea, TextViewPosition start, int endLine, double endXPos)
@@ -76,6 +133,16 @@ namespace ICSharpCode.AvalonEdit.Editing
CalculateSegments();
this.topLeftOffset = this.segments.First().StartOffset;
this.bottomRightOffset = this.segments.Last().EndOffset;
+
+ this.start = start;
+ this.end = GetEnd();
+ }
+
+ void InitDocument()
+ {
+ document = textArea.Document;
+ if (document == null)
+ throw ThrowUtil.NoDocumentAssigned();
}
static double GetXPos(TextArea textArea, TextViewPosition pos)
@@ -87,11 +154,43 @@ namespace ICSharpCode.AvalonEdit.Editing
return visualLine.GetTextLineVisualXPosition(textLine, vc);
}
- int GetVisualColumnFromXPos(int line, double xPos)
+ void CalculateSegments()
{
- var vl = textArea.TextView.GetOrConstructVisualLine(textArea.Document.GetLineByNumber(line));
- return vl.GetVisualColumn(new Point(xPos, 0), true);
+ DocumentLine nextLine = document.GetLineByNumber(Math.Min(startLine, endLine));
+ do {
+ VisualLine vl = textArea.TextView.GetOrConstructVisualLine(nextLine);
+ int startVC = vl.GetVisualColumn(new Point(startXPos, 0), true);
+ int endVC = vl.GetVisualColumn(new Point(endXPos, 0), true);
+
+ int baseOffset = vl.FirstDocumentLine.Offset;
+ int startOffset = baseOffset + vl.GetRelativeOffset(startVC);
+ int endOffset = baseOffset + vl.GetRelativeOffset(endVC);
+ segments.Add(new SelectionSegment(startOffset, startVC, endOffset, endVC));
+
+ nextLine = vl.LastDocumentLine.NextLine;
+ } while (nextLine != null && nextLine.LineNumber <= Math.Max(startLine, endLine));
+ }
+
+ TextViewPosition GetStart()
+ {
+ SelectionSegment segment = (startLine < endLine ? segments.First() : segments.Last());
+ if (startXPos < endXPos) {
+ return new TextViewPosition(document.GetLocation(segment.StartOffset), segment.StartVisualColumn);
+ } else {
+ return new TextViewPosition(document.GetLocation(segment.EndOffset), segment.EndVisualColumn);
+ }
+ }
+
+ TextViewPosition GetEnd()
+ {
+ SelectionSegment segment = (startLine < endLine ? segments.Last() : segments.First());
+ if (startXPos < endXPos) {
+ return new TextViewPosition(document.GetLocation(segment.EndOffset), segment.EndVisualColumn);
+ } else {
+ return new TextViewPosition(document.GetLocation(segment.StartOffset), segment.StartVisualColumn);
+ }
}
+ #endregion
///
public override string GetText()
@@ -135,22 +234,14 @@ namespace ICSharpCode.AvalonEdit.Editing
get { return segments; }
}
+ ///
+ public override TextViewPosition StartPosition {
+ get { return start; }
+ }
- void CalculateSegments()
- {
- DocumentLine nextLine = document.GetLineByNumber(Math.Min(startLine, endLine));
- do {
- VisualLine vl = textArea.TextView.GetOrConstructVisualLine(nextLine);
- int startVC = vl.GetVisualColumn(new Point(startXPos, 0), true);
- int endVC = vl.GetVisualColumn(new Point(endXPos, 0), true);
-
- int baseOffset = vl.FirstDocumentLine.Offset;
- int startOffset = baseOffset + vl.GetRelativeOffset(startVC);
- int endOffset = baseOffset + vl.GetRelativeOffset(endVC);
- segments.Add(new SelectionSegment(startOffset, startVC, endOffset, endVC));
-
- nextLine = vl.LastDocumentLine.NextLine;
- } while (nextLine != null && nextLine.LineNumber <= Math.Max(startLine, endLine));
+ ///
+ public override TextViewPosition EndPosition {
+ get { return end; }
}
///
@@ -175,6 +266,12 @@ namespace ICSharpCode.AvalonEdit.Editing
return new RectangleSelection(textArea, startLine, startXPos, endPosition);
}
+ int GetVisualColumnFromXPos(int line, double xPos)
+ {
+ var vl = textArea.TextView.GetOrConstructVisualLine(textArea.Document.GetLineByNumber(line));
+ return vl.GetVisualColumn(new Point(xPos, 0), true);
+ }
+
///
public override Selection UpdateOnDocumentChange(DocumentChangeEventArgs e)
{
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Selection.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Selection.cs
index f6af945b1d..7779aef994 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Selection.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Selection.cs
@@ -65,6 +65,16 @@ namespace ICSharpCode.AvalonEdit.Editing
this.textArea = textArea;
}
+ ///
+ /// Gets the start position of the selection.
+ ///
+ public abstract TextViewPosition StartPosition { get; }
+
+ ///
+ /// Gets the end position of the selection.
+ ///
+ public abstract TextViewPosition EndPosition { get; }
+
///
/// Gets the selected text segments.
///
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SimpleSelection.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SimpleSelection.cs
index 6659bfd8d4..5f053b08ac 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SimpleSelection.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SimpleSelection.cs
@@ -70,18 +70,12 @@ namespace ICSharpCode.AvalonEdit.Editing
}
}
- ///
- /// Gets the start offset.
- ///
- public int StartOffset {
- get { return startOffset; }
+ public override TextViewPosition StartPosition {
+ get { return start; }
}
- ///
- /// Gets the end offset.
- ///
- public int EndOffset {
- get { return endOffset; }
+ public override TextViewPosition EndPosition {
+ get { return end; }
}
///
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/DocumentHighlighter.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/DocumentHighlighter.cs
index 750c6c8451..881d849f0c 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/DocumentHighlighter.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/DocumentHighlighter.cs
@@ -312,11 +312,14 @@ namespace ICSharpCode.AvalonEdit.Highlighting
Debug.Assert(position == firstMatch.Index);
if (firstMatch == endSpanMatch) {
- PopColor(); // pop SpanColor
HighlightingSpan poppedSpan = spanStack.Peek();
+ if (!poppedSpan.SpanColorIncludesEnd)
+ PopColor(); // pop SpanColor
PushColor(poppedSpan.EndColor);
position = firstMatch.Index + firstMatch.Length;
PopColor(); // pop EndColor
+ if (poppedSpan.SpanColorIncludesEnd)
+ PopColor(); // pop SpanColor
spanStack = spanStack.Pop();
currentRuleSet = this.CurrentRuleSet;
//FreeMatchArray(matches);
@@ -342,10 +345,13 @@ namespace ICSharpCode.AvalonEdit.Highlighting
currentRuleSet = this.CurrentRuleSet;
storedMatchArrays.Push(matches);
matches = AllocateMatchArray(currentRuleSet.Spans.Count);
+ if (newSpan.SpanColorIncludesStart)
+ PushColor(newSpan.SpanColor);
PushColor(newSpan.StartColor);
position = firstMatch.Index + firstMatch.Length;
PopColor();
- PushColor(newSpan.SpanColor);
+ if (!newSpan.SpanColorIncludesStart)
+ PushColor(newSpan.SpanColor);
}
endSpanMatch = null;
}
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingSpan.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingSpan.cs
index 4b2f71322b..b9552e5bbb 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingSpan.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingSpan.cs
@@ -43,6 +43,18 @@ namespace ICSharpCode.AvalonEdit.Highlighting
///
public HighlightingColor EndColor { get; set; }
+ ///
+ /// Gets/Sets whether the span color includes the start.
+ /// The default is false.
+ ///
+ public bool SpanColorIncludesStart { get; set; }
+
+ ///
+ /// Gets/Sets whether the span color includes the end.
+ /// The default is false.
+ ///
+ public bool SpanColorIncludesEnd { get; set; }
+
///
public override string ToString()
{
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/PowerShell.xshd b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/PowerShell.xshd
new file mode 100644
index 0000000000..ee6fec4c8d
--- /dev/null
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/PowerShell.xshd
@@ -0,0 +1,146 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ \#
+
+
+
+ <\#
+ \#>
+
+
+
+ "
+ "
+
+
+
+
+
+
+
+ '
+ '
+
+
+
+
+
+
+
+ @"
+ "@
+
+
+
+
+
+
+
+ while
+ param
+ end
+ define
+ else
+ from
+ foreach
+ var
+ dynamicparam
+ filter
+ dp
+ until
+ for
+ exit
+ switch
+ process
+ begin
+ elseif
+ if
+ in
+ data
+ class
+ using
+ function
+
+
+
+ catch
+ finally
+ throw
+ trap
+ try
+
+
+
+ break
+ continue
+ return
+
+
+
+ class
+
+
+
+ -not
+ -band
+ -bor
+ -replace
+ -ireplace
+ -creplace
+ -and
+ -or
+ -is
+ -isnot
+ -as
+ -lt
+ -le
+ -gt
+ -ge
+ -eq
+ -ne
+ -contains
+ -notcontains
+ -like
+ -notlike
+ -match
+ -notmatch
+
+
+
+ \$[\d\w_]+
+
+
+
+ [\w]+-[\w]+
+
+
+
+
+ \b0[xX][0-9a-fA-F]+ # hex number
+ |
+ ( \b\d+(\.[0-9]+)? #number with optional floating point
+ | \.[0-9]+ #or just starting with floating point
+ )
+ ([eE][+-]?[0-9]+)? # optional exponent
+
+
+
+ [?,.;()\[\]{}+\-/%*<>^+~!|&]+
+
+
+
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/Resources.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/Resources.cs
index 594417e04b..07827576cb 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/Resources.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/Resources.cs
@@ -33,13 +33,14 @@ namespace ICSharpCode.AvalonEdit.Highlighting
hlm.RegisterHighlighting("C++", new[] { ".c", ".h", ".cc", ".cpp" , ".hpp" }, "CPP-Mode.xshd");
hlm.RegisterHighlighting("Java", new[] { ".java" }, "Java-Mode.xshd");
hlm.RegisterHighlighting("Patch", new[] { ".patch", ".diff" }, "Patch-Mode.xshd");
+ hlm.RegisterHighlighting("PowerShell", new[] { ".ps1", ".psm1", ".psd1" }, "PowerShell.xshd");
hlm.RegisterHighlighting("PHP", new[] { ".php" }, "PHP-Mode.xshd");
hlm.RegisterHighlighting("TeX", new[] { ".tex" }, "Tex-Mode.xshd");
hlm.RegisterHighlighting("VBNET", new[] { ".vb" }, "VBNET-Mode.xshd");
hlm.RegisterHighlighting("XML", (".xml;.xsl;.xslt;.xsd;.manifest;.config;.addin;" +
".xshd;.wxs;.wxi;.wxl;.proj;.csproj;.vbproj;.ilproj;" +
".booproj;.build;.xfrm;.targets;.xaml;.xpt;" +
- ".xft;.map;.wsdl;.disco").Split(';'),
+ ".xft;.map;.wsdl;.disco;.ps1xml;.nuspec").Split(';'),
"XML-Mode.xshd");
}
}
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/XML-Mode.xshd b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/XML-Mode.xshd
index f77b72d8ed..8f0bdef769 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/XML-Mode.xshd
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/XML-Mode.xshd
@@ -1,4 +1,4 @@
-
+
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/XmlHighlightingDefinition.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/XmlHighlightingDefinition.cs
index a0525cc1e7..d8bae25056 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/XmlHighlightingDefinition.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Xshd/XmlHighlightingDefinition.cs
@@ -317,22 +317,11 @@ namespace ICSharpCode.AvalonEdit.Highlighting.Xshd
StartExpression = CreateRegex(span, span.BeginRegex, span.BeginRegexType),
EndExpression = CreateRegex(span, endRegex, span.EndRegexType),
RuleSet = GetRuleSet(span, span.RuleSetReference),
- StartColor = MergeColor(wholeSpanColor, GetColor(span, span.BeginColorReference)),
+ StartColor = GetColor(span, span.BeginColorReference),
SpanColor = wholeSpanColor,
- EndColor = MergeColor(wholeSpanColor, GetColor(span, span.EndColorReference)),
- };
- }
-
- static HighlightingColor MergeColor(HighlightingColor baseColor, HighlightingColor newColor)
- {
- if (baseColor == null)
- return newColor;
- if (newColor == null)
- return baseColor;
- return new HighlightingColor {
- Foreground = newColor.Foreground ?? baseColor.Foreground,
- FontWeight = newColor.FontWeight ?? baseColor.FontWeight,
- FontStyle = newColor.FontStyle ?? baseColor.FontStyle,
+ EndColor = GetColor(span, span.EndColorReference),
+ SpanColorIncludesStart = true,
+ SpanColorIncludesEnd = true
};
}
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj
index b0621b4ee7..f3465f2edc 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/ICSharpCode.AvalonEdit.csproj
@@ -146,7 +146,9 @@
Selection.cs
+
+
@@ -440,4 +442,7 @@
+
+
+
\ No newline at end of file
diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs
index 6572f37f69..cd9d13d3da 100644
--- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs
+++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditorOptions.cs
@@ -381,5 +381,22 @@ namespace ICSharpCode.AvalonEdit
}
}
}
+
+ bool enableImeSupport = true;
+
+ ///
+ /// Gets/Sets whether the support for Input Method Editors (IME)
+ /// for non-alphanumeric scripts (Chinese, Japanese, Korean, ...) is enabled.
+ ///
+ [DefaultValue(true)]
+ public virtual bool EnableImeSupport {
+ get { return enableImeSupport; }
+ set {
+ if (enableImeSupport != value) {
+ enableImeSupport = value;
+ OnPropertyChanged("EnableImeSupport");
+ }
+ }
+ }
}
}
diff --git a/src/Libraries/ICSharpCode.Decompiler/Ast/AstBuilder.cs b/src/Libraries/ICSharpCode.Decompiler/Ast/AstBuilder.cs
index bf647b379d..fc288d80fd 100644
--- a/src/Libraries/ICSharpCode.Decompiler/Ast/AstBuilder.cs
+++ b/src/Libraries/ICSharpCode.Decompiler/Ast/AstBuilder.cs
@@ -157,15 +157,10 @@ namespace ICSharpCode.Decompiler.Ast
if (!transformationsHaveRun)
RunTransformations();
- astCompileUnit.AcceptVisitor(new InsertParenthesesVisitor { InsertParenthesesForReadability = true }, null);
+ astCompileUnit.AcceptVisitor(new InsertParenthesesVisitor { InsertParenthesesForReadability = true });
var outputFormatter = new TextOutputFormatter(output);
- var formattingPolicy = new CSharpFormattingOptions();
- // disable whitespace in front of parentheses:
- formattingPolicy.SpaceBeforeMethodCallParentheses = false;
- formattingPolicy.SpaceBeforeMethodDeclarationParentheses = false;
- formattingPolicy.SpaceBeforeConstructorDeclarationParentheses = false;
- formattingPolicy.SpaceBeforeDelegateDeclarationParentheses = false;
- astCompileUnit.AcceptVisitor(new CSharpOutputVisitor(outputFormatter, formattingPolicy), null);
+ var formattingPolicy = context.Settings.CSharpFormattingOptions;
+ astCompileUnit.AcceptVisitor(new CSharpOutputVisitor(outputFormatter, formattingPolicy));
}
public void AddAssembly(AssemblyDefinition assemblyDefinition, bool onlyAssemblyLevel = false)
@@ -185,7 +180,7 @@ namespace ICSharpCode.Decompiler.Ast
}
}
}
- }, AttributedNode.AttributeRole);
+ }, EntityDeclaration.AttributeRole);
}
ConvertCustomAttributes(astCompileUnit, assemblyDefinition, "assembly");
@@ -225,7 +220,7 @@ namespace ICSharpCode.Decompiler.Ast
Arguments = { forwardedType }
}
}
- }, AttributedNode.AttributeRole);
+ }, EntityDeclaration.AttributeRole);
}
}
}
@@ -283,7 +278,7 @@ namespace ICSharpCode.Decompiler.Ast
///
///
/// TypeDeclaration or DelegateDeclaration.
- public AttributedNode CreateType(TypeDefinition typeDef)
+ public EntityDeclaration CreateType(TypeDefinition typeDef)
{
// create type
TypeDefinition oldCurrentType = context.CurrentType;
@@ -313,7 +308,7 @@ namespace ICSharpCode.Decompiler.Ast
astType.TypeParameters.AddRange(MakeTypeParameters(genericParameters));
astType.Constraints.AddRange(MakeConstraints(genericParameters));
- AttributedNode result = astType;
+ EntityDeclaration result = astType;
if (typeDef.IsEnum) {
long expectedEnumMemberValue = 0;
bool forcePrintingInitializers = IsFlagsEnum(typeDef);
@@ -321,7 +316,7 @@ namespace ICSharpCode.Decompiler.Ast
if (!field.IsStatic) {
// the value__ field
if (field.FieldType != typeDef.Module.TypeSystem.Int32) {
- astType.AddChild(ConvertType(field.FieldType), TypeDeclaration.BaseTypeRole);
+ astType.AddChild(ConvertType(field.FieldType), Roles.BaseType);
}
} else {
EnumMemberDeclaration enumMember = new EnumMemberDeclaration();
@@ -332,7 +327,7 @@ namespace ICSharpCode.Decompiler.Ast
enumMember.AddChild(new PrimitiveExpression(field.Constant), EnumMemberDeclaration.InitializerRole);
}
expectedEnumMemberValue = memberValue + 1;
- astType.AddChild(enumMember, TypeDeclaration.MemberRole);
+ astType.AddChild(enumMember, Roles.TypeMemberRole);
}
}
} else if (typeDef.BaseType != null && typeDef.BaseType.FullName == "System.MulticastDelegate") {
@@ -354,10 +349,10 @@ namespace ICSharpCode.Decompiler.Ast
} else {
// Base type
if (typeDef.BaseType != null && !typeDef.IsValueType && typeDef.BaseType.FullName != "System.Object") {
- astType.AddChild(ConvertType(typeDef.BaseType), TypeDeclaration.BaseTypeRole);
+ astType.AddChild(ConvertType(typeDef.BaseType), Roles.BaseType);
}
foreach (var i in typeDef.Interfaces)
- astType.AddChild(ConvertType(i), TypeDeclaration.BaseTypeRole);
+ astType.AddChild(ConvertType(i), Roles.BaseType);
AddTypeMembers(astType, typeDef);
@@ -726,18 +721,18 @@ namespace ICSharpCode.Decompiler.Ast
continue;
var nestedType = CreateType(nestedTypeDef);
SetNewModifier(nestedType);
- astType.AddChild(nestedType, TypeDeclaration.MemberRole);
+ astType.AddChild(nestedType, Roles.TypeMemberRole);
}
// Add fields
foreach(FieldDefinition fieldDef in typeDef.Fields) {
if (MemberIsHidden(fieldDef, context.Settings)) continue;
- astType.AddChild(CreateField(fieldDef), TypeDeclaration.MemberRole);
+ astType.AddChild(CreateField(fieldDef), Roles.TypeMemberRole);
}
// Add events
foreach(EventDefinition eventDef in typeDef.Events) {
- astType.AddChild(CreateEvent(eventDef), TypeDeclaration.MemberRole);
+ astType.AddChild(CreateEvent(eventDef), Roles.TypeMemberRole);
}
// Add properties
@@ -756,7 +751,7 @@ namespace ICSharpCode.Decompiler.Ast
}
}
- AttributedNode CreateMethod(MethodDefinition methodDef)
+ EntityDeclaration CreateMethod(MethodDefinition methodDef)
{
MethodDeclaration astMethod = new MethodDeclaration();
astMethod.AddAnnotation(methodDef);
@@ -860,7 +855,7 @@ namespace ICSharpCode.Decompiler.Ast
astMethod.Body = CreateMethodBody(methodDef, astMethod.Parameters);
ConvertAttributes(astMethod, methodDef);
if (methodDef.IsStatic && methodDef.DeclaringType.IsBeforeFieldInit && !astMethod.Body.IsNull) {
- astMethod.Body.InsertChildAfter(null, new Comment(" Note: this type is marked as 'beforefieldinit'."), AstNode.Roles.Comment);
+ astMethod.Body.InsertChildAfter(null, new Comment(" Note: this type is marked as 'beforefieldinit'."), Roles.Comment);
}
return astMethod;
}
@@ -878,7 +873,7 @@ namespace ICSharpCode.Decompiler.Ast
return m & ~Modifiers.Private;
}
- MemberDeclaration CreateProperty(PropertyDefinition propDef)
+ EntityDeclaration CreateProperty(PropertyDefinition propDef)
{
PropertyDeclaration astProp = new PropertyDeclaration();
astProp.AddAnnotation(propDef);
@@ -937,7 +932,7 @@ namespace ICSharpCode.Decompiler.Ast
}
ConvertCustomAttributes(astProp, propDef);
- MemberDeclaration member = astProp;
+ EntityDeclaration member = astProp;
if(propDef.IsIndexer())
member = ConvertPropertyToIndexer(astProp, propDef);
if(!accessor.HasOverrides && !accessor.DeclaringType.IsInterface)
@@ -960,7 +955,7 @@ namespace ICSharpCode.Decompiler.Ast
return astIndexer;
}
- AttributedNode CreateEvent(EventDefinition eventDef)
+ EntityDeclaration CreateEvent(EventDefinition eventDef)
{
if (eventDef.AddMethod != null && eventDef.AddMethod.IsAbstract) {
// An abstract event cannot be custom
@@ -1018,7 +1013,7 @@ namespace ICSharpCode.Decompiler.Ast
FieldDeclaration astField = new FieldDeclaration();
astField.AddAnnotation(fieldDef);
VariableInitializer initializer = new VariableInitializer(CleanName(fieldDef.Name));
- astField.AddChild(initializer, FieldDeclaration.Roles.Variable);
+ astField.AddChild(initializer, Roles.Variable);
astField.ReturnType = ConvertType(fieldDef.FieldType, fieldDef);
astField.Modifiers = ConvertModifiers(fieldDef);
if (fieldDef.HasConstant) {
@@ -1098,7 +1093,7 @@ namespace ICSharpCode.Decompiler.Ast
}
#region ConvertAttributes
- void ConvertAttributes(AttributedNode attributedNode, TypeDefinition typeDefinition)
+ void ConvertAttributes(EntityDeclaration attributedNode, TypeDefinition typeDefinition)
{
ConvertCustomAttributes(attributedNode, typeDefinition);
ConvertSecurityAttributes(attributedNode, typeDefinition);
@@ -1154,7 +1149,7 @@ namespace ICSharpCode.Decompiler.Ast
#endregion
}
- void ConvertAttributes(AttributedNode attributedNode, MethodDefinition methodDefinition)
+ void ConvertAttributes(EntityDeclaration attributedNode, MethodDefinition methodDefinition)
{
ConvertCustomAttributes(attributedNode, methodDefinition);
ConvertSecurityAttributes(attributedNode, methodDefinition);
@@ -1254,7 +1249,7 @@ namespace ICSharpCode.Decompiler.Ast
ConvertAttributes(attributedNode, methodDefinition.MethodReturnType, methodDefinition.Module);
}
- void ConvertAttributes(AttributedNode attributedNode, MethodReturnType methodReturnType, ModuleDefinition module)
+ void ConvertAttributes(EntityDeclaration attributedNode, MethodReturnType methodReturnType, ModuleDefinition module)
{
ConvertCustomAttributes(attributedNode, methodReturnType, "return");
if (methodReturnType.HasMarshalInfo) {
@@ -1263,7 +1258,7 @@ namespace ICSharpCode.Decompiler.Ast
}
}
- internal static void ConvertAttributes(AttributedNode attributedNode, FieldDefinition fieldDefinition, string attributeTarget = null)
+ internal static void ConvertAttributes(EntityDeclaration attributedNode, FieldDefinition fieldDefinition, string attributeTarget = null)
{
ConvertCustomAttributes(attributedNode, fieldDefinition);
@@ -1402,14 +1397,14 @@ namespace ICSharpCode.Decompiler.Ast
var section = new AttributeSection();
section.AttributeTarget = attributeTarget;
section.Attributes.Add(attribute);
- attributedNode.AddChild(section, AttributedNode.AttributeRole);
+ attributedNode.AddChild(section, EntityDeclaration.AttributeRole);
}
} else if (attributes.Count > 0) {
// use single section for all attributes
var section = new AttributeSection();
section.AttributeTarget = attributeTarget;
section.Attributes.AddRange(attributes);
- attributedNode.AddChild(section, AttributedNode.AttributeRole);
+ attributedNode.AddChild(section, EntityDeclaration.AttributeRole);
}
}
}
@@ -1462,14 +1457,14 @@ namespace ICSharpCode.Decompiler.Ast
var section = new AttributeSection();
section.AttributeTarget = attributeTarget;
section.Attributes.Add(attribute);
- attributedNode.AddChild(section, AttributedNode.AttributeRole);
+ attributedNode.AddChild(section, EntityDeclaration.AttributeRole);
}
} else if (attributes.Count > 0) {
// use single section for all attributes
var section = new AttributeSection();
section.AttributeTarget = attributeTarget;
section.Attributes.AddRange(attributes);
- attributedNode.AddChild(section, AttributedNode.AttributeRole);
+ attributedNode.AddChild(section, EntityDeclaration.AttributeRole);
}
}
@@ -1594,7 +1589,7 @@ namespace ICSharpCode.Decompiler.Ast
/// Sets new modifier if the member hides some other member from a base type.
///
/// The node of the member which new modifier state should be determined.
- static void SetNewModifier(AttributedNode member)
+ static void SetNewModifier(EntityDeclaration member)
{
try {
bool addNewModifier = false;
@@ -1614,7 +1609,7 @@ namespace ICSharpCode.Decompiler.Ast
}
}
- private static bool HidesBaseMember(AttributedNode member)
+ private static bool HidesBaseMember(EntityDeclaration member)
{
var memberDefinition = member.Annotation();
bool addNewModifier = false;
diff --git a/src/Libraries/ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs b/src/Libraries/ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs
index 7b051c50df..5de5b0ba5a 100644
--- a/src/Libraries/ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs
+++ b/src/Libraries/ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs
@@ -543,12 +543,15 @@ namespace ICSharpCode.Decompiler.Ast
}
return arg1;
}
- case ILCode.Castclass:
- return arg1.CastTo(operandAsTypeRef);
case ILCode.Unbox_Any:
// unboxing does not require a cast if the argument was an isinst instruction
if (arg1 is AsExpression && byteCode.Arguments[0].Code == ILCode.Isinst && TypeAnalysis.IsSameType(operand as TypeReference, byteCode.Arguments[0].Operand as TypeReference))
return arg1;
+ else
+ goto case ILCode.Castclass;
+ case ILCode.Castclass:
+ if ((byteCode.Arguments[0].InferredType != null && byteCode.Arguments[0].InferredType.IsGenericParameter) || ((Cecil.TypeReference)operand).IsGenericParameter)
+ return arg1.CastTo(new PrimitiveType("object")).CastTo(operandAsTypeRef);
else
return arg1.CastTo(operandAsTypeRef);
case ILCode.Isinst:
diff --git a/src/Libraries/ICSharpCode.Decompiler/Ast/CommentStatement.cs b/src/Libraries/ICSharpCode.Decompiler/Ast/CommentStatement.cs
index 0940c6c5c7..6837b2418f 100644
--- a/src/Libraries/ICSharpCode.Decompiler/Ast/CommentStatement.cs
+++ b/src/Libraries/ICSharpCode.Decompiler/Ast/CommentStatement.cs
@@ -38,6 +38,15 @@ namespace ICSharpCode.Decompiler.Ast
this.comment = comment;
}
+ public override void AcceptVisitor(IAstVisitor visitor)
+ {
+ }
+
+ public override T AcceptVisitor(IAstVisitor visitor)
+ {
+ return default(T);
+ }
+
public override S AcceptVisitor(IAstVisitor visitor, T data)
{
return default(S);
diff --git a/src/Libraries/ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs b/src/Libraries/ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs
index 26bd784e2f..85fef513ee 100644
--- a/src/Libraries/ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs
+++ b/src/Libraries/ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs
@@ -82,7 +82,7 @@ namespace ICSharpCode.Decompiler.Ast
{
AstNode node = nodeStack.Peek();
MemberReference memberRef = node.Annotation();
- if (memberRef == null && node.Role == AstNode.Roles.TargetExpression && (node.Parent is InvocationExpression || node.Parent is ObjectCreateExpression)) {
+ if (memberRef == null && node.Role == Roles.TargetExpression && (node.Parent is InvocationExpression || node.Parent is ObjectCreateExpression)) {
memberRef = node.Parent.Annotation();
}
return memberRef;
@@ -168,7 +168,7 @@ namespace ICSharpCode.Decompiler.Ast
// Attach member reference to token only if there's no identifier in the current node.
MemberReference memberRef = GetCurrentMemberReference();
var node = nodeStack.Peek();
- if (memberRef != null && node.GetChildByRole(AstNode.Roles.Identifier).IsNull)
+ if (memberRef != null && node.GetChildByRole(Roles.Identifier).IsNull)
output.WriteReference(token, memberRef);
else
output.Write(token);
@@ -282,7 +282,7 @@ namespace ICSharpCode.Decompiler.Ast
nodeStack.Push(node);
startLocations.Push(output.Location);
- if (node is AttributedNode && node.GetChildByRole(AstNode.Roles.Identifier).IsNull)
+ if (node is EntityDeclaration && node.Annotation() != null && node.GetChildByRole(Roles.Identifier).IsNull)
output.WriteDefinition("", node.Annotation(), false);
MemberMapping mapping = node.Annotation();
@@ -330,15 +330,7 @@ namespace ICSharpCode.Decompiler.Ast
private static bool IsDefinition(AstNode node)
{
- return
- node is FieldDeclaration ||
- node is ConstructorDeclaration ||
- node is DestructorDeclaration ||
- node is EventDeclaration ||
- node is DelegateDeclaration ||
- node is OperatorDeclaration||
- node is MemberDeclaration ||
- node is TypeDeclaration;
+ return node is EntityDeclaration;
}
}
}
diff --git a/src/Libraries/ICSharpCode.Decompiler/Ast/Transforms/ConvertConstructorCallIntoInitializer.cs b/src/Libraries/ICSharpCode.Decompiler/Ast/Transforms/ConvertConstructorCallIntoInitializer.cs
index 4976a759bb..36811c1852 100644
--- a/src/Libraries/ICSharpCode.Decompiler/Ast/Transforms/ConvertConstructorCallIntoInitializer.cs
+++ b/src/Libraries/ICSharpCode.Decompiler/Ast/Transforms/ConvertConstructorCallIntoInitializer.cs
@@ -123,7 +123,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
if (allSame) {
foreach (var ctor in instanceCtorsNotChainingWithThis)
ctor.Body.First().Remove();
- fieldOrEventDecl.GetChildrenByRole(AstNode.Roles.Variable).Single().Initializer = initializer.Detach();
+ fieldOrEventDecl.GetChildrenByRole(Roles.Variable).Single().Initializer = initializer.Detach();
}
} while (allSame);
}
diff --git a/src/Libraries/ICSharpCode.Decompiler/Ast/Transforms/IntroduceUnsafeModifier.cs b/src/Libraries/ICSharpCode.Decompiler/Ast/Transforms/IntroduceUnsafeModifier.cs
index dc7e7f1a5a..43548e38d4 100644
--- a/src/Libraries/ICSharpCode.Decompiler/Ast/Transforms/IntroduceUnsafeModifier.cs
+++ b/src/Libraries/ICSharpCode.Decompiler/Ast/Transforms/IntroduceUnsafeModifier.cs
@@ -38,8 +38,8 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
for (AstNode child = node.FirstChild; child != null; child = child.NextSibling) {
result |= child.AcceptVisitor(this, data);
}
- if (result && node is AttributedNode && !(node is Accessor)) {
- ((AttributedNode)node).Modifiers |= Modifiers.Unsafe;
+ if (result && node is EntityDeclaration && !(node is Accessor)) {
+ ((EntityDeclaration)node).Modifiers |= Modifiers.Unsafe;
return false;
}
return result;
diff --git a/src/Libraries/ICSharpCode.Decompiler/Ast/Transforms/ReplaceMethodCallsWithOperators.cs b/src/Libraries/ICSharpCode.Decompiler/Ast/Transforms/ReplaceMethodCallsWithOperators.cs
index 4561da8176..6a3f8f9743 100644
--- a/src/Libraries/ICSharpCode.Decompiler/Ast/Transforms/ReplaceMethodCallsWithOperators.cs
+++ b/src/Libraries/ICSharpCode.Decompiler/Ast/Transforms/ReplaceMethodCallsWithOperators.cs
@@ -140,7 +140,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms
invocationExpression.ReplaceWith(arguments[0]);
return;
}
- if (methodRef.Name == "op_True" && arguments.Length == 1 && invocationExpression.Role == AstNode.Roles.Condition) {
+ if (methodRef.Name == "op_True" && arguments.Length == 1 && invocationExpression.Role == Roles.Condition) {
invocationExpression.ReplaceWith(arguments[0]);
return;
}
diff --git a/src/Libraries/ICSharpCode.Decompiler/CecilExtensions.cs b/src/Libraries/ICSharpCode.Decompiler/CecilExtensions.cs
index 82b67a07f4..cc047e09cd 100644
--- a/src/Libraries/ICSharpCode.Decompiler/CecilExtensions.cs
+++ b/src/Libraries/ICSharpCode.Decompiler/CecilExtensions.cs
@@ -133,6 +133,8 @@ namespace ICSharpCode.Decompiler
///
public static int GetEndOffset(this Instruction inst)
{
+ if (inst == null)
+ throw new ArgumentNullException("inst");
return inst.Offset + inst.GetSize();
}
diff --git a/src/Libraries/ICSharpCode.Decompiler/DecompilerSettings.cs b/src/Libraries/ICSharpCode.Decompiler/DecompilerSettings.cs
index 05a598520e..435124491c 100644
--- a/src/Libraries/ICSharpCode.Decompiler/DecompilerSettings.cs
+++ b/src/Libraries/ICSharpCode.Decompiler/DecompilerSettings.cs
@@ -18,6 +18,7 @@
using System;
using System.ComponentModel;
+using ICSharpCode.NRefactory.CSharp;
namespace ICSharpCode.Decompiler
{
@@ -271,6 +272,26 @@ namespace ICSharpCode.Decompiler
}
#endregion
+ CSharpFormattingOptions csharpFormattingOptions;
+
+ public CSharpFormattingOptions CSharpFormattingOptions {
+ get {
+ if (csharpFormattingOptions == null) {
+ csharpFormattingOptions = FormattingOptionsFactory.CreateAllman();
+ csharpFormattingOptions.IndentSwitchBody = false;
+ }
+ return csharpFormattingOptions;
+ }
+ set {
+ if (value == null)
+ throw new ArgumentNullException();
+ if (csharpFormattingOptions != value) {
+ csharpFormattingOptions = value;
+ OnPropertyChanged("CSharpFormattingOptions");
+ }
+ }
+ }
+
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
@@ -283,6 +304,8 @@ namespace ICSharpCode.Decompiler
public DecompilerSettings Clone()
{
DecompilerSettings settings = (DecompilerSettings)MemberwiseClone();
+ if (csharpFormattingOptions != null)
+ settings.csharpFormattingOptions = csharpFormattingOptions.Clone();
settings.PropertyChanged = null;
return settings;
}
diff --git a/src/Libraries/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs b/src/Libraries/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs
index 413234e77f..675d9e28a0 100644
--- a/src/Libraries/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs
+++ b/src/Libraries/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs
@@ -809,6 +809,7 @@ namespace ICSharpCode.Decompiler.Disassembler
{ TypeAttributes.SpecialName, "specialname" },
{ TypeAttributes.Import, "import" },
{ TypeAttributes.Serializable, "serializable" },
+ { TypeAttributes.WindowsRuntime, "windowsruntime" },
{ TypeAttributes.BeforeFieldInit, "beforefieldinit" },
{ TypeAttributes.HasSecurity, null },
};
@@ -1075,7 +1076,10 @@ namespace ICSharpCode.Decompiler.Disassembler
public void WriteAssemblyHeader(AssemblyDefinition asm)
{
- output.Write(".assembly " + DisassemblerHelpers.Escape(asm.Name.Name));
+ output.Write(".assembly ");
+ if (asm.Name.IsWindowsRuntime)
+ output.Write("windowsruntime ");
+ output.Write(DisassemblerHelpers.Escape(asm.Name.Name));
OpenBlock(false);
WriteAttributes(asm.CustomAttributes);
WriteSecurityDeclarations(asm);
@@ -1103,7 +1107,10 @@ namespace ICSharpCode.Decompiler.Disassembler
output.WriteLine(".module extern {0}", DisassemblerHelpers.Escape(mref.Name));
}
foreach (var aref in module.AssemblyReferences) {
- output.Write(".assembly extern {0}", DisassemblerHelpers.Escape(aref.Name));
+ output.Write(".assembly extern ");
+ if (aref.IsWindowsRuntime)
+ output.Write("windowsruntime ");
+ output.Write(DisassemblerHelpers.Escape(aref.Name));
OpenBlock(false);
if (aref.PublicKeyToken != null) {
output.Write(".publickeytoken = ");
diff --git a/src/Libraries/ICSharpCode.Decompiler/FlowAnalysis/ControlFlowNode.cs b/src/Libraries/ICSharpCode.Decompiler/FlowAnalysis/ControlFlowNode.cs
index 606b43286b..cab507bc95 100644
--- a/src/Libraries/ICSharpCode.Decompiler/FlowAnalysis/ControlFlowNode.cs
+++ b/src/Libraries/ICSharpCode.Decompiler/FlowAnalysis/ControlFlowNode.cs
@@ -253,8 +253,11 @@ namespace ICSharpCode.Decompiler.FlowAnalysis
StringWriter writer = new StringWriter();
switch (NodeType) {
case ControlFlowNodeType.Normal:
- int endOffset = End.GetEndOffset();
- writer.Write("Block #{0}: IL_{1:x4} to IL_{2:x4}", BlockIndex, Start.Offset, endOffset);
+ writer.Write("Block #{0}", BlockIndex);
+ if (Start != null)
+ writer.Write(": IL_{0:x4}", Start.Offset);
+ if (End != null)
+ writer.Write(" to IL_{0:x4}", End.GetEndOffset());
break;
case ControlFlowNodeType.CatchHandler:
case ControlFlowNodeType.FinallyOrFaultHandler:
@@ -277,6 +280,10 @@ namespace ICSharpCode.Decompiler.FlowAnalysis
writer.WriteLine();
Disassembler.DisassemblerHelpers.WriteTo(inst, new PlainTextOutput(writer));
}
+ if (UserData != null) {
+ writer.WriteLine();
+ writer.Write(UserData.ToString());
+ }
return writer.ToString();
}
diff --git a/src/Libraries/ICSharpCode.Decompiler/ILAst/LoopsAndConditions.cs b/src/Libraries/ICSharpCode.Decompiler/ILAst/LoopsAndConditions.cs
index e5409a2e58..32095b03eb 100644
--- a/src/Libraries/ICSharpCode.Decompiler/ILAst/LoopsAndConditions.cs
+++ b/src/Libraries/ICSharpCode.Decompiler/ILAst/LoopsAndConditions.cs
@@ -101,7 +101,7 @@ namespace ICSharpCode.Decompiler.ILAst
// Find all branches
foreach(ILLabel target in node.GetSelfAndChildrenRecursive(e => e.IsBranch()).SelectMany(e => e.GetBranchTargets())) {
ControlFlowNode destination;
- // Labels which are out of out scope will not be int the collection
+ // Labels which are out of out scope will not be in the collection
// Insert self edge only if we are sure we are a loop
if (labelToCfNode.TryGetValue(target, out destination) && (destination != source || target == node.Body.FirstOrDefault())) {
ControlFlowEdge edge = new ControlFlowEdge(source, destination, JumpType.Normal);
@@ -228,15 +228,10 @@ namespace ICSharpCode.Decompiler.ILAst
// Do not modify entry data
scope = new HashSet(scope);
- HashSet agenda = new HashSet();
- agenda.Add(entryNode);
- while(agenda.Any()) {
- ControlFlowNode node = agenda.First();
- // Attempt for a good order
- while(agenda.Contains(node.ImmediateDominator)) {
- node = node.ImmediateDominator;
- }
- agenda.Remove(node);
+ Stack agenda = new Stack();
+ agenda.Push(entryNode);
+ while(agenda.Count > 0) {
+ ControlFlowNode node = agenda.Pop();
// Find a block that represents a simple condition
if (scope.Contains(node)) {
@@ -364,18 +359,12 @@ namespace ICSharpCode.Decompiler.ILAst
labelToCfNode.TryGetValue(falseLabel, out falseTarget);
// Pull in the conditional code
- HashSet frontiers = new HashSet();
- if (trueTarget != null)
- frontiers.UnionWith(trueTarget.DominanceFrontier.Except(new [] { trueTarget }));
- if (falseTarget != null)
- frontiers.UnionWith(falseTarget.DominanceFrontier.Except(new [] { falseTarget }));
-
- if (trueTarget != null && !frontiers.Contains(trueTarget)) {
+ if (trueTarget != null && HasSingleEdgeEnteringBlock(trueTarget)) {
HashSet content = FindDominatedNodes(scope, trueTarget);
scope.ExceptWith(content);
ilCond.TrueBlock.Body.AddRange(FindConditions(content, trueTarget));
}
- if (falseTarget != null && !frontiers.Contains(falseTarget)) {
+ if (falseTarget != null && HasSingleEdgeEnteringBlock(falseTarget)) {
HashSet content = FindDominatedNodes(scope, falseTarget);
scope.ExceptWith(content);
ilCond.FalseBlock.Body.AddRange(FindConditions(content, falseTarget));
@@ -390,9 +379,9 @@ namespace ICSharpCode.Decompiler.ILAst
}
}
- // Using the dominator tree should ensure we find the the widest loop first
- foreach(var child in node.DominatorTreeChildren) {
- agenda.Add(child);
+ // depth-first traversal of dominator tree
+ for (int i = node.DominatorTreeChildren.Count - 1; i >= 0; i--) {
+ agenda.Push(node.DominatorTreeChildren[i]);
}
}
@@ -404,6 +393,11 @@ namespace ICSharpCode.Decompiler.ILAst
return result;
}
+ static bool HasSingleEdgeEnteringBlock(ControlFlowNode node)
+ {
+ return node.Incoming.Count(edge => !node.Dominates(edge.Source)) == 1;
+ }
+
static HashSet FindDominatedNodes(HashSet scope, ControlFlowNode head)
{
HashSet agenda = new HashSet();
diff --git a/src/Libraries/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs b/src/Libraries/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs
index b2af46d975..6e8444a1ca 100644
--- a/src/Libraries/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs
+++ b/src/Libraries/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs
@@ -985,12 +985,24 @@ namespace ICSharpCode.Decompiler.ILAst
InferTypeForExpression(right, typeSystem.IntPtr);
return leftPreferred;
}
+ if (IsEnum(leftPreferred)) {
+ //E+U=E
+ left.InferredType = left.ExpectedType = leftPreferred;
+ InferTypeForExpression(right, GetEnumUnderlyingType(leftPreferred));
+ return leftPreferred;
+ }
TypeReference rightPreferred = DoInferTypeForExpression(right, expectedType);
if (rightPreferred is PointerType) {
InferTypeForExpression(left, typeSystem.IntPtr);
right.InferredType = right.ExpectedType = rightPreferred;
return rightPreferred;
}
+ if (IsEnum(rightPreferred)) {
+ //U+E=E
+ right.InferredType = right.ExpectedType = rightPreferred;
+ InferTypeForExpression(left, GetEnumUnderlyingType(rightPreferred));
+ return rightPreferred;
+ }
return InferBinaryArguments(left, right, expectedType, leftPreferred: leftPreferred, rightPreferred: rightPreferred);
}
@@ -1004,6 +1016,19 @@ namespace ICSharpCode.Decompiler.ILAst
InferTypeForExpression(right, typeSystem.IntPtr);
return leftPreferred;
}
+ if (IsEnum(leftPreferred)) {
+ if (expectedType != null && IsEnum(expectedType)) {
+ // E-U=E
+ left.InferredType = left.ExpectedType = leftPreferred;
+ InferTypeForExpression(right, GetEnumUnderlyingType(leftPreferred));
+ return leftPreferred;
+ } else {
+ // E-E=U
+ left.InferredType = left.ExpectedType = leftPreferred;
+ InferTypeForExpression(right, leftPreferred);
+ return GetEnumUnderlyingType(leftPreferred);
+ }
+ }
return InferBinaryArguments(left, right, expectedType, leftPreferred: leftPreferred);
}
diff --git a/src/Libraries/ICSharpCode.Decompiler/Properties/AssemblyInfo.cs b/src/Libraries/ICSharpCode.Decompiler/Properties/AssemblyInfo.cs
index 0deae79817..9260b6ba55 100644
--- a/src/Libraries/ICSharpCode.Decompiler/Properties/AssemblyInfo.cs
+++ b/src/Libraries/ICSharpCode.Decompiler/Properties/AssemblyInfo.cs
@@ -19,8 +19,8 @@ using System.Runtime.InteropServices;
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
-[assembly: AssemblyVersion("2.0.0.1489")]
-[assembly: AssemblyInformationalVersion("2.0.0.1489-774e3cd8")]
+[assembly: AssemblyVersion("2.0.0.1595")]
+[assembly: AssemblyInformationalVersion("2.0.0.1595-5773d3d2")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2243:AttributeStringLiteralsShouldParseCorrectly",
diff --git a/src/Libraries/ICSharpCode.Decompiler/Tests/ControlFlow.cs b/src/Libraries/ICSharpCode.Decompiler/Tests/ControlFlow.cs
new file mode 100644
index 0000000000..76038f1254
--- /dev/null
+++ b/src/Libraries/ICSharpCode.Decompiler/Tests/ControlFlow.cs
@@ -0,0 +1,81 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy of this
+// software and associated documentation files (the "Software"), to deal in the Software
+// without restriction, including without limitation the rights to use, copy, modify, merge,
+// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
+// to whom the Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all copies or
+// substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
+// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+using System;
+using System.Collections.Generic;
+
+public static class ControlFlow
+{
+ public static void EmptyIf(string input, List value, Dictionary _headers)
+ {
+ if (value.Contains("test"))
+ {
+ }
+ _headers.Add(2, "result");
+ }
+
+ public static void NormalIf(string input, List value, Dictionary _headers)
+ {
+ if (value.Contains("test"))
+ {
+ _headers.Add(1, "result");
+ }
+ else
+ {
+ _headers.Add(1, "else");
+ }
+ _headers.Add(2, "end");
+ }
+
+ public static void NormalIf2(string input, List value, Dictionary _headers)
+ {
+ if (value.Contains("test"))
+ {
+ _headers.Add(1, "result");
+ }
+ _headers.Add(2, "end");
+ }
+
+ public static void NormalIf3(string input, List value, Dictionary _headers)
+ {
+ if (value.Contains("test"))
+ {
+ _headers.Add(1, "result");
+ }
+ else
+ {
+ _headers.Add(1, "else");
+ }
+ }
+
+ public static void Test(string input, List value, Dictionary _headers)
+ {
+ foreach (string current in value)
+ {
+ _headers.Add(0, current);
+ }
+ if (value.Contains("test"))
+ {
+ _headers.Add(1, "result");
+ }
+ else
+ {
+ _headers.Add(1, "else");
+ }
+ }
+}
diff --git a/src/Libraries/ICSharpCode.Decompiler/Tests/Generics.cs b/src/Libraries/ICSharpCode.Decompiler/Tests/Generics.cs
index 5adb934c68..9776d42f34 100644
--- a/src/Libraries/ICSharpCode.Decompiler/Tests/Generics.cs
+++ b/src/Libraries/ICSharpCode.Decompiler/Tests/Generics.cs
@@ -107,4 +107,59 @@ public static class Generics
// Tests references to inner classes in generic classes
return d.Keys.GetEnumerator();
}
+
+ public static bool IsString(T input)
+ {
+ return input is string;
+ }
+
+ public static string AsString(T input)
+ {
+ return input as string;
+ }
+
+ public static string CastToString(T input)
+ {
+ return (string)((object)input);
+ }
+
+ public static T CastFromString(string input)
+ {
+ return (T)((object)input);
+ }
+
+ public static bool IsInt(T input)
+ {
+ return input is int;
+ }
+
+ public static int CastToInt(T input)
+ {
+ return (int)((object)input);
+ }
+
+ public static T CastFromInt(int input)
+ {
+ return (T)((object)input);
+ }
+
+ public static bool IsNullableInt(T input)
+ {
+ return input is int?;
+ }
+
+ public static int? AsNullableInt(T input)
+ {
+ return input as int?;
+ }
+
+ public static int? CastToNullableInt(T input)
+ {
+ return (int?)((object)input);
+ }
+
+ public static T CastFromNullableInt(int? input)
+ {
+ return (T)((object)input);
+ }
}
diff --git a/src/Libraries/ICSharpCode.Decompiler/Tests/Helpers/RemoveCompilerAttribute.cs b/src/Libraries/ICSharpCode.Decompiler/Tests/Helpers/RemoveCompilerAttribute.cs
index 2519165578..cb65620242 100644
--- a/src/Libraries/ICSharpCode.Decompiler/Tests/Helpers/RemoveCompilerAttribute.cs
+++ b/src/Libraries/ICSharpCode.Decompiler/Tests/Helpers/RemoveCompilerAttribute.cs
@@ -15,7 +15,7 @@ namespace ICSharpCode.Decompiler.Tests.Helpers
var section = (AttributeSection)attribute.Parent;
SimpleType type = attribute.Type as SimpleType;
if (section.AttributeTarget == "assembly" &&
- (type.Identifier == "CompilationRelaxations" || type.Identifier == "RuntimeCompatibility" || type.Identifier == "SecurityPermission" || type.Identifier == "AssemblyVersion"))
+ (type.Identifier == "CompilationRelaxations" || type.Identifier == "RuntimeCompatibility" || type.Identifier == "SecurityPermission" || type.Identifier == "AssemblyVersion" || type.Identifier == "Debuggable"))
{
attribute.Remove();
if (section.Attributes.Count == 0)
diff --git a/src/Libraries/ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj b/src/Libraries/ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj
index c42f043393..52a4f950da 100644
--- a/src/Libraries/ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj
+++ b/src/Libraries/ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj
@@ -64,7 +64,10 @@
+
+
+
@@ -77,6 +80,10 @@
+
+
+
+
@@ -117,10 +124,11 @@
ICSharpCode.Decompiler
-
+
+
+
-
\ No newline at end of file
diff --git a/src/Libraries/ICSharpCode.Decompiler/Tests/IL/ILTests.cs b/src/Libraries/ICSharpCode.Decompiler/Tests/IL/ILTests.cs
new file mode 100644
index 0000000000..3cfed30f22
--- /dev/null
+++ b/src/Libraries/ICSharpCode.Decompiler/Tests/IL/ILTests.cs
@@ -0,0 +1,51 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy of this
+// software and associated documentation files (the "Software"), to deal in the Software
+// without restriction, including without limitation the rights to use, copy, modify, merge,
+// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
+// to whom the Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all copies or
+// substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
+// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+// DEALINGS IN THE SOFTWARE.
+
+using System;
+using System.IO;
+using ICSharpCode.Decompiler.Ast;
+using ICSharpCode.Decompiler.Tests.Helpers;
+using Mono.Cecil;
+using NUnit.Framework;
+
+namespace ICSharpCode.Decompiler.Tests
+{
+ [TestFixture]
+ public class ILTests
+ {
+ const string path = "../../Tests/IL";
+
+ [Test]
+ public void SequenceOfNestedIfs()
+ {
+ Run("SequenceOfNestedIfs.dll", "SequenceOfNestedIfs.Output.cs");
+ }
+
+ void Run(string compiledFile, string expectedOutputFile)
+ {
+ string expectedOutput = File.ReadAllText(Path.Combine(path, expectedOutputFile));
+ var assembly = AssemblyDefinition.ReadAssembly(Path.Combine(path, compiledFile));
+ AstBuilder decompiler = new AstBuilder(new DecompilerContext(assembly.MainModule));
+ decompiler.AddAssembly(assembly);
+ new Helpers.RemoveCompilerAttribute().Run(decompiler.CompilationUnit);
+ StringWriter output = new StringWriter();
+ decompiler.GenerateCode(new PlainTextOutput(output));
+ CodeAssert.AreEqual(expectedOutput, output.ToString());
+ }
+ }
+}
diff --git a/src/Libraries/ICSharpCode.Decompiler/Tests/IL/SequenceOfNestedIfs.Output.cs b/src/Libraries/ICSharpCode.Decompiler/Tests/IL/SequenceOfNestedIfs.Output.cs
new file mode 100644
index 0000000000..754d7dafdc
--- /dev/null
+++ b/src/Libraries/ICSharpCode.Decompiler/Tests/IL/SequenceOfNestedIfs.Output.cs
@@ -0,0 +1,53 @@
+using System;
+[Serializable]
+public class Material
+{
+ public static implicit operator bool(Material m)
+ {
+ return m == null;
+ }
+}
+[Serializable]
+public class SequenceOfNestedIfs
+{
+ public bool _clear;
+ public Material _material;
+ public override bool CheckShader()
+ {
+ return false;
+ }
+ public override void CreateMaterials()
+ {
+ if (!this._clear)
+ {
+ if (!this.CheckShader())
+ {
+ return;
+ }
+ this._material = new Material();
+ }
+ if (!this._material)
+ {
+ if (!this.CheckShader())
+ {
+ return;
+ }
+ this._material = new Material();
+ }
+ if (!this._material)
+ {
+ if (!this.CheckShader())
+ {
+ return;
+ }
+ this._material = new Material();
+ }
+ if (!this._material)
+ {
+ if (this.CheckShader())
+ {
+ this._material = new Material();
+ }
+ }
+ }
+}
diff --git a/src/Libraries/ICSharpCode.Decompiler/Tests/IL/SequenceOfNestedIfs.dll b/src/Libraries/ICSharpCode.Decompiler/Tests/IL/SequenceOfNestedIfs.dll
new file mode 100644
index 0000000000..f517d4546d
Binary files /dev/null and b/src/Libraries/ICSharpCode.Decompiler/Tests/IL/SequenceOfNestedIfs.dll differ
diff --git a/src/Libraries/ICSharpCode.Decompiler/Tests/IL/SequenceOfNestedIfs.il b/src/Libraries/ICSharpCode.Decompiler/Tests/IL/SequenceOfNestedIfs.il
new file mode 100644
index 0000000000..9c9b749ce4
--- /dev/null
+++ b/src/Libraries/ICSharpCode.Decompiler/Tests/IL/SequenceOfNestedIfs.il
@@ -0,0 +1,140 @@
+// Metadata version: v2.0.50727
+.assembly extern mscorlib
+{
+ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+ .ver 2:0:0:0
+}
+
+.assembly SequenceOfNestedIfs
+{
+ .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
+ 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+.module SequenceOfNestedIfs
+// MVID: {DCEC8A87-5679-4EBE-89A3-51274D8B5446}
+.imagebase 0x00400000
+.file alignment 0x00000200
+.stackreserve 0x00100000
+.subsystem 0x0003 // WINDOWS_CUI
+.corflags 0x00000001 // ILONLY
+// Image base: 0x01D60000
+
+
+// =============== CLASS MEMBERS DECLARATION ===================
+
+.class public auto ansi serializable beforefieldinit Material
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ } // end of method Material::.ctor
+
+ .method public hidebysig specialname static
+ bool op_Implicit(class Material m) cil managed
+ {
+ // Code size 11 (0xb)
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: ldnull
+ IL_0008: ceq
+ IL_000a: ret
+ } // end of method Material::op_Implicit
+
+} // end of class Material
+
+.class public auto ansi serializable beforefieldinit SequenceOfNestedIfs
+ extends [mscorlib]System.Object
+{
+ .field public bool _clear
+ .field public class Material _material
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ // Code size 7 (0x7)
+ .maxstack 8
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ } // end of method SequenceOfNestedIfs::.ctor
+
+ .method public hidebysig virtual instance bool
+ CheckShader() cil managed
+ {
+ // Code size 2 (0x2)
+ .maxstack 8
+ IL_0000: ldc.i4.0
+ IL_0001: ret
+ } // end of method SequenceOfNestedIfs::CheckShader
+
+ .method public hidebysig virtual instance void
+ CreateMaterials() cil managed
+ {
+ // Code size 168 (0xa8)
+ .maxstack 13
+ IL_0000: ldarg.0
+ IL_0001: ldfld bool SequenceOfNestedIfs::_clear
+ IL_0006: brtrue IL_0026
+
+ IL_000b: ldarg.0
+ IL_000c: callvirt instance bool SequenceOfNestedIfs::CheckShader()
+ IL_0011: brtrue IL_001b
+
+ IL_0016: br IL_00a7
+
+ IL_001b: ldarg.0
+ IL_001c: newobj instance void Material::.ctor()
+ IL_0021: stfld class Material SequenceOfNestedIfs::_material
+ IL_0026: ldarg.0
+ IL_0027: ldfld class Material SequenceOfNestedIfs::_material
+ IL_002c: call bool Material::op_Implicit(class Material)
+ IL_0031: brtrue IL_0051
+
+ IL_0036: ldarg.0
+ IL_0037: callvirt instance bool SequenceOfNestedIfs::CheckShader()
+ IL_003c: brtrue IL_0046
+
+ IL_0041: br IL_00a7
+
+ IL_0046: ldarg.0
+ IL_0047: newobj instance void Material::.ctor()
+ IL_004c: stfld class Material SequenceOfNestedIfs::_material
+ IL_0051: ldarg.0
+ IL_0052: ldfld class Material SequenceOfNestedIfs::_material
+ IL_0057: call bool Material::op_Implicit(class Material)
+ IL_005c: brtrue IL_007c
+
+ IL_0061: ldarg.0
+ IL_0062: callvirt instance bool SequenceOfNestedIfs::CheckShader()
+ IL_0067: brtrue IL_0071
+
+ IL_006c: br IL_00a7
+
+ IL_0071: ldarg.0
+ IL_0072: newobj instance void Material::.ctor()
+ IL_0077: stfld class Material SequenceOfNestedIfs::_material
+ IL_007c: ldarg.0
+ IL_007d: ldfld class Material SequenceOfNestedIfs::_material
+ IL_0082: call bool Material::op_Implicit(class Material)
+ IL_0087: brtrue IL_00a7
+
+ IL_008c: ldarg.0
+ IL_008d: callvirt instance bool SequenceOfNestedIfs::CheckShader()
+ IL_0092: brtrue IL_009c
+
+ IL_0097: br IL_00a7
+
+ IL_009c: ldarg.0
+ IL_009d: newobj instance void Material::.ctor()
+ IL_00a2: stfld class Material SequenceOfNestedIfs::_material
+ IL_00a7: ret
+ } // end of method SequenceOfNestedIfs::CreateMaterials
+
+} // end of class SequenceOfNestedIfs
\ No newline at end of file
diff --git a/src/Libraries/ICSharpCode.Decompiler/Tests/StackTests/StackTests.exe b/src/Libraries/ICSharpCode.Decompiler/Tests/IL/StackTests.exe
similarity index 100%
rename from src/Libraries/ICSharpCode.Decompiler/Tests/StackTests/StackTests.exe
rename to src/Libraries/ICSharpCode.Decompiler/Tests/IL/StackTests.exe
diff --git a/src/Libraries/ICSharpCode.Decompiler/Tests/StackTests/StackTests.il b/src/Libraries/ICSharpCode.Decompiler/Tests/IL/StackTests.il
similarity index 100%
rename from src/Libraries/ICSharpCode.Decompiler/Tests/StackTests/StackTests.il
rename to src/Libraries/ICSharpCode.Decompiler/Tests/IL/StackTests.il
diff --git a/src/Libraries/ICSharpCode.Decompiler/Tests/PropertiesAndEvents.cs b/src/Libraries/ICSharpCode.Decompiler/Tests/PropertiesAndEvents.cs
index 4bacc06e3e..bdc4f7dd1f 100644
--- a/src/Libraries/ICSharpCode.Decompiler/Tests/PropertiesAndEvents.cs
+++ b/src/Libraries/ICSharpCode.Decompiler/Tests/PropertiesAndEvents.cs
@@ -26,8 +26,7 @@ public class PropertiesAndEvents
[field: NonSerialized]
public event EventHandler AutomaticEventWithInitializer = delegate
{
- }
- ;
+ };
public event EventHandler CustomEvent
{
diff --git a/src/Libraries/ICSharpCode.Decompiler/Tests/TestRunner.cs b/src/Libraries/ICSharpCode.Decompiler/Tests/TestRunner.cs
index a4feebca09..8160a7376d 100644
--- a/src/Libraries/ICSharpCode.Decompiler/Tests/TestRunner.cs
+++ b/src/Libraries/ICSharpCode.Decompiler/Tests/TestRunner.cs
@@ -61,7 +61,7 @@ namespace ICSharpCode.Decompiler.Tests
[Test]
public void ExceptionHandling()
{
- TestFile(@"..\..\Tests\ExceptionHandling.cs", false);
+ TestFile(@"..\..\Tests\ExceptionHandling.cs", optimize: false);
}
[Test]
@@ -76,6 +76,12 @@ namespace ICSharpCode.Decompiler.Tests
TestFile(@"..\..\Tests\CustomShortCircuitOperators.cs");
}
+ [Test]
+ public void ControlFlowWithDebug()
+ {
+ TestFile(@"..\..\Tests\ControlFlow.cs", optimize: false, useDebug: true);
+ }
+
[Test]
public void IncrementDecrement()
{
@@ -160,16 +166,16 @@ namespace ICSharpCode.Decompiler.Tests
TestFile(@"..\..\Tests\TypeAnalysisTests.cs");
}
- static void TestFile(string fileName)
+ static void TestFile(string fileName, bool useDebug = false)
{
- TestFile(fileName, false);
- TestFile(fileName, true);
+ TestFile(fileName, false, useDebug);
+ TestFile(fileName, true, useDebug);
}
- static void TestFile(string fileName, bool optimize)
+ static void TestFile(string fileName, bool optimize, bool useDebug = false)
{
string code = File.ReadAllText(fileName);
- AssemblyDefinition assembly = Compile(code, optimize);
+ AssemblyDefinition assembly = Compile(code, optimize, useDebug);
AstBuilder decompiler = new AstBuilder(new DecompilerContext(assembly.MainModule));
decompiler.AddAssembly(assembly);
new Helpers.RemoveCompilerAttribute().Run(decompiler.CompilationUnit);
@@ -178,11 +184,11 @@ namespace ICSharpCode.Decompiler.Tests
CodeAssert.AreEqual(code, output.ToString());
}
- static AssemblyDefinition Compile(string code, bool optimize)
+ static AssemblyDefinition Compile(string code, bool optimize, bool useDebug)
{
CSharpCodeProvider provider = new CSharpCodeProvider(new Dictionary { { "CompilerVersion", "v4.0" } });
CompilerParameters options = new CompilerParameters();
- options.CompilerOptions = "/unsafe /o" + (optimize ? "+" : "-");
+ options.CompilerOptions = "/unsafe /o" + (optimize ? "+" : "-") + (useDebug ? " /debug": "");
options.ReferencedAssemblies.Add("System.Core.dll");
CompilerResults results = provider.CompileAssemblyFromSource(options, code);
try {
diff --git a/src/Libraries/ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs b/src/Libraries/ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs
index 3c0ffc4b97..760bb862d3 100644
--- a/src/Libraries/ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs
+++ b/src/Libraries/ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs
@@ -140,4 +140,14 @@ public class TypeAnalysisTests
{
return new byte[length];
}
+
+ public StringComparison EnumDiffNumber(StringComparison data)
+ {
+ return data - 1;
+ }
+
+ public int EnumDiff(StringComparison a, StringComparison b)
+ {
+ return Math.Abs(a - b);
+ }
}
diff --git a/src/Libraries/Mono.Cecil/Mono.Cecil.PE/Image.cs b/src/Libraries/Mono.Cecil/Mono.Cecil.PE/Image.cs
index 9a04494f01..e5d8075251 100644
--- a/src/Libraries/Mono.Cecil/Mono.Cecil.PE/Image.cs
+++ b/src/Libraries/Mono.Cecil/Mono.Cecil.PE/Image.cs
@@ -52,6 +52,7 @@ namespace Mono.Cecil.PE {
public DataDirectory Debug;
public DataDirectory Resources;
+ public DataDirectory StrongName;
public StringHeap StringHeap;
public BlobHeap BlobHeap;
diff --git a/src/Libraries/Mono.Cecil/Mono.Cecil.PE/ImageReader.cs b/src/Libraries/Mono.Cecil/Mono.Cecil.PE/ImageReader.cs
index 9baeca5eef..b320169192 100644
--- a/src/Libraries/Mono.Cecil/Mono.Cecil.PE/ImageReader.cs
+++ b/src/Libraries/Mono.Cecil/Mono.Cecil.PE/ImageReader.cs
@@ -322,6 +322,7 @@ namespace Mono.Cecil.PE {
// Resources 8
image.Resources = ReadDataDirectory ();
// StrongNameSignature 8
+ image.StrongName = ReadDataDirectory ();
// CodeManagerTable 8
// VTableFixups 8
// ExportAddressTableJumps 8
diff --git a/src/Libraries/Mono.Cecil/Mono.Cecil.PE/ImageWriter.cs b/src/Libraries/Mono.Cecil/Mono.Cecil.PE/ImageWriter.cs
index af6aa7a359..bea308c919 100644
--- a/src/Libraries/Mono.Cecil/Mono.Cecil.PE/ImageWriter.cs
+++ b/src/Libraries/Mono.Cecil/Mono.Cecil.PE/ImageWriter.cs
@@ -75,7 +75,7 @@ namespace Mono.Cecil.PE {
this.GetDebugHeader ();
this.GetWin32Resources ();
this.text_map = BuildTextMap ();
- this.sections = 2; // text + reloc
+ this.sections = (ushort) (pe64 ? 1 : 2); // text + reloc
this.time_stamp = (uint) DateTime.UtcNow.Subtract (new DateTime (1970, 1, 1)).TotalSeconds;
}
@@ -133,7 +133,8 @@ namespace Mono.Cecil.PE {
previous = rsrc;
}
- reloc = CreateSection (".reloc", 12u, previous);
+ if (!pe64)
+ reloc = CreateSection (".reloc", 12u, previous);
}
Section CreateSection (string name, uint size, Section previous)
@@ -217,20 +218,29 @@ namespace Mono.Cecil.PE {
throw new NotSupportedException ();
}
+ Section LastSection ()
+ {
+ if (reloc != null)
+ return reloc;
+
+ if (rsrc != null)
+ return rsrc;
+
+ return text;
+ }
+
void WriteOptionalHeaders ()
{
WriteUInt16 ((ushort) (!pe64 ? 0x10b : 0x20b)); // Magic
WriteByte (8); // LMajor
WriteByte (0); // LMinor
WriteUInt32 (text.SizeOfRawData); // CodeSize
- WriteUInt32 (reloc.SizeOfRawData
+ WriteUInt32 (reloc != null ? reloc.SizeOfRawData : 0
+ (rsrc != null ? rsrc.SizeOfRawData : 0)); // InitializedDataSize
WriteUInt32 (0); // UninitializedDataSize
- var entry_point_rva = text_map.GetRVA (TextSegment.StartupStub);
- if (module.Architecture == TargetArchitecture.IA64)
- entry_point_rva += 0x20;
- WriteUInt32 (entry_point_rva); // EntryPointRVA
+ var startub_stub = text_map.GetRange (TextSegment.StartupStub);
+ WriteUInt32 (startub_stub.Length > 0 ? startub_stub.Start : 0); // EntryPointRVA
WriteUInt32 (text_rva); // BaseOfCode
if (!pe64) {
@@ -251,7 +261,8 @@ namespace Mono.Cecil.PE {
WriteUInt16 (0); // SubSysMinor
WriteUInt32 (0); // Reserved
- WriteUInt32 (reloc.VirtualAddress + Align (reloc.VirtualSize, section_alignment)); // ImageSize
+ var last_section = LastSection();
+ WriteUInt32 (last_section.VirtualAddress + Align (last_section.VirtualSize, section_alignment)); // ImageSize
WriteUInt32 (text.PointerToRawData); // HeaderSize
WriteUInt32 (0); // Checksum
@@ -288,8 +299,8 @@ namespace Mono.Cecil.PE {
WriteZeroDataDirectory (); // ExceptionTable
WriteZeroDataDirectory (); // CertificateTable
- WriteUInt32 (reloc.VirtualAddress); // BaseRelocationTable
- WriteUInt32 (reloc.VirtualSize);
+ WriteUInt32 (reloc != null ? reloc.VirtualAddress : 0); // BaseRelocationTable
+ WriteUInt32 (reloc != null ? reloc.VirtualSize : 0);
if (text_map.GetLength (TextSegment.DebugDirectory) > 0) {
WriteUInt32 (text_map.GetRVA (TextSegment.DebugDirectory));
@@ -335,7 +346,8 @@ namespace Mono.Cecil.PE {
if (rsrc != null)
WriteSection (rsrc, 0x40000040);
- WriteSection (reloc, 0x42000040);
+ if (reloc != null)
+ WriteSection (reloc, 0x42000040);
}
void WriteSection (Section section, uint characteristics)
@@ -386,8 +398,10 @@ namespace Mono.Cecil.PE {
// ImportAddressTable
- WriteRVA (text_map.GetRVA (TextSegment.ImportHintNameTable));
- WriteRVA (0);
+ if (!pe64) {
+ WriteRVA (text_map.GetRVA (TextSegment.ImportHintNameTable));
+ WriteRVA (0);
+ }
// CLIHeader
@@ -439,6 +453,9 @@ namespace Mono.Cecil.PE {
WriteDebugDirectory ();
}
+ if (pe64)
+ return;
+
// ImportDirectory
MoveToRVA (TextSegment.ImportDirectory);
WriteImportDirectory ();
@@ -605,19 +622,8 @@ namespace Mono.Cecil.PE {
WriteUInt16 (0x25ff);
WriteUInt32 ((uint) image_base + text_map.GetRVA (TextSegment.ImportAddressTable));
return;
- case TargetArchitecture.AMD64:
- WriteUInt16 (0xa148);
- WriteUInt32 ((uint) image_base + text_map.GetRVA (TextSegment.ImportAddressTable));
- WriteUInt16 (0xe0ff);
- return;
- case TargetArchitecture.IA64:
- WriteBytes (new byte [] {
- 0x0b, 0x48, 0x00, 0x02, 0x18, 0x10, 0xa0, 0x40, 0x24, 0x30, 0x28, 0x00, 0x00, 0x00, 0x04, 0x00,
- 0x10, 0x08, 0x00, 0x12, 0x18, 0x10, 0x60, 0x50, 0x04, 0x80, 0x03, 0x00, 0x60, 0x00, 0x80, 0x00
- });
- WriteUInt32 ((uint) image_base + text_map.GetRVA (TextSegment.StartupStub));
- WriteUInt32 ((uint) image_base + text_rva);
- return;
+ default:
+ throw new NotSupportedException ();
}
}
@@ -642,13 +648,8 @@ namespace Mono.Cecil.PE {
case TargetArchitecture.I386:
WriteUInt32 (0x3000 + reloc_rva - page_rva);
break;
- case TargetArchitecture.AMD64:
- WriteUInt32 (0xa000 + reloc_rva - page_rva);
- break;
- case TargetArchitecture.IA64:
- WriteUInt16 ((ushort) (0xa000 + reloc_rva - page_rva));
- WriteUInt16 ((ushort) (0xa000 + reloc_rva - page_rva + 8));
- break;
+ default:
+ throw new NotSupportedException();
}
WriteBytes (new byte [file_alignment - reloc.VirtualSize]);
@@ -663,7 +664,8 @@ namespace Mono.Cecil.PE {
WriteText ();
if (rsrc != null)
WriteRsrc ();
- WriteReloc ();
+ if (reloc != null)
+ WriteReloc ();
}
TextMap BuildTextMap ()
@@ -694,8 +696,16 @@ namespace Mono.Cecil.PE {
map.AddMap (TextSegment.DebugDirectory, debug_dir_len, 4);
+ if (pe64) {
+ var start = map.GetNextRVA (TextSegment.DebugDirectory);
+ map.AddMap (TextSegment.ImportDirectory, new Range (start, 0));
+ map.AddMap (TextSegment.ImportHintNameTable, new Range (start, 0));
+ map.AddMap (TextSegment.StartupStub, new Range (start, 0));
+ return map;
+ }
+
RVA import_dir_rva = map.GetNextRVA (TextSegment.DebugDirectory);
- RVA import_hnt_rva = import_dir_rva + (!pe64 ? 48u : 52u);
+ RVA import_hnt_rva = import_dir_rva + 48u;
import_hnt_rva = (import_hnt_rva + 15u) & ~15u;
uint import_dir_len = (import_hnt_rva - import_dir_rva) + 27u;
@@ -716,12 +726,8 @@ namespace Mono.Cecil.PE {
switch (module.Architecture) {
case TargetArchitecture.I386:
return 6;
- case TargetArchitecture.AMD64:
- return 12;
- case TargetArchitecture.IA64:
- return 48;
default:
- throw new InvalidOperationException ();
+ throw new NotSupportedException ();
}
}
@@ -744,11 +750,8 @@ namespace Mono.Cecil.PE {
int GetStrongNameLength ()
{
- if ((module.Attributes & ModuleAttributes.StrongNameSigned) == 0)
- return 0;
-
if (module.Assembly == null)
- throw new InvalidOperationException ();
+ return 0;
var public_key = module.Assembly.Name.PublicKey;
diff --git a/src/Libraries/Mono.Cecil/Mono.Cecil/AssemblyFlags.cs b/src/Libraries/Mono.Cecil/Mono.Cecil/AssemblyFlags.cs
index e466e78441..72a0eb06c2 100644
--- a/src/Libraries/Mono.Cecil/Mono.Cecil/AssemblyFlags.cs
+++ b/src/Libraries/Mono.Cecil/Mono.Cecil/AssemblyFlags.cs
@@ -35,6 +35,7 @@ namespace Mono.Cecil {
PublicKey = 0x0001,
SideBySideCompatible = 0x0000,
Retargetable = 0x0100,
+ WindowsRuntime = 0x0200,
DisableJITCompileOptimizer = 0x4000,
EnableJITCompileTracking = 0x8000,
}
diff --git a/src/Libraries/Mono.Cecil/Mono.Cecil/AssemblyNameReference.cs b/src/Libraries/Mono.Cecil/Mono.Cecil/AssemblyNameReference.cs
index 31b7a30b3a..3da978057b 100644
--- a/src/Libraries/Mono.Cecil/Mono.Cecil/AssemblyNameReference.cs
+++ b/src/Libraries/Mono.Cecil/Mono.Cecil/AssemblyNameReference.cs
@@ -92,6 +92,11 @@ namespace Mono.Cecil {
set { attributes = attributes.SetAttributes ((uint) AssemblyAttributes.Retargetable, value); }
}
+ public bool IsWindowsRuntime {
+ get { return attributes.GetAttributes ((uint) AssemblyAttributes.WindowsRuntime); }
+ set { attributes = attributes.SetAttributes ((uint) AssemblyAttributes.WindowsRuntime, value); }
+ }
+
public byte [] PublicKey {
get { return public_key; }
set {
diff --git a/src/Libraries/Mono.Cecil/Mono.Cecil/AssemblyWriter.cs b/src/Libraries/Mono.Cecil/Mono.Cecil/AssemblyWriter.cs
index 22c77ab7ac..bffa439c60 100644
--- a/src/Libraries/Mono.Cecil/Mono.Cecil/AssemblyWriter.cs
+++ b/src/Libraries/Mono.Cecil/Mono.Cecil/AssemblyWriter.cs
@@ -97,13 +97,11 @@ namespace Mono.Cecil {
var symbol_writer = GetSymbolWriter (module, fq_name, symbol_writer_provider);
#if !SILVERLIGHT && !CF
- if (parameters.StrongNameKeyPair != null && name != null)
+ if (parameters.StrongNameKeyPair != null && name != null) {
name.PublicKey = parameters.StrongNameKeyPair.PublicKey;
-#endif
-
- if (name != null && name.HasPublicKey)
module.Attributes |= ModuleAttributes.StrongNameSigned;
-
+ }
+#endif
var metadata = new MetadataBuilder (module, fq_name,
symbol_writer_provider, symbol_writer);
@@ -786,7 +784,7 @@ namespace Mono.Cecil {
TextMap CreateTextMap ()
{
var map = new TextMap ();
- map.AddMap (TextSegment.ImportAddressTable, module.Architecture == TargetArchitecture.I386 ? 8 : 16);
+ map.AddMap (TextSegment.ImportAddressTable, module.Architecture == TargetArchitecture.I386 ? 8 : 0);
map.AddMap (TextSegment.CLIHeader, 0x48, 8);
return map;
}
diff --git a/src/Libraries/Mono.Cecil/Mono.Cecil/Import.cs b/src/Libraries/Mono.Cecil/Mono.Cecil/Import.cs
index 4f3ff25c4e..38d0120412 100644
--- a/src/Libraries/Mono.Cecil/Mono.Cecil/Import.cs
+++ b/src/Libraries/Mono.Cecil/Mono.Cecil/Import.cs
@@ -92,7 +92,7 @@ namespace Mono.Cecil {
if (IsNestedType (type))
reference.DeclaringType = ImportType (type.DeclaringType, context, import_kind);
else
- reference.Namespace = type.Namespace;
+ reference.Namespace = type.Namespace ?? string.Empty;
if (type.IsGenericType)
ImportGenericParameters (reference, type.GetGenericArguments ());
diff --git a/src/Libraries/Mono.Cecil/Mono.Cecil/TypeAttributes.cs b/src/Libraries/Mono.Cecil/Mono.Cecil/TypeAttributes.cs
index bc4e18f336..86fbc4dba5 100644
--- a/src/Libraries/Mono.Cecil/Mono.Cecil/TypeAttributes.cs
+++ b/src/Libraries/Mono.Cecil/Mono.Cecil/TypeAttributes.cs
@@ -62,6 +62,7 @@ namespace Mono.Cecil {
// Implementation attributes
Import = 0x00001000, // Class/Interface is imported
Serializable = 0x00002000, // Class is serializable
+ WindowsRuntime = 0x00004000, // Windows Runtime type
// String formatting attributes
StringFormatMask = 0x00030000, // Use this mask to retrieve string information for native interop
diff --git a/src/Libraries/Mono.Cecil/Mono.Cecil/TypeDefinition.cs b/src/Libraries/Mono.Cecil/Mono.Cecil/TypeDefinition.cs
index a43e7e53ea..58c52af179 100644
--- a/src/Libraries/Mono.Cecil/Mono.Cecil/TypeDefinition.cs
+++ b/src/Libraries/Mono.Cecil/Mono.Cecil/TypeDefinition.cs
@@ -389,6 +389,11 @@ namespace Mono.Cecil {
set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Serializable, value); }
}
+ public bool IsWindowsRuntime {
+ get { return attributes.GetAttributes ((uint) TypeAttributes.WindowsRuntime); }
+ set { attributes = attributes.SetAttributes ((uint) TypeAttributes.WindowsRuntime, value); }
+ }
+
public bool IsAnsiClass {
get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AnsiClass); }
set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AnsiClass, value); }
diff --git a/src/Libraries/NRefactory/ICSharpCode.NRefactory/Utils/GraphVizGraph.cs b/src/Libraries/NRefactory/ICSharpCode.NRefactory/Utils/GraphVizGraph.cs
index 880a4c2dfd..77953349a9 100644
--- a/src/Libraries/NRefactory/ICSharpCode.NRefactory/Utils/GraphVizGraph.cs
+++ b/src/Libraries/NRefactory/ICSharpCode.NRefactory/Utils/GraphVizGraph.cs
@@ -22,6 +22,7 @@ using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text.RegularExpressions;
+using System.Threading;
namespace ICSharpCode.NRefactory.Utils
{
@@ -66,8 +67,11 @@ namespace ICSharpCode.NRefactory.Utils
name = name.Replace(c, '-');
string fileName = name != null ? Path.Combine(Path.GetTempPath(), name) : Path.GetTempFileName();
Save(fileName + ".gv");
- Process.Start("dot", "\"" + fileName + ".gv\" -Tpng -o \"" + fileName + ".png\"").WaitForExit();
- Process.Start(fileName + ".png");
+ new Thread(new ThreadStart(
+ delegate {
+ Process.Start("dot", "\"" + fileName + ".gv\" -Tpng -o \"" + fileName + ".png\"").WaitForExit();
+ Process.Start(fileName + ".png");
+ })).Start();
}
static string Escape(string text)
diff --git a/src/Libraries/NRefactory/Project/Src/Lexer/AbstractLexer.cs b/src/Libraries/NRefactory/Project/Src/Lexer/AbstractLexer.cs
new file mode 100644
index 0000000000..688c7e95f6
--- /dev/null
+++ b/src/Libraries/NRefactory/Project/Src/Lexer/AbstractLexer.cs
@@ -0,0 +1,386 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+
+namespace ICSharpCode.NRefactory.Parser
+{
+ ///
+ /// This is the base class for the C# and VB.NET lexer
+ ///
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1708:IdentifiersShouldDifferByMoreThanCase")]
+ internal abstract class AbstractLexer : ILexer
+ {
+ LATextReader reader;
+ int col = 1;
+ int line = 1;
+
+ protected Errors errors = new Errors();
+
+ protected Token lastToken = null;
+ protected Token curToken = null;
+ protected Token peekToken = null;
+
+ string[] specialCommentTags = null;
+ protected Hashtable specialCommentHash = null;
+ List tagComments = new List();
+ protected StringBuilder sb = new StringBuilder();
+ protected SpecialTracker specialTracker = new SpecialTracker();
+
+ // used for the original value of strings (with escape sequences).
+ protected StringBuilder originalValue = new StringBuilder();
+
+ public bool SkipAllComments { get; set; }
+ public bool EvaluateConditionalCompilation { get; set; }
+ public virtual IDictionary ConditionalCompilationSymbols {
+ get { throw new NotSupportedException(); }
+ }
+
+ protected static IEnumerable GetSymbols (string symbols)
+ {
+ if (!string.IsNullOrEmpty(symbols)) {
+ foreach (string symbol in symbols.Split (';', ' ', '\t')) {
+ string s = symbol.Trim ();
+ if (s.Length == 0)
+ continue;
+ yield return s;
+ }
+ }
+ }
+
+ public virtual void SetConditionalCompilationSymbols (string symbols)
+ {
+ throw new NotSupportedException ();
+ }
+
+ protected int Line {
+ get {
+ return line;
+ }
+ }
+ protected int Col {
+ get {
+ return col;
+ }
+ }
+
+ protected bool recordRead = false;
+ protected StringBuilder recordedText = new StringBuilder ();
+
+ protected int ReaderRead()
+ {
+ int val = reader.Read();
+ if (recordRead && val >= 0)
+ recordedText.Append ((char)val);
+ if ((val == '\r' && reader.Peek() != '\n') || val == '\n') {
+ ++line;
+ col = 1;
+ LineBreak();
+ } else if (val >= 0) {
+ col++;
+ }
+ return val;
+ }
+
+ protected int ReaderPeek()
+ {
+ return reader.Peek();
+ }
+
+ protected int ReaderPeek(int step)
+ {
+ return reader.Peek(step);
+ }
+
+ protected void ReaderSkip(int steps)
+ {
+ for (int i = 0; i < steps; i++) {
+ ReaderRead();
+ }
+ }
+
+ protected string ReaderPeekString(int length)
+ {
+ StringBuilder builder = new StringBuilder();
+
+ for (int i = 0; i < length; i++) {
+ int peek = ReaderPeek(i);
+ if (peek != -1)
+ builder.Append((char)peek);
+ }
+
+ return builder.ToString();
+ }
+
+ public void SetInitialLocation(Location location)
+ {
+ if (lastToken != null || curToken != null || peekToken != null)
+ throw new InvalidOperationException();
+ this.line = location.Line;
+ this.col = location.Column;
+ }
+
+ public Errors Errors {
+ get {
+ return errors;
+ }
+ }
+
+ ///
+ /// Returns the comments that had been read and containing tag key words.
+ ///
+ public List TagComments {
+ get {
+ return tagComments;
+ }
+ }
+
+ public SpecialTracker SpecialTracker {
+ get {
+ return specialTracker;
+ }
+ }
+
+ ///
+ /// Special comment tags are tags like TODO, HACK or UNDONE which are read by the lexer and stored in .
+ ///
+ public string[] SpecialCommentTags {
+ get {
+ return specialCommentTags;
+ }
+ set {
+ specialCommentTags = value;
+ specialCommentHash = null;
+ if (specialCommentTags != null && specialCommentTags.Length > 0) {
+ specialCommentHash = new Hashtable();
+ foreach (string str in specialCommentTags) {
+ specialCommentHash.Add(str, null);
+ }
+ }
+ }
+ }
+
+ ///
+ /// The current Token.
+ ///
+ public Token Token {
+ get {
+// Console.WriteLine("Call to Token");
+ return lastToken;
+ }
+ }
+
+ ///
+ /// The next Token (The after call) .
+ ///
+ public Token LookAhead {
+ get {
+// Console.WriteLine("Call to LookAhead");
+ return curToken;
+ }
+ }
+
+ ///
+ /// Constructor for the abstract lexer class.
+ ///
+ protected AbstractLexer(TextReader reader)
+ {
+ this.reader = new LATextReader(reader);
+ }
+
+ protected AbstractLexer(TextReader reader, LexerMemento state)
+ : this(reader)
+ {
+ SetInitialLocation(new Location(state.Column, state.Line));
+ lastToken = new Token(state.PrevTokenKind, 0, 0);
+ }
+
+ #region System.IDisposable interface implementation
+ public virtual void Dispose()
+ {
+ reader.Close();
+ reader = null;
+ errors = null;
+ lastToken = curToken = peekToken = null;
+ specialCommentHash = null;
+ tagComments = null;
+ sb = originalValue = null;
+ }
+ #endregion
+
+ ///
+ /// Must be called before a peek operation.
+ ///
+ public void StartPeek()
+ {
+ peekToken = curToken;
+ }
+
+ ///
+ /// Gives back the next token. A second call to Peek() gives the next token after the last call for Peek() and so on.
+ ///
+ /// An object.
+ public Token Peek()
+ {
+// Console.WriteLine("Call to Peek");
+ if (peekToken.next == null) {
+ peekToken.next = Next();
+ }
+ peekToken = peekToken.next;
+ return peekToken;
+ }
+
+ ///
+ /// Reads the next token and gives it back.
+ ///
+ /// An object.
+ public virtual Token NextToken()
+ {
+ if (curToken == null) {
+ curToken = Next();
+ //Console.WriteLine(ICSharpCode.NRefactory.Parser.CSharp.Tokens.GetTokenString(curToken.kind) + " -- " + curToken.val + "(" + curToken.kind + ")");
+ return curToken;
+ }
+
+ lastToken = curToken;
+
+ if (curToken.next == null) {
+ curToken.next = Next();
+ }
+
+ curToken = curToken.next;
+ //Console.WriteLine(ICSharpCode.NRefactory.Parser.CSharp.Tokens.GetTokenString(curToken.kind) + " -- " + curToken.val + "(" + curToken.kind + ")");
+ return curToken;
+ }
+
+ protected abstract Token Next();
+
+ protected static bool IsIdentifierPart(int ch)
+ {
+ if (ch == 95) return true; // 95 = '_'
+ if (ch == -1) return false;
+ return char.IsLetterOrDigit((char)ch); // accept unicode letters
+ }
+
+ protected static bool IsHex(char digit)
+ {
+ return Char.IsDigit(digit) || ('A' <= digit && digit <= 'F') || ('a' <= digit && digit <= 'f');
+ }
+
+ protected int GetHexNumber(char digit)
+ {
+ if (Char.IsDigit(digit)) {
+ return digit - '0';
+ }
+ if ('A' <= digit && digit <= 'F') {
+ return digit - 'A' + 0xA;
+ }
+ if ('a' <= digit && digit <= 'f') {
+ return digit - 'a' + 0xA;
+ }
+ errors.Error(line, col, "Invalid hex number '" + digit + "'");
+ return 0;
+ }
+ protected Location lastLineEnd = new Location (1, 1);
+ protected Location curLineEnd = new Location (1, 1);
+ protected void LineBreak ()
+ {
+ lastLineEnd = curLineEnd;
+ curLineEnd = new Location (col - 1, line);
+ }
+ protected bool HandleLineEnd(char ch)
+ {
+ // Handle MS-DOS or MacOS line ends.
+ if (ch == '\r') {
+ if (reader.Peek() == '\n') { // MS-DOS line end '\r\n'
+ ReaderRead(); // LineBreak (); called by ReaderRead ();
+ return true;
+ } else { // assume MacOS line end which is '\r'
+ LineBreak ();
+ return true;
+ }
+ }
+ if (ch == '\n') {
+ LineBreak ();
+ return true;
+ }
+ return false;
+ }
+
+ protected void SkipToEndOfLine()
+ {
+ int nextChar;
+ while ((nextChar = reader.Read()) != -1) {
+ if (nextChar == '\r') {
+ if (reader.Peek() == '\n')
+ reader.Read();
+ nextChar = '\n';
+ }
+ if (nextChar == '\n') {
+ ++line;
+ col = 1;
+ break;
+ }
+ }
+ }
+
+ protected string ReadToEndOfLine()
+ {
+ sb.Length = 0;
+ int nextChar;
+ while ((nextChar = reader.Read()) != -1) {
+ char ch = (char)nextChar;
+
+ if (nextChar == '\r') {
+ if (reader.Peek() == '\n')
+ reader.Read();
+ nextChar = '\n';
+ }
+ // Return read string, if EOL is reached
+ if (nextChar == '\n') {
+ ++line;
+ col = 1;
+ return sb.ToString();
+ }
+
+ sb.Append(ch);
+ }
+
+ // Got EOF before EOL
+ string retStr = sb.ToString();
+ col += retStr.Length;
+ return retStr;
+ }
+
+ ///
+ /// Skips to the end of the current code block.
+ /// For this, the lexer must have read the next token AFTER the token opening the
+ /// block (so that Lexer.Token is the block-opening token, not Lexer.LookAhead).
+ /// After the call, Lexer.LookAhead will be the block-closing token.
+ ///
+ public abstract void SkipCurrentBlock(int targetToken);
+
+ public event EventHandler SavepointReached;
+
+ protected virtual void OnSavepointReached(SavepointEventArgs e)
+ {
+ if (SavepointReached != null) {
+ SavepointReached(this, e);
+ }
+ }
+
+ public virtual LexerMemento Export()
+ {
+ throw new NotSupportedException();
+ }
+
+ public virtual void SetInitialContext(SnippetType context)
+ {
+ throw new NotSupportedException();
+ }
+ }
+}
diff --git a/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
new file mode 100644
index 0000000000..6fd33cca4f
--- /dev/null
+++ b/src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
@@ -0,0 +1,8149 @@
+
+#line 1 "VBNET.ATG"
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Linq;
+using System.Text;
+using ICSharpCode.NRefactory.Ast;
+using ICSharpCode.NRefactory.Parser.VB;
+using ASTAttribute = ICSharpCode.NRefactory.Ast.Attribute;
+/*
+ Parser.frame file for NRefactory.
+ */
+using System;
+using System.Reflection;
+
+namespace ICSharpCode.NRefactory.Parser.VB {
+
+
+
+partial class Parser : AbstractParser
+{
+ const int maxT = 238;
+
+ const bool T = true;
+ const bool x = false;
+
+
+#line 13 "VBNET.ATG"
+
+
+/*
+
+*/
+
+ void VBNET() {
+
+#line 263 "VBNET.ATG"
+ lexer.NextToken(); // get the first token
+ compilationUnit = new CompilationUnit();
+ BlockStart(compilationUnit);
+
+ while (la.kind == 1 || la.kind == 21) {
+ EndOfStmt();
+ }
+ while (la.kind == 173) {
+ OptionStmt();
+ while (la.kind == 1 || la.kind == 21) {
+ EndOfStmt();
+ }
+ }
+ while (la.kind == 137) {
+ ImportsStmt();
+ while (la.kind == 1 || la.kind == 21) {
+ EndOfStmt();
+ }
+ }
+ while (
+#line 271 "VBNET.ATG"
+IsGlobalAttrTarget()) {
+ GlobalAttributeSection();
+ while (la.kind == 1 || la.kind == 21) {
+ EndOfStmt();
+ }
+ }
+ while (StartOf(1)) {
+ NamespaceMemberDecl();
+ while (la.kind == 1 || la.kind == 21) {
+ EndOfStmt();
+ }
+ }
+ Expect(0);
+ }
+
+ void EndOfStmt() {
+ while (!(la.kind == 0 || la.kind == 1 || la.kind == 21)) {SynErr(239); lexer.NextToken(); }
+ if (la.kind == 1) {
+ lexer.NextToken();
+ } else if (la.kind == 21) {
+ lexer.NextToken();
+ } else SynErr(240);
+ }
+
+ void OptionStmt() {
+
+#line 276 "VBNET.ATG"
+ INode node = null; bool val = true;
+ Expect(173);
+
+#line 277 "VBNET.ATG"
+ Location startPos = t.Location;
+ if (la.kind == 121) {
+ lexer.NextToken();
+ if (la.kind == 170 || la.kind == 171) {
+ OptionValue(
+#line 279 "VBNET.ATG"
+ref val);
+ }
+
+#line 280 "VBNET.ATG"
+ node = new OptionDeclaration(OptionType.Explicit, val);
+ } else if (la.kind == 207) {
+ lexer.NextToken();
+ if (la.kind == 170 || la.kind == 171) {
+ OptionValue(
+#line 282 "VBNET.ATG"
+ref val);
+ }
+
+#line 283 "VBNET.ATG"
+ node = new OptionDeclaration(OptionType.Strict, val);
+ } else if (la.kind == 87) {
+ lexer.NextToken();
+ if (la.kind == 67) {
+ lexer.NextToken();
+
+#line 285 "VBNET.ATG"
+ node = new OptionDeclaration(OptionType.CompareBinary, val);
+ } else if (la.kind == 213) {
+ lexer.NextToken();
+
+#line 286 "VBNET.ATG"
+ node = new OptionDeclaration(OptionType.CompareText, val);
+ } else SynErr(241);
+ } else if (la.kind == 139) {
+ lexer.NextToken();
+ if (la.kind == 170 || la.kind == 171) {
+ OptionValue(
+#line 289 "VBNET.ATG"
+ref val);
+ }
+
+#line 290 "VBNET.ATG"
+ node = new OptionDeclaration(OptionType.Infer, val);
+ } else SynErr(242);
+ EndOfStmt();
+
+#line 294 "VBNET.ATG"
+ if (node != null) {
+ node.StartLocation = startPos;
+ node.EndLocation = t.Location;
+ AddChild(node);
+ }
+
+ }
+
+ void ImportsStmt() {
+
+#line 315 "VBNET.ATG"
+ List usings = new List();
+
+ Expect(137);
+
+#line 319 "VBNET.ATG"
+ Location startPos = t.Location;
+ Using u;
+
+ ImportClause(
+#line 322 "VBNET.ATG"
+out u);
+
+#line 322 "VBNET.ATG"
+ if (u != null) { usings.Add(u); }
+ while (la.kind == 22) {
+ lexer.NextToken();
+ ImportClause(
+#line 324 "VBNET.ATG"
+out u);
+
+#line 324 "VBNET.ATG"
+ if (u != null) { usings.Add(u); }
+ }
+ EndOfStmt();
+
+#line 328 "VBNET.ATG"
+ UsingDeclaration usingDeclaration = new UsingDeclaration(usings);
+ usingDeclaration.StartLocation = startPos;
+ usingDeclaration.EndLocation = t.Location;
+ AddChild(usingDeclaration);
+
+ }
+
+ void GlobalAttributeSection() {
+ Expect(40);
+
+#line 2826 "VBNET.ATG"
+ Location startPos = t.Location;
+ if (la.kind == 65) {
+ lexer.NextToken();
+ } else if (la.kind == 155) {
+ lexer.NextToken();
+ } else SynErr(243);
+
+#line 2828 "VBNET.ATG"
+ string attributeTarget = t.val != null ? t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture) : null;
+ List attributes = new List();
+ ASTAttribute attribute;
+
+ Expect(21);
+ Attribute(
+#line 2832 "VBNET.ATG"
+out attribute);
+
+#line 2832 "VBNET.ATG"
+ attributes.Add(attribute);
+ while (
+#line 2833 "VBNET.ATG"
+NotFinalComma()) {
+ if (la.kind == 22) {
+ lexer.NextToken();
+ if (la.kind == 65) {
+ lexer.NextToken();
+ } else if (la.kind == 155) {
+ lexer.NextToken();
+ } else SynErr(244);
+ Expect(21);
+ }
+ Attribute(
+#line 2833 "VBNET.ATG"
+out attribute);
+
+#line 2833 "VBNET.ATG"
+ attributes.Add(attribute);
+ }
+ if (la.kind == 22) {
+ lexer.NextToken();
+ }
+ Expect(39);
+ EndOfStmt();
+
+#line 2838 "VBNET.ATG"
+ AttributeSection section = new AttributeSection {
+ AttributeTarget = attributeTarget,
+ Attributes = attributes,
+ StartLocation = startPos,
+ EndLocation = t.EndLocation
+ };
+ AddChild(section);
+
+ }
+
+ void NamespaceMemberDecl() {
+
+#line 361 "VBNET.ATG"
+ ModifierList m = new ModifierList();
+ AttributeSection section;
+ List attributes = new List();
+ string qualident;
+
+ if (la.kind == 160) {
+ lexer.NextToken();
+
+#line 368 "VBNET.ATG"
+ Location startPos = t.Location;
+
+ Qualident(
+#line 370 "VBNET.ATG"
+out qualident);
+
+#line 372 "VBNET.ATG"
+ INode node = new NamespaceDeclaration(qualident);
+ node.StartLocation = startPos;
+ AddChild(node);
+ BlockStart(node);
+
+ EndOfStmt();
+ NamespaceBody();
+
+#line 380 "VBNET.ATG"
+ node.EndLocation = t.Location;
+ BlockEnd();
+
+ } else if (StartOf(2)) {
+ while (la.kind == 40) {
+ AttributeSection(
+#line 384 "VBNET.ATG"
+out section);
+
+#line 384 "VBNET.ATG"
+ attributes.Add(section);
+ }
+ while (StartOf(3)) {
+ TypeModifier(
+#line 385 "VBNET.ATG"
+m);
+ }
+ NonModuleDeclaration(
+#line 385 "VBNET.ATG"
+m, attributes);
+ } else SynErr(245);
+ }
+
+ void OptionValue(
+#line 302 "VBNET.ATG"
+ref bool val) {
+ if (la.kind == 171) {
+ lexer.NextToken();
+
+#line 304 "VBNET.ATG"
+ val = true;
+ } else if (la.kind == 170) {
+ lexer.NextToken();
+
+#line 306 "VBNET.ATG"
+ val = false;
+ } else SynErr(246);
+ }
+
+ void ImportClause(
+#line 335 "VBNET.ATG"
+out Using u) {
+
+#line 337 "VBNET.ATG"
+ string qualident = null;
+ TypeReference aliasedType = null;
+ u = null;
+
+ if (StartOf(4)) {
+ Qualident(
+#line 342 "VBNET.ATG"
+out qualident);
+ if (la.kind == 20) {
+ lexer.NextToken();
+ TypeName(
+#line 343 "VBNET.ATG"
+out aliasedType);
+ }
+
+#line 345 "VBNET.ATG"
+ if (qualident != null && qualident.Length > 0) {
+ if (aliasedType != null) {
+ u = new Using(qualident, aliasedType);
+ } else {
+ u = new Using(qualident);
+ }
+ }
+
+ } else if (la.kind == 10) {
+
+#line 353 "VBNET.ATG"
+ string prefix = null;
+ lexer.NextToken();
+ Identifier();
+
+#line 354 "VBNET.ATG"
+ prefix = t.val;
+ Expect(20);
+ Expect(3);
+
+#line 354 "VBNET.ATG"
+ u = new Using(t.literalValue as string, prefix);
+ Expect(11);
+ } else SynErr(247);
+ }
+
+ void Qualident(
+#line 3626 "VBNET.ATG"
+out string qualident) {
+
+#line 3628 "VBNET.ATG"
+ string name;
+ qualidentBuilder.Length = 0;
+
+ Identifier();
+
+#line 3632 "VBNET.ATG"
+ qualidentBuilder.Append(t.val);
+ while (
+#line 3633 "VBNET.ATG"
+DotAndIdentOrKw()) {
+ Expect(26);
+ IdentifierOrKeyword(
+#line 3633 "VBNET.ATG"
+out name);
+
+#line 3633 "VBNET.ATG"
+ qualidentBuilder.Append('.'); qualidentBuilder.Append(name);
+ }
+
+#line 3635 "VBNET.ATG"
+ qualident = qualidentBuilder.ToString();
+ }
+
+ void TypeName(
+#line 2697 "VBNET.ATG"
+out TypeReference typeref) {
+
+#line 2698 "VBNET.ATG"
+ ArrayList rank = null; Location startLocation = la.Location;
+ NonArrayTypeName(
+#line 2700 "VBNET.ATG"
+out typeref, false);
+ ArrayTypeModifiers(
+#line 2701 "VBNET.ATG"
+out rank);
+
+#line 2703 "VBNET.ATG"
+ if (typeref != null) {
+ if (rank != null) {
+ typeref.RankSpecifier = (int[])rank.ToArray(typeof(int));
+ }
+ typeref.StartLocation = startLocation;
+ typeref.EndLocation = t.EndLocation;
+ }
+
+ }
+
+ void Identifier() {
+ if (StartOf(5)) {
+ IdentifierForFieldDeclaration();
+ } else if (la.kind == 98) {
+ lexer.NextToken();
+ } else SynErr(248);
+ }
+
+ void NamespaceBody() {
+ while (la.kind == 1 || la.kind == 21) {
+ EndOfStmt();
+ }
+ while (StartOf(1)) {
+ NamespaceMemberDecl();
+ while (la.kind == 1 || la.kind == 21) {
+ EndOfStmt();
+ }
+ }
+ Expect(113);
+ Expect(160);
+ EndOfStmt();
+ }
+
+ void AttributeSection(
+#line 2904 "VBNET.ATG"
+out AttributeSection section) {
+
+#line 2906 "VBNET.ATG"
+ string attributeTarget = "";
+ List attributes = new List();
+ ASTAttribute attribute;
+ Location startLocation = la.Location;
+
+ Expect(40);
+ if (
+#line 2912 "VBNET.ATG"
+IsLocalAttrTarget()) {
+ if (la.kind == 119) {
+ lexer.NextToken();
+
+#line 2913 "VBNET.ATG"
+ attributeTarget = "event";
+ } else if (la.kind == 195) {
+ lexer.NextToken();
+
+#line 2914 "VBNET.ATG"
+ attributeTarget = "return";
+ } else {
+ Identifier();
+
+#line 2917 "VBNET.ATG"
+ string val = t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture);
+ if (val != "field" || val != "method" ||
+ val != "module" || val != "param" ||
+ val != "property" || val != "type")
+ Error("attribute target specifier (event, return, field," +
+ "method, module, param, property, or type) expected");
+ attributeTarget = t.val;
+
+ }
+ Expect(21);
+ }
+ Attribute(
+#line 2927 "VBNET.ATG"
+out attribute);
+
+#line 2927 "VBNET.ATG"
+ attributes.Add(attribute);
+ while (
+#line 2928 "VBNET.ATG"
+NotFinalComma()) {
+ Expect(22);
+ Attribute(
+#line 2928 "VBNET.ATG"
+out attribute);
+
+#line 2928 "VBNET.ATG"
+ attributes.Add(attribute);
+ }
+ if (la.kind == 22) {
+ lexer.NextToken();
+ }
+ Expect(39);
+
+#line 2932 "VBNET.ATG"
+ section = new AttributeSection {
+ AttributeTarget = attributeTarget,
+ Attributes = attributes,
+ StartLocation = startLocation,
+ EndLocation = t.EndLocation
+ };
+
+ }
+
+ void TypeModifier(
+#line 3711 "VBNET.ATG"
+ModifierList m) {
+ switch (la.kind) {
+ case 188: {
+ lexer.NextToken();
+
+#line 3712 "VBNET.ATG"
+ m.Add(Modifiers.Public, t.Location);
+ break;
+ }
+ case 187: {
+ lexer.NextToken();
+
+#line 3713 "VBNET.ATG"
+ m.Add(Modifiers.Protected, t.Location);
+ break;
+ }
+ case 125: {
+ lexer.NextToken();
+
+#line 3714 "VBNET.ATG"
+ m.Add(Modifiers.Internal, t.Location);
+ break;
+ }
+ case 185: {
+ lexer.NextToken();
+
+#line 3715 "VBNET.ATG"
+ m.Add(Modifiers.Private, t.Location);
+ break;
+ }
+ case 200: {
+ lexer.NextToken();
+
+#line 3716 "VBNET.ATG"
+ m.Add(Modifiers.Static, t.Location);
+ break;
+ }
+ case 199: {
+ lexer.NextToken();
+
+#line 3717 "VBNET.ATG"
+ m.Add(Modifiers.New, t.Location);
+ break;
+ }
+ case 156: {
+ lexer.NextToken();
+
+#line 3718 "VBNET.ATG"
+ m.Add(Modifiers.Abstract, t.Location);
+ break;
+ }
+ case 166: {
+ lexer.NextToken();
+
+#line 3719 "VBNET.ATG"
+ m.Add(Modifiers.Sealed, t.Location);
+ break;
+ }
+ case 183: {
+ lexer.NextToken();
+
+#line 3720 "VBNET.ATG"
+ m.Add(Modifiers.Partial, t.Location);
+ break;
+ }
+ default: SynErr(249); break;
+ }
+ }
+
+ void NonModuleDeclaration(
+#line 455 "VBNET.ATG"
+ModifierList m, List attributes) {
+
+#line 457 "VBNET.ATG"
+ TypeReference typeRef = null;
+ List baseInterfaces = null;
+
+ switch (la.kind) {
+ case 84: {
+
+#line 460 "VBNET.ATG"
+ m.Check(Modifiers.Classes);
+ lexer.NextToken();
+
+#line 463 "VBNET.ATG"
+ TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
+ newType.StartLocation = t.Location;
+ AddChild(newType);
+ BlockStart(newType);
+
+ newType.Type = ClassType.Class;
+
+ Identifier();
+
+#line 470 "VBNET.ATG"
+ newType.Name = t.val;
+ TypeParameterList(
+#line 471 "VBNET.ATG"
+newType.Templates);
+ EndOfStmt();
+
+#line 473 "VBNET.ATG"
+ newType.BodyStartLocation = t.Location;
+ if (la.kind == 140) {
+ ClassBaseType(
+#line 474 "VBNET.ATG"
+out typeRef);
+
+#line 474 "VBNET.ATG"
+ SafeAdd(newType, newType.BaseTypes, typeRef);
+ }
+ while (la.kind == 136) {
+ TypeImplementsClause(
+#line 475 "VBNET.ATG"
+out baseInterfaces);
+
+#line 475 "VBNET.ATG"
+ newType.BaseTypes.AddRange(baseInterfaces);
+ }
+ ClassBody(
+#line 476 "VBNET.ATG"
+newType);
+ Expect(113);
+ Expect(84);
+
+#line 477 "VBNET.ATG"
+ newType.EndLocation = t.EndLocation;
+ EndOfStmt();
+
+#line 480 "VBNET.ATG"
+ BlockEnd();
+
+ break;
+ }
+ case 155: {
+ lexer.NextToken();
+
+#line 484 "VBNET.ATG"
+ m.Check(Modifiers.VBModules);
+ TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
+ AddChild(newType);
+ BlockStart(newType);
+ newType.StartLocation = m.GetDeclarationLocation(t.Location);
+ newType.Type = ClassType.Module;
+
+ Identifier();
+
+#line 491 "VBNET.ATG"
+ newType.Name = t.val;
+ EndOfStmt();
+
+#line 493 "VBNET.ATG"
+ newType.BodyStartLocation = t.Location;
+ ModuleBody(
+#line 494 "VBNET.ATG"
+newType);
+
+#line 496 "VBNET.ATG"
+ BlockEnd();
+
+ break;
+ }
+ case 209: {
+ lexer.NextToken();
+
+#line 500 "VBNET.ATG"
+ m.Check(Modifiers.VBStructures);
+ TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
+ AddChild(newType);
+ BlockStart(newType);
+ newType.StartLocation = m.GetDeclarationLocation(t.Location);
+ newType.Type = ClassType.Struct;
+
+ Identifier();
+
+#line 507 "VBNET.ATG"
+ newType.Name = t.val;
+ TypeParameterList(
+#line 508 "VBNET.ATG"
+newType.Templates);
+ EndOfStmt();
+
+#line 510 "VBNET.ATG"
+ newType.BodyStartLocation = t.Location;
+ while (la.kind == 136) {
+ TypeImplementsClause(
+#line 511 "VBNET.ATG"
+out baseInterfaces);
+
+#line 511 "VBNET.ATG"
+ newType.BaseTypes.AddRange(baseInterfaces);
+ }
+ StructureBody(
+#line 512 "VBNET.ATG"
+newType);
+
+#line 514 "VBNET.ATG"
+ BlockEnd();
+
+ break;
+ }
+ case 115: {
+ lexer.NextToken();
+
+#line 519 "VBNET.ATG"
+ m.Check(Modifiers.VBEnums);
+ TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
+ newType.StartLocation = m.GetDeclarationLocation(t.Location);
+ AddChild(newType);
+ BlockStart(newType);
+
+ newType.Type = ClassType.Enum;
+
+ Identifier();
+
+#line 527 "VBNET.ATG"
+ newType.Name = t.val;
+ if (la.kind == 63) {
+ lexer.NextToken();
+ NonArrayTypeName(
+#line 528 "VBNET.ATG"
+out typeRef, false);
+
+#line 528 "VBNET.ATG"
+ SafeAdd(newType, newType.BaseTypes, typeRef);
+ }
+ EndOfStmt();
+
+#line 530 "VBNET.ATG"
+ newType.BodyStartLocation = t.Location;
+ EnumBody(
+#line 531 "VBNET.ATG"
+newType);
+
+#line 533 "VBNET.ATG"
+ BlockEnd();
+
+ break;
+ }
+ case 142: {
+ lexer.NextToken();
+
+#line 538 "VBNET.ATG"
+ m.Check(Modifiers.VBInterfacs);
+ TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
+ newType.StartLocation = m.GetDeclarationLocation(t.Location);
+ AddChild(newType);
+ BlockStart(newType);
+ newType.Type = ClassType.Interface;
+
+ Identifier();
+
+#line 545 "VBNET.ATG"
+ newType.Name = t.val;
+ TypeParameterList(
+#line 546 "VBNET.ATG"
+newType.Templates);
+ EndOfStmt();
+
+#line 548 "VBNET.ATG"
+ newType.BodyStartLocation = t.Location;
+ while (la.kind == 140) {
+ InterfaceBase(
+#line 549 "VBNET.ATG"
+out baseInterfaces);
+
+#line 549 "VBNET.ATG"
+ newType.BaseTypes.AddRange(baseInterfaces);
+ }
+ InterfaceBody(
+#line 550 "VBNET.ATG"
+newType);
+
+#line 552 "VBNET.ATG"
+ BlockEnd();
+
+ break;
+ }
+ case 103: {
+ lexer.NextToken();
+
+#line 557 "VBNET.ATG"
+ m.Check(Modifiers.VBDelegates);
+ DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes);
+ delegateDeclr.ReturnType = new TypeReference("System.Void", true);
+ delegateDeclr.StartLocation = m.GetDeclarationLocation(t.Location);
+ List p = new List();
+
+ if (la.kind == 210) {
+ lexer.NextToken();
+ Identifier();
+
+#line 564 "VBNET.ATG"
+ delegateDeclr.Name = t.val;
+ TypeParameterList(
+#line 565 "VBNET.ATG"
+delegateDeclr.Templates);
+ if (la.kind == 37) {
+ lexer.NextToken();
+ if (StartOf(6)) {
+ FormalParameterList(
+#line 566 "VBNET.ATG"
+p);
+ }
+ Expect(38);
+
+#line 566 "VBNET.ATG"
+ delegateDeclr.Parameters = p;
+ }
+ } else if (la.kind == 127) {
+ lexer.NextToken();
+ Identifier();
+
+#line 568 "VBNET.ATG"
+ delegateDeclr.Name = t.val;
+ TypeParameterList(
+#line 569 "VBNET.ATG"
+delegateDeclr.Templates);
+ if (la.kind == 37) {
+ lexer.NextToken();
+ if (StartOf(6)) {
+ FormalParameterList(
+#line 570 "VBNET.ATG"
+p);
+ }
+ Expect(38);
+
+#line 570 "VBNET.ATG"
+ delegateDeclr.Parameters = p;
+ }
+ if (la.kind == 63) {
+ lexer.NextToken();
+
+#line 571 "VBNET.ATG"
+ TypeReference type;
+ TypeName(
+#line 571 "VBNET.ATG"
+out type);
+
+#line 571 "VBNET.ATG"
+ delegateDeclr.ReturnType = type;
+ }
+ } else SynErr(250);
+
+#line 573 "VBNET.ATG"
+ delegateDeclr.EndLocation = t.EndLocation;
+ EndOfStmt();
+
+#line 576 "VBNET.ATG"
+ AddChild(delegateDeclr);
+
+ break;
+ }
+ default: SynErr(251); break;
+ }
+ }
+
+ void TypeParameterList(
+#line 389 "VBNET.ATG"
+List templates) {
+
+#line 391 "VBNET.ATG"
+ TemplateDefinition template;
+
+ if (
+#line 395 "VBNET.ATG"
+la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) {
+ lexer.NextToken();
+ Expect(169);
+ TypeParameter(
+#line 396 "VBNET.ATG"
+out template);
+
+#line 398 "VBNET.ATG"
+ if (template != null) templates.Add(template);
+
+ while (la.kind == 22) {
+ lexer.NextToken();
+ TypeParameter(
+#line 401 "VBNET.ATG"
+out template);
+
+#line 403 "VBNET.ATG"
+ if (template != null) templates.Add(template);
+
+ }
+ Expect(38);
+ }
+ }
+
+ void TypeParameter(
+#line 411 "VBNET.ATG"
+out TemplateDefinition template) {
+
+#line 412 "VBNET.ATG"
+ VarianceModifier modifier = VarianceModifier.Invariant; Location startLocation = la.Location;
+ if (la.kind == 138 || la.kind == 178) {
+ if (la.kind == 138) {
+ lexer.NextToken();
+
+#line 415 "VBNET.ATG"
+ modifier = VarianceModifier.Contravariant;
+ } else {
+ lexer.NextToken();
+
+#line 415 "VBNET.ATG"
+ modifier = VarianceModifier.Covariant;
+ }
+ }
+ Identifier();
+
+#line 415 "VBNET.ATG"
+ template = new TemplateDefinition(t.val, null) { VarianceModifier = modifier };
+ if (la.kind == 63) {
+ TypeParameterConstraints(
+#line 416 "VBNET.ATG"
+template);
+ }
+
+#line 419 "VBNET.ATG"
+ if (template != null) {
+ template.StartLocation = startLocation;
+ template.EndLocation = t.EndLocation;
+ }
+
+ }
+
+ void TypeParameterConstraints(
+#line 427 "VBNET.ATG"
+TemplateDefinition template) {
+
+#line 429 "VBNET.ATG"
+ TypeReference constraint;
+
+ Expect(63);
+ if (la.kind == 35) {
+ lexer.NextToken();
+ TypeParameterConstraint(
+#line 435 "VBNET.ATG"
+out constraint);
+
+#line 435 "VBNET.ATG"
+ if (constraint != null) { template.Bases.Add(constraint); }
+ while (la.kind == 22) {
+ lexer.NextToken();
+ TypeParameterConstraint(
+#line 438 "VBNET.ATG"
+out constraint);
+
+#line 438 "VBNET.ATG"
+ if (constraint != null) { template.Bases.Add(constraint); }
+ }
+ Expect(36);
+ } else if (StartOf(7)) {
+ TypeParameterConstraint(
+#line 441 "VBNET.ATG"
+out constraint);
+
+#line 441 "VBNET.ATG"
+ if (constraint != null) { template.Bases.Add(constraint); }
+ } else SynErr(252);
+ }
+
+ void TypeParameterConstraint(
+#line 445 "VBNET.ATG"
+out TypeReference constraint) {
+
+#line 446 "VBNET.ATG"
+ constraint = null; Location startLocation = la.Location;
+ if (la.kind == 84) {
+ lexer.NextToken();
+
+#line 448 "VBNET.ATG"
+ constraint = TypeReference.ClassConstraint;
+ } else if (la.kind == 209) {
+ lexer.NextToken();
+
+#line 449 "VBNET.ATG"
+ constraint = TypeReference.StructConstraint;
+ } else if (la.kind == 162) {
+ lexer.NextToken();
+
+#line 450 "VBNET.ATG"
+ constraint = TypeReference.NewConstraint;
+ } else if (StartOf(8)) {
+ TypeName(
+#line 451 "VBNET.ATG"
+out constraint);
+ } else SynErr(253);
+ }
+
+ void ClassBaseType(
+#line 797 "VBNET.ATG"
+out TypeReference typeRef) {
+
+#line 799 "VBNET.ATG"
+ typeRef = null;
+
+ Expect(140);
+ TypeName(
+#line 802 "VBNET.ATG"
+out typeRef);
+ EndOfStmt();
+ }
+
+ void TypeImplementsClause(
+#line 1620 "VBNET.ATG"
+out List baseInterfaces) {
+
+#line 1622 "VBNET.ATG"
+ baseInterfaces = new List();
+ TypeReference type = null;
+
+ Expect(136);
+ TypeName(
+#line 1625 "VBNET.ATG"
+out type);
+
+#line 1627 "VBNET.ATG"
+ if (type != null) baseInterfaces.Add(type);
+
+ while (la.kind == 22) {
+ lexer.NextToken();
+ TypeName(
+#line 1630 "VBNET.ATG"
+out type);
+
+#line 1631 "VBNET.ATG"
+ if (type != null) baseInterfaces.Add(type);
+ }
+ EndOfStmt();
+ }
+
+ void ClassBody(
+#line 590 "VBNET.ATG"
+TypeDeclaration newType) {
+
+#line 591 "VBNET.ATG"
+ AttributeSection section;
+ while (la.kind == 1 || la.kind == 21) {
+ EndOfStmt();
+ }
+ while (StartOf(9)) {
+
+#line 594 "VBNET.ATG"
+ List attributes = new List();
+ ModifierList m = new ModifierList();
+
+ while (la.kind == 40) {
+ AttributeSection(
+#line 597 "VBNET.ATG"
+out section);
+
+#line 597 "VBNET.ATG"
+ attributes.Add(section);
+ }
+ while (StartOf(10)) {
+ MemberModifier(
+#line 598 "VBNET.ATG"
+m);
+ }
+ ClassMemberDecl(
+#line 599 "VBNET.ATG"
+m, attributes);
+ while (la.kind == 1 || la.kind == 21) {
+ EndOfStmt();
+ }
+ }
+ }
+
+ void ModuleBody(
+#line 621 "VBNET.ATG"
+TypeDeclaration newType) {
+
+#line 622 "VBNET.ATG"
+ AttributeSection section;
+ while (la.kind == 1 || la.kind == 21) {
+ EndOfStmt();
+ }
+ while (StartOf(9)) {
+
+#line 625 "VBNET.ATG"
+ List attributes = new List();
+ ModifierList m = new ModifierList();
+
+ while (la.kind == 40) {
+ AttributeSection(
+#line 628 "VBNET.ATG"
+out section);
+
+#line 628 "VBNET.ATG"
+ attributes.Add(section);
+ }
+ while (StartOf(10)) {
+ MemberModifier(
+#line 629 "VBNET.ATG"
+m);
+ }
+ ClassMemberDecl(
+#line 630 "VBNET.ATG"
+m, attributes);
+ while (la.kind == 1 || la.kind == 21) {
+ EndOfStmt();
+ }
+ }
+ Expect(113);
+ Expect(155);
+
+#line 633 "VBNET.ATG"
+ newType.EndLocation = t.EndLocation;
+ EndOfStmt();
+ }
+
+ void StructureBody(
+#line 604 "VBNET.ATG"
+TypeDeclaration newType) {
+
+#line 605 "VBNET.ATG"
+ AttributeSection section;
+ while (la.kind == 1 || la.kind == 21) {
+ EndOfStmt();
+ }
+ while (StartOf(9)) {
+
+#line 608 "VBNET.ATG"
+ List attributes = new List();
+ ModifierList m = new ModifierList();
+
+ while (la.kind == 40) {
+ AttributeSection(
+#line 611 "VBNET.ATG"
+out section);
+
+#line 611 "VBNET.ATG"
+ attributes.Add(section);
+ }
+ while (StartOf(10)) {
+ MemberModifier(
+#line 612 "VBNET.ATG"
+m);
+ }
+ StructureMemberDecl(
+#line 613 "VBNET.ATG"
+m, attributes);
+ while (la.kind == 1 || la.kind == 21) {
+ EndOfStmt();
+ }
+ }
+ Expect(113);
+ Expect(209);
+
+#line 616 "VBNET.ATG"
+ newType.EndLocation = t.EndLocation;
+ EndOfStmt();
+ }
+
+ void NonArrayTypeName(
+#line 2725 "VBNET.ATG"
+out TypeReference typeref, bool canBeUnbound) {
+
+#line 2727 "VBNET.ATG"
+ string name;
+ typeref = null;
+ bool isGlobal = false;
+
+ if (StartOf(11)) {
+ if (la.kind == 130) {
+ lexer.NextToken();
+ Expect(26);
+
+#line 2732 "VBNET.ATG"
+ isGlobal = true;
+ }
+ QualIdentAndTypeArguments(
+#line 2733 "VBNET.ATG"
+out typeref, canBeUnbound);
+
+#line 2734 "VBNET.ATG"
+ typeref.IsGlobal = isGlobal;
+ while (la.kind == 26) {
+ lexer.NextToken();
+
+#line 2735 "VBNET.ATG"
+ TypeReference nestedTypeRef;
+ QualIdentAndTypeArguments(
+#line 2736 "VBNET.ATG"
+out nestedTypeRef, canBeUnbound);
+
+#line 2737 "VBNET.ATG"
+ typeref = new InnerClassTypeReference(typeref, nestedTypeRef.Type, nestedTypeRef.GenericTypes);
+ }
+ } else if (la.kind == 168) {
+ lexer.NextToken();
+
+#line 2740 "VBNET.ATG"
+ typeref = new TypeReference("System.Object", true);
+ if (la.kind == 33) {
+ lexer.NextToken();
+
+#line 2744 "VBNET.ATG"
+ List typeArguments = new List(1);
+ if (typeref != null) typeArguments.Add(typeref);
+ typeref = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true };
+
+ }
+ } else if (StartOf(12)) {
+ PrimitiveTypeName(
+#line 2750 "VBNET.ATG"
+out name);
+
+#line 2750 "VBNET.ATG"
+ typeref = new TypeReference(name, true);
+ if (la.kind == 33) {
+ lexer.NextToken();
+
+#line 2754 "VBNET.ATG"
+ List typeArguments = new List(1);
+ if (typeref != null) typeArguments.Add(typeref);
+ typeref = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true };
+
+ }
+ } else SynErr(254);
+ }
+
+ void EnumBody(
+#line 637 "VBNET.ATG"
+TypeDeclaration newType) {
+
+#line 638 "VBNET.ATG"
+ FieldDeclaration f;
+ while (la.kind == 1 || la.kind == 21) {
+ EndOfStmt();
+ }
+ while (StartOf(13)) {
+ EnumMemberDecl(
+#line 641 "VBNET.ATG"
+out f);
+
+#line 643 "VBNET.ATG"
+ AddChild(f);
+
+ while (la.kind == 1 || la.kind == 21) {
+ EndOfStmt();
+ }
+ }
+ Expect(113);
+ Expect(115);
+
+#line 647 "VBNET.ATG"
+ newType.EndLocation = t.EndLocation;
+ EndOfStmt();
+ }
+
+ void InterfaceBase(
+#line 1605 "VBNET.ATG"
+out List bases) {
+
+#line 1607 "VBNET.ATG"
+ TypeReference type;
+ bases = new List();
+
+ Expect(140);
+ TypeName(
+#line 1611 "VBNET.ATG"
+out type);
+
+#line 1611 "VBNET.ATG"
+ if (type != null) bases.Add(type);
+ while (la.kind == 22) {
+ lexer.NextToken();
+ TypeName(
+#line 1614 "VBNET.ATG"
+out type);
+
+#line 1614 "VBNET.ATG"
+ if (type != null) bases.Add(type);
+ }
+ EndOfStmt();
+ }
+
+ void InterfaceBody(
+#line 651 "VBNET.ATG"
+TypeDeclaration newType) {
+ while (la.kind == 1 || la.kind == 21) {
+ EndOfStmt();
+ }
+ while (StartOf(14)) {
+ InterfaceMemberDecl();
+ while (la.kind == 1 || la.kind == 21) {
+ EndOfStmt();
+ }
+ }
+ Expect(113);
+ Expect(142);
+
+#line 657 "VBNET.ATG"
+ newType.EndLocation = t.EndLocation;
+ EndOfStmt();
+ }
+
+ void FormalParameterList(
+#line 2942 "VBNET.ATG"
+List parameter) {
+
+#line 2943 "VBNET.ATG"
+ ParameterDeclarationExpression p;
+ FormalParameter(
+#line 2945 "VBNET.ATG"
+out p);
+
+#line 2945 "VBNET.ATG"
+ if (p != null) parameter.Add(p);
+ while (la.kind == 22) {
+ lexer.NextToken();
+ FormalParameter(
+#line 2947 "VBNET.ATG"
+out p);
+
+#line 2947 "VBNET.ATG"
+ if (p != null) parameter.Add(p);
+ }
+ }
+
+ void MemberModifier(
+#line 3723 "VBNET.ATG"
+ModifierList m) {
+ switch (la.kind) {
+ case 156: {
+ lexer.NextToken();
+
+#line 3724 "VBNET.ATG"
+ m.Add(Modifiers.Abstract, t.Location);
+ break;
+ }
+ case 102: {
+ lexer.NextToken();
+
+#line 3725 "VBNET.ATG"
+ m.Add(Modifiers.Default, t.Location);
+ break;
+ }
+ case 125: {
+ lexer.NextToken();
+
+#line 3726 "VBNET.ATG"
+ m.Add(Modifiers.Internal, t.Location);
+ break;
+ }
+ case 199: {
+ lexer.NextToken();
+
+#line 3727 "VBNET.ATG"
+ m.Add(Modifiers.New, t.Location);
+ break;
+ }
+ case 181: {
+ lexer.NextToken();
+
+#line 3728 "VBNET.ATG"
+ m.Add(Modifiers.Override, t.Location);
+ break;
+ }
+ case 157: {
+ lexer.NextToken();
+
+#line 3729 "VBNET.ATG"
+ m.Add(Modifiers.Abstract, t.Location);
+ break;
+ }
+ case 185: {
+ lexer.NextToken();
+
+#line 3730 "VBNET.ATG"
+ m.Add(Modifiers.Private, t.Location);
+ break;
+ }
+ case 187: {
+ lexer.NextToken();
+
+#line 3731 "VBNET.ATG"
+ m.Add(Modifiers.Protected, t.Location);
+ break;
+ }
+ case 188: {
+ lexer.NextToken();
+
+#line 3732 "VBNET.ATG"
+ m.Add(Modifiers.Public, t.Location);
+ break;
+ }
+ case 166: {
+ lexer.NextToken();
+
+#line 3733 "VBNET.ATG"
+ m.Add(Modifiers.Sealed, t.Location);
+ break;
+ }
+ case 167: {
+ lexer.NextToken();
+
+#line 3734 "VBNET.ATG"
+ m.Add(Modifiers.Sealed, t.Location);
+ break;
+ }
+ case 200: {
+ lexer.NextToken();
+
+#line 3735 "VBNET.ATG"
+ m.Add(Modifiers.Static, t.Location);
+ break;
+ }
+ case 180: {
+ lexer.NextToken();
+
+#line 3736 "VBNET.ATG"
+ m.Add(Modifiers.Virtual, t.Location);
+ break;
+ }
+ case 179: {
+ lexer.NextToken();
+
+#line 3737 "VBNET.ATG"
+ m.Add(Modifiers.Overloads, t.Location);
+ break;
+ }
+ case 190: {
+ lexer.NextToken();
+
+#line 3738 "VBNET.ATG"
+ m.Add(Modifiers.ReadOnly, t.Location);
+ break;
+ }
+ case 235: {
+ lexer.NextToken();
+
+#line 3739 "VBNET.ATG"
+ m.Add(Modifiers.WriteOnly, t.Location);
+ break;
+ }
+ case 234: {
+ lexer.NextToken();
+
+#line 3740 "VBNET.ATG"
+ m.Add(Modifiers.WithEvents, t.Location);
+ break;
+ }
+ case 105: {
+ lexer.NextToken();
+
+#line 3741 "VBNET.ATG"
+ m.Add(Modifiers.Dim, t.Location);
+ break;
+ }
+ case 183: {
+ lexer.NextToken();
+
+#line 3742 "VBNET.ATG"
+ m.Add(Modifiers.Partial, t.Location);
+ break;
+ }
+ default: SynErr(255); break;
+ }
+ }
+
+ void ClassMemberDecl(
+#line 793 "VBNET.ATG"
+ModifierList m, List attributes) {
+ StructureMemberDecl(
+#line 794 "VBNET.ATG"
+m, attributes);
+ }
+
+ void StructureMemberDecl(
+#line 807 "VBNET.ATG"
+ModifierList m, List attributes) {
+
+#line 809 "VBNET.ATG"
+ TypeReference type = null;
+ List p = new List();
+ Statement stmt = null;
+ List variableDeclarators = new List();
+ List templates = new List();
+
+ switch (la.kind) {
+ case 84: case 103: case 115: case 142: case 155: case 209: {
+ NonModuleDeclaration(
+#line 816 "VBNET.ATG"
+m, attributes);
+ break;
+ }
+ case 210: {
+ lexer.NextToken();
+
+#line 820 "VBNET.ATG"
+ Location startPos = t.Location;
+
+ if (StartOf(4)) {
+
+#line 824 "VBNET.ATG"
+ string name = String.Empty;
+ MethodDeclaration methodDeclaration; List handlesClause = null;
+ List implementsClause = null;
+
+ Identifier();
+
+#line 830 "VBNET.ATG"
+ name = t.val;
+ m.Check(Modifiers.VBMethods);
+
+ TypeParameterList(
+#line 833 "VBNET.ATG"
+templates);
+ if (la.kind == 37) {
+ lexer.NextToken();
+ if (StartOf(6)) {
+ FormalParameterList(
+#line 834 "VBNET.ATG"
+p);
+ }
+ Expect(38);
+ }
+ if (la.kind == 134 || la.kind == 136) {
+ if (la.kind == 136) {
+ ImplementsClause(
+#line 837 "VBNET.ATG"
+out implementsClause);
+ } else {
+ HandlesClause(
+#line 839 "VBNET.ATG"
+out handlesClause);
+ }
+ }
+
+#line 842 "VBNET.ATG"
+ Location endLocation = t.EndLocation;
+ if (
+#line 845 "VBNET.ATG"
+IsMustOverride(m)) {
+ EndOfStmt();
+
+#line 848 "VBNET.ATG"
+ methodDeclaration = new MethodDeclaration {
+ Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes,
+ StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation,
+ TypeReference = new TypeReference("System.Void", true),
+ Templates = templates,
+ HandlesClause = handlesClause,
+ InterfaceImplementations = implementsClause
+ };
+ AddChild(methodDeclaration);
+
+ } else if (la.kind == 1) {
+ lexer.NextToken();
+
+#line 861 "VBNET.ATG"
+ methodDeclaration = new MethodDeclaration {
+ Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes,
+ StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation,
+ TypeReference = new TypeReference("System.Void", true),
+ Templates = templates,
+ HandlesClause = handlesClause,
+ InterfaceImplementations = implementsClause
+ };
+ AddChild(methodDeclaration);
+
+
+#line 872 "VBNET.ATG"
+ if (ParseMethodBodies) {
+ Block(
+#line 873 "VBNET.ATG"
+out stmt);
+ Expect(113);
+ Expect(210);
+
+#line 875 "VBNET.ATG"
+ } else {
+ // don't parse method body
+ lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement();
+ }
+
+
+#line 881 "VBNET.ATG"
+ methodDeclaration.Body = (BlockStatement)stmt;
+
+#line 882 "VBNET.ATG"
+ methodDeclaration.Body.EndLocation = t.EndLocation;
+ EndOfStmt();
+ } else SynErr(256);
+ } else if (la.kind == 162) {
+ lexer.NextToken();
+ if (la.kind == 37) {
+ lexer.NextToken();
+ if (StartOf(6)) {
+ FormalParameterList(
+#line 886 "VBNET.ATG"
+p);
+ }
+ Expect(38);
+ }
+
+#line 887 "VBNET.ATG"
+ m.Check(Modifiers.Constructors);
+
+#line 888 "VBNET.ATG"
+ Location constructorEndLocation = t.EndLocation;
+ Expect(1);
+
+#line 891 "VBNET.ATG"
+ if (ParseMethodBodies) {
+ Block(
+#line 892 "VBNET.ATG"
+out stmt);
+ Expect(113);
+ Expect(210);
+
+#line 894 "VBNET.ATG"
+ } else {
+ // don't parse method body
+ lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement();
+ }
+
+
+#line 900 "VBNET.ATG"
+ Location endLocation = t.EndLocation;
+ EndOfStmt();
+
+#line 903 "VBNET.ATG"
+ ConstructorDeclaration cd = new ConstructorDeclaration("New", m.Modifier, p, attributes);
+ cd.StartLocation = m.GetDeclarationLocation(startPos);
+ cd.EndLocation = constructorEndLocation;
+ cd.Body = (BlockStatement)stmt;
+ cd.Body.EndLocation = endLocation;
+ AddChild(cd);
+
+ } else SynErr(257);
+ break;
+ }
+ case 127: {
+ lexer.NextToken();
+
+#line 915 "VBNET.ATG"
+ m.Check(Modifiers.VBMethods);
+ string name = String.Empty;
+ Location startPos = t.Location;
+ MethodDeclaration methodDeclaration;List handlesClause = null;
+ List implementsClause = null;
+ AttributeSection returnTypeAttributeSection = null;
+
+ Identifier();
+
+#line 922 "VBNET.ATG"
+ name = t.val;
+ TypeParameterList(
+#line 923 "VBNET.ATG"
+templates);
+ if (la.kind == 37) {
+ lexer.NextToken();
+ if (StartOf(6)) {
+ FormalParameterList(
+#line 924 "VBNET.ATG"
+p);
+ }
+ Expect(38);
+ }
+ if (la.kind == 63) {
+ lexer.NextToken();
+ while (la.kind == 40) {
+ AttributeSection(
+#line 926 "VBNET.ATG"
+out returnTypeAttributeSection);
+
+#line 928 "VBNET.ATG"
+ if (returnTypeAttributeSection != null) {
+ returnTypeAttributeSection.AttributeTarget = "return";
+ attributes.Add(returnTypeAttributeSection);
+ }
+
+ }
+ TypeName(
+#line 934 "VBNET.ATG"
+out type);
+ }
+
+#line 936 "VBNET.ATG"
+ if(type == null) {
+ type = new TypeReference("System.Object", true);
+ }
+
+ if (la.kind == 134 || la.kind == 136) {
+ if (la.kind == 136) {
+ ImplementsClause(
+#line 942 "VBNET.ATG"
+out implementsClause);
+ } else {
+ HandlesClause(
+#line 944 "VBNET.ATG"
+out handlesClause);
+ }
+ }
+
+#line 947 "VBNET.ATG"
+ Location endLocation = t.EndLocation;
+ if (
+#line 950 "VBNET.ATG"
+IsMustOverride(m)) {
+ EndOfStmt();
+
+#line 953 "VBNET.ATG"
+ methodDeclaration = new MethodDeclaration {
+ Name = name, Modifier = m.Modifier, TypeReference = type,
+ Parameters = p, Attributes = attributes,
+ StartLocation = m.GetDeclarationLocation(startPos),
+ EndLocation = endLocation,
+ HandlesClause = handlesClause,
+ Templates = templates,
+ InterfaceImplementations = implementsClause
+ };
+
+ AddChild(methodDeclaration);
+
+ } else if (la.kind == 1) {
+ lexer.NextToken();
+
+#line 968 "VBNET.ATG"
+ methodDeclaration = new MethodDeclaration {
+ Name = name, Modifier = m.Modifier, TypeReference = type,
+ Parameters = p, Attributes = attributes,
+ StartLocation = m.GetDeclarationLocation(startPos),
+ EndLocation = endLocation,
+ Templates = templates,
+ HandlesClause = handlesClause,
+ InterfaceImplementations = implementsClause
+ };
+
+ AddChild(methodDeclaration);
+
+ if (ParseMethodBodies) {
+ Block(
+#line 981 "VBNET.ATG"
+out stmt);
+ Expect(113);
+ Expect(127);
+
+#line 983 "VBNET.ATG"
+ } else {
+ // don't parse method body
+ lexer.SkipCurrentBlock(Tokens.Function); stmt = new BlockStatement();
+ }
+ methodDeclaration.Body = (BlockStatement)stmt;
+ methodDeclaration.Body.StartLocation = methodDeclaration.EndLocation;
+ methodDeclaration.Body.EndLocation = t.EndLocation;
+
+ EndOfStmt();
+ } else SynErr(258);
+ break;
+ }
+ case 101: {
+ lexer.NextToken();
+
+#line 997 "VBNET.ATG"
+ m.Check(Modifiers.VBExternalMethods);
+ Location startPos = t.Location;
+ CharsetModifier charsetModifer = CharsetModifier.None;
+ string library = String.Empty;
+ string alias = null;
+ string name = String.Empty;
+
+ if (StartOf(15)) {
+ Charset(
+#line 1004 "VBNET.ATG"
+out charsetModifer);
+ }
+ if (la.kind == 210) {
+ lexer.NextToken();
+ Identifier();
+
+#line 1007 "VBNET.ATG"
+ name = t.val;
+ Expect(149);
+ Expect(3);
+
+#line 1008 "VBNET.ATG"
+ library = t.literalValue as string;
+ if (la.kind == 59) {
+ lexer.NextToken();
+ Expect(3);
+
+#line 1009 "VBNET.ATG"
+ alias = t.literalValue as string;
+ }
+ if (la.kind == 37) {
+ lexer.NextToken();
+ if (StartOf(6)) {
+ FormalParameterList(
+#line 1010 "VBNET.ATG"
+p);
+ }
+ Expect(38);
+ }
+ EndOfStmt();
+
+#line 1013 "VBNET.ATG"
+ DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, null, p, attributes, library, alias, charsetModifer);
+ declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
+ declareDeclaration.EndLocation = t.EndLocation;
+ AddChild(declareDeclaration);
+
+ } else if (la.kind == 127) {
+ lexer.NextToken();
+ Identifier();
+
+#line 1020 "VBNET.ATG"
+ name = t.val;
+ Expect(149);
+ Expect(3);
+
+#line 1021 "VBNET.ATG"
+ library = t.literalValue as string;
+ if (la.kind == 59) {
+ lexer.NextToken();
+ Expect(3);
+
+#line 1022 "VBNET.ATG"
+ alias = t.literalValue as string;
+ }
+ if (la.kind == 37) {
+ lexer.NextToken();
+ if (StartOf(6)) {
+ FormalParameterList(
+#line 1023 "VBNET.ATG"
+p);
+ }
+ Expect(38);
+ }
+ if (la.kind == 63) {
+ lexer.NextToken();
+ TypeName(
+#line 1024 "VBNET.ATG"
+out type);
+ }
+ EndOfStmt();
+
+#line 1027 "VBNET.ATG"
+ DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, type, p, attributes, library, alias, charsetModifer);
+ declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
+ declareDeclaration.EndLocation = t.EndLocation;
+ AddChild(declareDeclaration);
+
+ } else SynErr(259);
+ break;
+ }
+ case 119: {
+ lexer.NextToken();
+
+#line 1037 "VBNET.ATG"
+ m.Check(Modifiers.VBEvents);
+ Location startPos = t.Location;
+ EventDeclaration eventDeclaration;
+ string name = String.Empty;
+ List implementsClause = null;
+
+ Identifier();
+
+#line 1043 "VBNET.ATG"
+ name= t.val;
+ if (la.kind == 63) {
+ lexer.NextToken();
+ TypeName(
+#line 1045 "VBNET.ATG"
+out type);
+ } else if (StartOf(16)) {
+ if (la.kind == 37) {
+ lexer.NextToken();
+ if (StartOf(6)) {
+ FormalParameterList(
+#line 1047 "VBNET.ATG"
+p);
+ }
+ Expect(38);
+ }
+ } else SynErr(260);
+ if (la.kind == 136) {
+ ImplementsClause(
+#line 1049 "VBNET.ATG"
+out implementsClause);
+ }
+
+#line 1051 "VBNET.ATG"
+ eventDeclaration = new EventDeclaration {
+ Name = name, TypeReference = type, Modifier = m.Modifier,
+ Parameters = p, Attributes = attributes, InterfaceImplementations = implementsClause,
+ StartLocation = m.GetDeclarationLocation(startPos),
+ EndLocation = t.EndLocation
+ };
+ AddChild(eventDeclaration);
+
+ EndOfStmt();
+ break;
+ }
+ case 2: case 58: case 62: case 64: case 65: case 66: case 67: case 70: case 87: case 104: case 107: case 116: case 121: case 126: case 133: case 139: case 143: case 146: case 147: case 170: case 176: case 178: case 184: case 203: case 212: case 213: case 223: case 224: case 230: {
+
+#line 1062 "VBNET.ATG"
+ m.Check(Modifiers.Fields);
+ FieldDeclaration fd = new FieldDeclaration(attributes, null, m.Modifier);
+
+ IdentifierForFieldDeclaration();
+
+#line 1065 "VBNET.ATG"
+ string name = t.val;
+
+#line 1066 "VBNET.ATG"
+ fd.StartLocation = m.GetDeclarationLocation(t.Location);
+ VariableDeclaratorPartAfterIdentifier(
+#line 1068 "VBNET.ATG"
+variableDeclarators, name);
+ while (la.kind == 22) {
+ lexer.NextToken();
+ VariableDeclarator(
+#line 1069 "VBNET.ATG"
+variableDeclarators);
+ }
+ EndOfStmt();
+
+#line 1072 "VBNET.ATG"
+ fd.EndLocation = t.EndLocation;
+ fd.Fields = variableDeclarators;
+ AddChild(fd);
+
+ break;
+ }
+ case 88: {
+
+#line 1077 "VBNET.ATG"
+ m.Check(Modifiers.Fields);
+ lexer.NextToken();
+
+#line 1078 "VBNET.ATG"
+ m.Add(Modifiers.Const, t.Location);
+
+#line 1080 "VBNET.ATG"
+ FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier);
+ fd.StartLocation = m.GetDeclarationLocation(t.Location);
+ List constantDeclarators = new List();
+
+ ConstantDeclarator(
+#line 1084 "VBNET.ATG"
+constantDeclarators);
+ while (la.kind == 22) {
+ lexer.NextToken();
+ ConstantDeclarator(
+#line 1085 "VBNET.ATG"
+constantDeclarators);
+ }
+
+#line 1087 "VBNET.ATG"
+ fd.Fields = constantDeclarators;
+ fd.EndLocation = t.Location;
+
+ EndOfStmt();
+
+#line 1092 "VBNET.ATG"
+ fd.EndLocation = t.EndLocation;
+ AddChild(fd);
+
+ break;
+ }
+ case 186: {
+ lexer.NextToken();
+
+#line 1098 "VBNET.ATG"
+ m.Check(Modifiers.VBProperties);
+ Location startPos = t.Location;
+ List implementsClause = null;
+ AttributeSection returnTypeAttributeSection = null;
+ Expression initializer = null;
+
+ Identifier();
+
+#line 1104 "VBNET.ATG"
+ string propertyName = t.val;
+ if (la.kind == 37) {
+ lexer.NextToken();
+ if (StartOf(6)) {
+ FormalParameterList(
+#line 1105 "VBNET.ATG"
+p);
+ }
+ Expect(38);
+ }
+ if (la.kind == 63) {
+ lexer.NextToken();
+ while (la.kind == 40) {
+ AttributeSection(
+#line 1108 "VBNET.ATG"
+out returnTypeAttributeSection);
+
+#line 1110 "VBNET.ATG"
+ if (returnTypeAttributeSection != null) {
+ returnTypeAttributeSection.AttributeTarget = "return";
+ attributes.Add(returnTypeAttributeSection);
+ }
+
+ }
+ if (
+#line 1117 "VBNET.ATG"
+IsNewExpression()) {
+ ObjectCreateExpression(
+#line 1117 "VBNET.ATG"
+out initializer);
+
+#line 1119 "VBNET.ATG"
+ if (initializer is ObjectCreateExpression) {
+ type = ((ObjectCreateExpression)initializer).CreateType.Clone();
+ } else {
+ type = ((ArrayCreateExpression)initializer).CreateType.Clone();
+ }
+
+ } else if (StartOf(8)) {
+ TypeName(
+#line 1126 "VBNET.ATG"
+out type);
+ } else SynErr(261);
+ }
+ if (la.kind == 20) {
+ lexer.NextToken();
+ Expr(
+#line 1129 "VBNET.ATG"
+out initializer);
+ }
+ if (la.kind == 136) {
+ ImplementsClause(
+#line 1130 "VBNET.ATG"
+out implementsClause);
+ }
+ EndOfStmt();
+ if (
+#line 1134 "VBNET.ATG"
+IsMustOverride(m) || IsAutomaticProperty()) {
+
+#line 1136 "VBNET.ATG"
+ PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes);
+ pDecl.StartLocation = m.GetDeclarationLocation(startPos);
+ pDecl.EndLocation = t.Location;
+ pDecl.TypeReference = type;
+ pDecl.InterfaceImplementations = implementsClause;
+ pDecl.Parameters = p;
+ if (initializer != null)
+ pDecl.Initializer = initializer;
+ AddChild(pDecl);
+
+ } else if (StartOf(17)) {
+
+#line 1148 "VBNET.ATG"
+ PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes);
+ pDecl.StartLocation = m.GetDeclarationLocation(startPos);
+ pDecl.EndLocation = t.Location;
+ pDecl.BodyStart = t.Location;
+ pDecl.TypeReference = type;
+ pDecl.InterfaceImplementations = implementsClause;
+ pDecl.Parameters = p;
+ PropertyGetRegion getRegion;
+ PropertySetRegion setRegion;
+
+ AccessorDecls(
+#line 1158 "VBNET.ATG"
+out getRegion, out setRegion);
+ Expect(113);
+ Expect(186);
+ EndOfStmt();
+
+#line 1162 "VBNET.ATG"
+ pDecl.GetRegion = getRegion;
+ pDecl.SetRegion = setRegion;
+ pDecl.BodyEnd = t.Location; // t = EndOfStmt; not "Property"
+ AddChild(pDecl);
+
+ } else SynErr(262);
+ break;
+ }
+ case 98: {
+ lexer.NextToken();
+
+#line 1169 "VBNET.ATG"
+ Location startPos = t.Location;
+ Expect(119);
+
+#line 1171 "VBNET.ATG"
+ m.Check(Modifiers.VBCustomEvents);
+ EventAddRemoveRegion eventAccessorDeclaration;
+ EventAddRegion addHandlerAccessorDeclaration = null;
+ EventRemoveRegion removeHandlerAccessorDeclaration = null;
+ EventRaiseRegion raiseEventAccessorDeclaration = null;
+ List implementsClause = null;
+
+ Identifier();
+
+#line 1178 "VBNET.ATG"
+ string customEventName = t.val;
+ Expect(63);
+ TypeName(
+#line 1179 "VBNET.ATG"
+out type);
+ if (la.kind == 136) {
+ ImplementsClause(
+#line 1180 "VBNET.ATG"
+out implementsClause);
+ }
+ EndOfStmt();
+ while (StartOf(18)) {
+ EventAccessorDeclaration(
+#line 1183 "VBNET.ATG"
+out eventAccessorDeclaration);
+
+#line 1185 "VBNET.ATG"
+ if(eventAccessorDeclaration is EventAddRegion)
+ {
+ addHandlerAccessorDeclaration = (EventAddRegion)eventAccessorDeclaration;
+ }
+ else if(eventAccessorDeclaration is EventRemoveRegion)
+ {
+ removeHandlerAccessorDeclaration = (EventRemoveRegion)eventAccessorDeclaration;
+ }
+ else if(eventAccessorDeclaration is EventRaiseRegion)
+ {
+ raiseEventAccessorDeclaration = (EventRaiseRegion)eventAccessorDeclaration;
+ }
+
+ }
+ Expect(113);
+ Expect(119);
+ EndOfStmt();
+
+#line 1201 "VBNET.ATG"
+ if(addHandlerAccessorDeclaration == null)
+ {
+ Error("Need to provide AddHandler accessor.");
+ }
+
+ if(removeHandlerAccessorDeclaration == null)
+ {
+ Error("Need to provide RemoveHandler accessor.");
+ }
+
+ if(raiseEventAccessorDeclaration == null)
+ {
+ Error("Need to provide RaiseEvent accessor.");
+ }
+
+ EventDeclaration decl = new EventDeclaration {
+ TypeReference = type, Name = customEventName, Modifier = m.Modifier,
+ Attributes = attributes,
+ StartLocation = m.GetDeclarationLocation(startPos),
+ EndLocation = t.EndLocation,
+ AddRegion = addHandlerAccessorDeclaration,
+ RemoveRegion = removeHandlerAccessorDeclaration,
+ RaiseRegion = raiseEventAccessorDeclaration
+ };
+ AddChild(decl);
+
+ break;
+ }
+ case 161: case 172: case 232: {
+
+#line 1227 "VBNET.ATG"
+ ConversionType opConversionType = ConversionType.None;
+ if (la.kind == 161 || la.kind == 232) {
+ if (la.kind == 232) {
+ lexer.NextToken();
+
+#line 1228 "VBNET.ATG"
+ opConversionType = ConversionType.Implicit;
+ } else {
+ lexer.NextToken();
+
+#line 1229 "VBNET.ATG"
+ opConversionType = ConversionType.Explicit;
+ }
+ }
+ Expect(172);
+
+#line 1232 "VBNET.ATG"
+ m.Check(Modifiers.VBOperators);
+ Location startPos = t.Location;
+ TypeReference returnType = NullTypeReference.Instance;
+ TypeReference operandType = NullTypeReference.Instance;
+ OverloadableOperatorType operatorType;
+ AttributeSection section;
+ ParameterDeclarationExpression param;
+ List parameters = new List();
+
+ OverloadableOperator(
+#line 1241 "VBNET.ATG"
+out operatorType);
+ Expect(37);
+ FormalParameter(
+#line 1243 "VBNET.ATG"
+out param);
+
+#line 1244 "VBNET.ATG"
+ if (param != null) parameters.Add(param);
+ if (la.kind == 22) {
+ lexer.NextToken();
+ FormalParameter(
+#line 1246 "VBNET.ATG"
+out param);
+
+#line 1247 "VBNET.ATG"
+ if (param != null) parameters.Add(param);
+ }
+ Expect(38);
+
+#line 1250 "VBNET.ATG"
+ Location endPos = t.EndLocation;
+ if (la.kind == 63) {
+ lexer.NextToken();
+ while (la.kind == 40) {
+ AttributeSection(
+#line 1251 "VBNET.ATG"
+out section);
+
+#line 1252 "VBNET.ATG"
+ if (section != null) {
+ section.AttributeTarget = "return";
+ attributes.Add(section);
+ }
+ }
+ TypeName(
+#line 1256 "VBNET.ATG"
+out returnType);
+
+#line 1256 "VBNET.ATG"
+ endPos = t.EndLocation;
+ }
+ Expect(1);
+ Block(
+#line 1258 "VBNET.ATG"
+out stmt);
+ Expect(113);
+ Expect(172);
+ EndOfStmt();
+
+#line 1260 "VBNET.ATG"
+ OperatorDeclaration operatorDeclaration = new OperatorDeclaration {
+ Modifier = m.Modifier,
+ Attributes = attributes,
+ Parameters = parameters,
+ TypeReference = returnType,
+ OverloadableOperator = operatorType,
+ Name = GetReflectionNameForOperator(operatorType, opConversionType),
+ ConversionType = opConversionType,
+ Body = (BlockStatement)stmt,
+ StartLocation = m.GetDeclarationLocation(startPos),
+ EndLocation = endPos
+ };
+ operatorDeclaration.Body.StartLocation = startPos;
+ operatorDeclaration.Body.EndLocation = t.Location;
+ AddChild(operatorDeclaration);
+
+ break;
+ }
+ default: SynErr(263); break;
+ }
+ }
+
+ void EnumMemberDecl(
+#line 774 "VBNET.ATG"
+out FieldDeclaration f) {
+
+#line 776 "VBNET.ATG"
+ Expression expr = null;List attributes = new List();
+ AttributeSection section = null;
+ VariableDeclaration varDecl = null;
+
+ while (la.kind == 40) {
+ AttributeSection(
+#line 780 "VBNET.ATG"
+out section);
+
+#line 780 "VBNET.ATG"
+ attributes.Add(section);
+ }
+ Identifier();
+
+#line 783 "VBNET.ATG"
+ f = new FieldDeclaration(attributes);
+ varDecl = new VariableDeclaration(t.val);
+ f.Fields.Add(varDecl);
+ f.StartLocation = varDecl.StartLocation = t.Location;
+
+ if (la.kind == 20) {
+ lexer.NextToken();
+ Expr(
+#line 788 "VBNET.ATG"
+out expr);
+
+#line 788 "VBNET.ATG"
+ varDecl.Initializer = expr;
+ }
+
+#line 789 "VBNET.ATG"
+ f.EndLocation = varDecl.EndLocation = t.EndLocation;
+ EndOfStmt();
+ }
+
+ void InterfaceMemberDecl() {
+
+#line 665 "VBNET.ATG"
+ TypeReference type =null;
+ List p = new List();
+ List templates = new List();
+ AttributeSection section, returnTypeAttributeSection = null;
+ ModifierList mod = new ModifierList();
+ List attributes = new List();
+ string name;
+
+ if (StartOf(19)) {
+ while (la.kind == 40) {
+ AttributeSection(
+#line 673 "VBNET.ATG"
+out section);
+
+#line 673 "VBNET.ATG"
+ attributes.Add(section);
+ }
+ while (StartOf(10)) {
+ MemberModifier(
+#line 676 "VBNET.ATG"
+mod);
+ }
+ if (la.kind == 119) {
+ lexer.NextToken();
+
+#line 680 "VBNET.ATG"
+ mod.Check(Modifiers.VBInterfaceEvents);
+ Location startLocation = t.Location;
+
+ Identifier();
+
+#line 683 "VBNET.ATG"
+ name = t.val;
+ if (la.kind == 37) {
+ lexer.NextToken();
+ if (StartOf(6)) {
+ FormalParameterList(
+#line 684 "VBNET.ATG"
+p);
+ }
+ Expect(38);
+ }
+ if (la.kind == 63) {
+ lexer.NextToken();
+ TypeName(
+#line 685 "VBNET.ATG"
+out type);
+ }
+ EndOfStmt();
+
+#line 688 "VBNET.ATG"
+ EventDeclaration ed = new EventDeclaration {
+ Name = name, TypeReference = type, Modifier = mod.Modifier,
+ Parameters = p, Attributes = attributes,
+ StartLocation = startLocation, EndLocation = t.EndLocation
+ };
+ AddChild(ed);
+
+ } else if (la.kind == 210) {
+ lexer.NextToken();
+
+#line 698 "VBNET.ATG"
+ Location startLocation = t.Location;
+ mod.Check(Modifiers.VBInterfaceMethods);
+
+ Identifier();
+
+#line 701 "VBNET.ATG"
+ name = t.val;
+ TypeParameterList(
+#line 702 "VBNET.ATG"
+templates);
+ if (la.kind == 37) {
+ lexer.NextToken();
+ if (StartOf(6)) {
+ FormalParameterList(
+#line 703 "VBNET.ATG"
+p);
+ }
+ Expect(38);
+ }
+ EndOfStmt();
+
+#line 706 "VBNET.ATG"
+ MethodDeclaration md = new MethodDeclaration {
+ Name = name,
+ Modifier = mod.Modifier,
+ Parameters = p,
+ Attributes = attributes,
+ TypeReference = new TypeReference("System.Void", true),
+ StartLocation = startLocation,
+ EndLocation = t.EndLocation,
+ Templates = templates
+ };
+ AddChild(md);
+
+ } else if (la.kind == 127) {
+ lexer.NextToken();
+
+#line 721 "VBNET.ATG"
+ mod.Check(Modifiers.VBInterfaceMethods);
+ Location startLocation = t.Location;
+
+ Identifier();
+
+#line 724 "VBNET.ATG"
+ name = t.val;
+ TypeParameterList(
+#line 725 "VBNET.ATG"
+templates);
+ if (la.kind == 37) {
+ lexer.NextToken();
+ if (StartOf(6)) {
+ FormalParameterList(
+#line 726 "VBNET.ATG"
+p);
+ }
+ Expect(38);
+ }
+ if (la.kind == 63) {
+ lexer.NextToken();
+ while (la.kind == 40) {
+ AttributeSection(
+#line 727 "VBNET.ATG"
+out returnTypeAttributeSection);
+ }
+ TypeName(
+#line 727 "VBNET.ATG"
+out type);
+ }
+
+#line 729 "VBNET.ATG"
+ if(type == null) {
+ type = new TypeReference("System.Object", true);
+ }
+ MethodDeclaration md = new MethodDeclaration {
+ Name = name, Modifier = mod.Modifier,
+ TypeReference = type, Parameters = p, Attributes = attributes
+ };
+ if (returnTypeAttributeSection != null) {
+ returnTypeAttributeSection.AttributeTarget = "return";
+ md.Attributes.Add(returnTypeAttributeSection);
+ }
+ md.StartLocation = startLocation;
+ md.EndLocation = t.EndLocation;
+ md.Templates = templates;
+ AddChild(md);
+
+ EndOfStmt();
+ } else if (la.kind == 186) {
+ lexer.NextToken();
+
+#line 749 "VBNET.ATG"
+ Location startLocation = t.Location;
+ mod.Check(Modifiers.VBInterfaceProperties);
+
+ Identifier();
+
+#line 752 "VBNET.ATG"
+ name = t.val;
+ if (la.kind == 37) {
+ lexer.NextToken();
+ if (StartOf(6)) {
+ FormalParameterList(
+#line 753 "VBNET.ATG"
+p);
+ }
+ Expect(38);
+ }
+ if (la.kind == 63) {
+ lexer.NextToken();
+ TypeName(
+#line 754 "VBNET.ATG"
+out type);
+ }
+
+#line 756 "VBNET.ATG"
+ if(type == null) {
+ type = new TypeReference("System.Object", true);
+ }
+
+ EndOfStmt();
+
+#line 762 "VBNET.ATG"
+ PropertyDeclaration pd = new PropertyDeclaration(name, type, mod.Modifier, attributes);
+ pd.Parameters = p;
+ pd.EndLocation = t.EndLocation;
+ pd.StartLocation = startLocation;
+ AddChild(pd);
+
+ } else SynErr(264);
+ } else if (StartOf(20)) {
+ NonModuleDeclaration(
+#line 770 "VBNET.ATG"
+mod, attributes);
+ } else SynErr(265);
+ }
+
+ void Expr(
+#line 1664 "VBNET.ATG"
+out Expression expr) {
+
+#line 1665 "VBNET.ATG"
+ expr = null; Location startLocation = la.Location;
+ if (
+#line 1668 "VBNET.ATG"
+IsQueryExpression() ) {
+ QueryExpr(
+#line 1669 "VBNET.ATG"
+out expr);
+ } else if (la.kind == 127 || la.kind == 210) {
+ LambdaExpr(
+#line 1670 "VBNET.ATG"
+out expr);
+ } else if (StartOf(21)) {
+ DisjunctionExpr(
+#line 1671 "VBNET.ATG"
+out expr);
+ } else SynErr(266);
+
+#line 1674 "VBNET.ATG"
+ if (expr != null) {
+ expr.StartLocation = startLocation;
+ expr.EndLocation = t.EndLocation;
+ }
+
+ }
+
+ void ImplementsClause(
+#line 1637 "VBNET.ATG"
+out List baseInterfaces) {
+
+#line 1639 "VBNET.ATG"
+ baseInterfaces = new List();
+ TypeReference type = null;
+ string memberName = null;
+
+ Expect(136);
+ NonArrayTypeName(
+#line 1644 "VBNET.ATG"
+out type, false);
+
+#line 1645 "VBNET.ATG"
+ if (type != null) memberName = TypeReference.StripLastIdentifierFromType(ref type);
+
+#line 1646 "VBNET.ATG"
+ baseInterfaces.Add(new InterfaceImplementation(type, memberName));
+ while (la.kind == 22) {
+ lexer.NextToken();
+ NonArrayTypeName(
+#line 1648 "VBNET.ATG"
+out type, false);
+
+#line 1649 "VBNET.ATG"
+ if (type != null) memberName = TypeReference.StripLastIdentifierFromType(ref type);
+
+#line 1650 "VBNET.ATG"
+ baseInterfaces.Add(new InterfaceImplementation(type, memberName));
+ }
+ }
+
+ void HandlesClause(
+#line 1595 "VBNET.ATG"
+out List handlesClause) {
+
+#line 1597 "VBNET.ATG"
+ handlesClause = new List();
+ string name;
+
+ Expect(134);
+ EventMemberSpecifier(
+#line 1600 "VBNET.ATG"
+out name);
+
+#line 1600 "VBNET.ATG"
+ if (name != null) handlesClause.Add(name);
+ while (la.kind == 22) {
+ lexer.NextToken();
+ EventMemberSpecifier(
+#line 1601 "VBNET.ATG"
+out name);
+
+#line 1601 "VBNET.ATG"
+ if (name != null) handlesClause.Add(name);
+ }
+ }
+
+ void Block(
+#line 2990 "VBNET.ATG"
+out Statement stmt) {
+
+#line 2993 "VBNET.ATG"
+ BlockStatement blockStmt = new BlockStatement();
+ /* in snippet parsing mode, t might be null */
+ if (t != null) blockStmt.StartLocation = t.EndLocation;
+ BlockStart(blockStmt);
+
+ while (StartOf(22) ||
+#line 2999 "VBNET.ATG"
+IsEndStmtAhead()) {
+ if (
+#line 2999 "VBNET.ATG"
+IsEndStmtAhead()) {
+
+#line 3000 "VBNET.ATG"
+ Token first = la;
+ Expect(113);
+ EndOfStmt();
+
+#line 3003 "VBNET.ATG"
+ AddChild(new EndStatement() {
+ StartLocation = first.Location,
+ EndLocation = first.EndLocation }
+ );
+
+ } else {
+ Statement();
+ EndOfStmt();
+ }
+ }
+
+#line 3012 "VBNET.ATG"
+ stmt = blockStmt;
+ if (t != null) blockStmt.EndLocation = t.EndLocation;
+ BlockEnd();
+
+ }
+
+ void Charset(
+#line 1587 "VBNET.ATG"
+out CharsetModifier charsetModifier) {
+
+#line 1588 "VBNET.ATG"
+ charsetModifier = CharsetModifier.None;
+ if (la.kind == 127 || la.kind == 210) {
+ } else if (la.kind == 62) {
+ lexer.NextToken();
+
+#line 1589 "VBNET.ATG"
+ charsetModifier = CharsetModifier.Ansi;
+ } else if (la.kind == 66) {
+ lexer.NextToken();
+
+#line 1590 "VBNET.ATG"
+ charsetModifier = CharsetModifier.Auto;
+ } else if (la.kind == 223) {
+ lexer.NextToken();
+
+#line 1591 "VBNET.ATG"
+ charsetModifier = CharsetModifier.Unicode;
+ } else SynErr(267);
+ }
+
+ void IdentifierForFieldDeclaration() {
+ switch (la.kind) {
+ case 2: {
+ lexer.NextToken();
+ break;
+ }
+ case 58: {
+ lexer.NextToken();
+ break;
+ }
+ case 62: {
+ lexer.NextToken();
+ break;
+ }
+ case 64: {
+ lexer.NextToken();
+ break;
+ }
+ case 65: {
+ lexer.NextToken();
+ break;
+ }
+ case 66: {
+ lexer.NextToken();
+ break;
+ }
+ case 67: {
+ lexer.NextToken();
+ break;
+ }
+ case 70: {
+ lexer.NextToken();
+ break;
+ }
+ case 87: {
+ lexer.NextToken();
+ break;
+ }
+ case 104: {
+ lexer.NextToken();
+ break;
+ }
+ case 107: {
+ lexer.NextToken();
+ break;
+ }
+ case 116: {
+ lexer.NextToken();
+ break;
+ }
+ case 121: {
+ lexer.NextToken();
+ break;
+ }
+ case 126: {
+ lexer.NextToken();
+ break;
+ }
+ case 133: {
+ lexer.NextToken();
+ break;
+ }
+ case 139: {
+ lexer.NextToken();
+ break;
+ }
+ case 143: {
+ lexer.NextToken();
+ break;
+ }
+ case 146: {
+ lexer.NextToken();
+ break;
+ }
+ case 147: {
+ lexer.NextToken();
+ break;
+ }
+ case 170: {
+ lexer.NextToken();
+ break;
+ }
+ case 176: {
+ lexer.NextToken();
+ break;
+ }
+ case 178: {
+ lexer.NextToken();
+ break;
+ }
+ case 184: {
+ lexer.NextToken();
+ break;
+ }
+ case 203: {
+ lexer.NextToken();
+ break;
+ }
+ case 212: {
+ lexer.NextToken();
+ break;
+ }
+ case 213: {
+ lexer.NextToken();
+ break;
+ }
+ case 223: {
+ lexer.NextToken();
+ break;
+ }
+ case 224: {
+ lexer.NextToken();
+ break;
+ }
+ case 230: {
+ lexer.NextToken();
+ break;
+ }
+ default: SynErr(268); break;
+ }
+ }
+
+ void VariableDeclaratorPartAfterIdentifier(
+#line 1466 "VBNET.ATG"
+List fieldDeclaration, string name) {
+
+#line 1468 "VBNET.ATG"
+ Expression expr = null;
+ TypeReference type = null;
+ ArrayList rank = null;
+ List dimension = null;
+ Location startLocation = t.Location;
+
+ if (
+#line 1474 "VBNET.ATG"
+IsSize() && !IsDims()) {
+ ArrayInitializationModifier(
+#line 1474 "VBNET.ATG"
+out dimension);
+ }
+ if (
+#line 1475 "VBNET.ATG"
+IsDims()) {
+ ArrayNameModifier(
+#line 1475 "VBNET.ATG"
+out rank);
+ }
+ if (
+#line 1477 "VBNET.ATG"
+IsObjectCreation()) {
+ Expect(63);
+ ObjectCreateExpression(
+#line 1477 "VBNET.ATG"
+out expr);
+
+#line 1479 "VBNET.ATG"
+ if (expr is ObjectCreateExpression) {
+ type = ((ObjectCreateExpression)expr).CreateType.Clone();
+ } else {
+ type = ((ArrayCreateExpression)expr).CreateType.Clone();
+ }
+
+ } else if (StartOf(23)) {
+ if (la.kind == 63) {
+ lexer.NextToken();
+ TypeName(
+#line 1486 "VBNET.ATG"
+out type);
+
+#line 1488 "VBNET.ATG"
+ if (type != null) {
+ for (int i = fieldDeclaration.Count - 1; i >= 0; i--) {
+ VariableDeclaration vd = fieldDeclaration[i];
+ if (vd.TypeReference.Type.Length > 0) break;
+ TypeReference newType = type.Clone();
+ newType.RankSpecifier = vd.TypeReference.RankSpecifier;
+ vd.TypeReference = newType;
+ }
+ }
+
+ }
+
+#line 1500 "VBNET.ATG"
+ if (type == null && (dimension != null || rank != null)) {
+ type = new TypeReference("");
+ }
+ if (dimension != null) {
+ if(type.RankSpecifier != null) {
+ Error("array rank only allowed one time");
+ } else {
+ if (rank == null) {
+ type.RankSpecifier = new int[] { dimension.Count - 1 };
+ } else {
+ rank.Insert(0, dimension.Count - 1);
+ type.RankSpecifier = (int[])rank.ToArray(typeof(int));
+ }
+ expr = new ArrayCreateExpression(type.Clone(), dimension);
+ }
+ } else if (rank != null) {
+ if(type.RankSpecifier != null) {
+ Error("array rank only allowed one time");
+ } else {
+ type.RankSpecifier = (int[])rank.ToArray(typeof(int));
+ }
+ }
+
+ if (la.kind == 20) {
+ lexer.NextToken();
+ Expr(
+#line 1523 "VBNET.ATG"
+out expr);
+ }
+ } else SynErr(269);
+
+#line 1526 "VBNET.ATG"
+ VariableDeclaration varDecl = new VariableDeclaration(name, expr, type);
+ varDecl.StartLocation = startLocation;
+ varDecl.EndLocation = t.Location;
+ fieldDeclaration.Add(varDecl);
+
+ }
+
+ void VariableDeclarator(
+#line 1460 "VBNET.ATG"
+List fieldDeclaration) {
+ Identifier();
+
+#line 1462 "VBNET.ATG"
+ string name = t.val;
+ VariableDeclaratorPartAfterIdentifier(
+#line 1463 "VBNET.ATG"
+fieldDeclaration, name);
+ }
+
+ void ConstantDeclarator(
+#line 1441 "VBNET.ATG"
+List constantDeclaration) {
+
+#line 1443 "VBNET.ATG"
+ Expression expr = null;
+ TypeReference type = null;
+ string name = String.Empty;
+ Location location;
+
+ Identifier();
+
+#line 1448 "VBNET.ATG"
+ name = t.val; location = t.Location;
+ if (la.kind == 63) {
+ lexer.NextToken();
+ TypeName(
+#line 1449 "VBNET.ATG"
+out type);
+ }
+ Expect(20);
+ Expr(
+#line 1450 "VBNET.ATG"
+out expr);
+
+#line 1452 "VBNET.ATG"
+ VariableDeclaration f = new VariableDeclaration(name, expr);
+ f.TypeReference = type;
+ f.StartLocation = location;
+ constantDeclaration.Add(f);
+
+ }
+
+ void ObjectCreateExpression(
+#line 2126 "VBNET.ATG"
+out Expression oce) {
+
+#line 2128 "VBNET.ATG"
+ TypeReference type = null;
+ CollectionInitializerExpression initializer = null;
+ List arguments = null;
+ ArrayList dimensions = null;
+ oce = null;
+ Location startLocation = la.Location;
+ bool canBeNormal; bool canBeReDim;
+
+ Expect(162);
+ if (StartOf(8)) {
+ NonArrayTypeName(
+#line 2137 "VBNET.ATG"
+out type, false);
+ if (la.kind == 37) {
+ lexer.NextToken();
+ NormalOrReDimArgumentList(
+#line 2138 "VBNET.ATG"
+out arguments, out canBeNormal, out canBeReDim);
+ Expect(38);
+ if (la.kind == 35 ||
+#line 2139 "VBNET.ATG"
+la.kind == Tokens.OpenParenthesis) {
+ if (
+#line 2139 "VBNET.ATG"
+la.kind == Tokens.OpenParenthesis) {
+ ArrayTypeModifiers(
+#line 2140 "VBNET.ATG"
+out dimensions);
+ CollectionInitializer(
+#line 2141 "VBNET.ATG"
+out initializer);
+ } else {
+ CollectionInitializer(
+#line 2142 "VBNET.ATG"
+out initializer);
+ }
+ }
+
+#line 2144 "VBNET.ATG"
+ if (canBeReDim && !canBeNormal && initializer == null) initializer = new CollectionInitializerExpression();
+ }
+ }
+
+#line 2148 "VBNET.ATG"
+ if (initializer == null) {
+ oce = new ObjectCreateExpression(type, arguments);
+ } else {
+ if (dimensions == null) dimensions = new ArrayList();
+ dimensions.Insert(0, (arguments == null) ? 0 : Math.Max(arguments.Count - 1, 0));
+ type.RankSpecifier = (int[])dimensions.ToArray(typeof(int));
+ ArrayCreateExpression ace = new ArrayCreateExpression(type, initializer);
+ ace.Arguments = arguments;
+ oce = ace;
+ }
+
+ if (la.kind == 126 || la.kind == 233) {
+ if (la.kind == 233) {
+
+#line 2163 "VBNET.ATG"
+ MemberInitializerExpression memberInitializer = null;
+ Expression anonymousMember = null;
+
+ lexer.NextToken();
+
+#line 2168 "VBNET.ATG"
+ CollectionInitializerExpression memberInitializers = new CollectionInitializerExpression();
+ memberInitializers.StartLocation = la.Location;
+
+ Expect(35);
+ if (la.kind == 26 || la.kind == 147) {
+ MemberInitializer(
+#line 2173 "VBNET.ATG"
+out memberInitializer);
+
+#line 2174 "VBNET.ATG"
+ memberInitializers.CreateExpressions.Add(memberInitializer);
+ } else if (StartOf(24)) {
+ Expr(
+#line 2175 "VBNET.ATG"
+out anonymousMember);
+
+#line 2176 "VBNET.ATG"
+ memberInitializers.CreateExpressions.Add(anonymousMember);
+ } else SynErr(270);
+ while (la.kind == 22) {
+ lexer.NextToken();
+ if (la.kind == 26 || la.kind == 147) {
+ MemberInitializer(
+#line 2180 "VBNET.ATG"
+out memberInitializer);
+
+#line 2181 "VBNET.ATG"
+ memberInitializers.CreateExpressions.Add(memberInitializer);
+ } else if (StartOf(24)) {
+ Expr(
+#line 2182 "VBNET.ATG"
+out anonymousMember);
+
+#line 2183 "VBNET.ATG"
+ memberInitializers.CreateExpressions.Add(anonymousMember);
+ } else SynErr(271);
+ }
+ Expect(36);
+
+#line 2188 "VBNET.ATG"
+ memberInitializers.EndLocation = t.Location;
+ if(oce is ObjectCreateExpression)
+ {
+ ((ObjectCreateExpression)oce).ObjectInitializer = memberInitializers;
+ }
+
+ } else {
+ lexer.NextToken();
+ CollectionInitializer(
+#line 2198 "VBNET.ATG"
+out initializer);
+
+#line 2200 "VBNET.ATG"
+ if(oce is ObjectCreateExpression)
+ ((ObjectCreateExpression)oce).ObjectInitializer = initializer;
+
+ }
+ }
+
+#line 2206 "VBNET.ATG"
+ if (oce != null) {
+ oce.StartLocation = startLocation;
+ oce.EndLocation = t.EndLocation;
+ }
+
+ }
+
+ void AccessorDecls(
+#line 1375 "VBNET.ATG"
+out PropertyGetRegion getBlock, out PropertySetRegion setBlock) {
+
+#line 1377 "VBNET.ATG"
+ List attributes = new List();
+ AttributeSection section;
+ getBlock = null;
+ setBlock = null;
+
+ while (la.kind == 40) {
+ AttributeSection(
+#line 1382 "VBNET.ATG"
+out section);
+
+#line 1382 "VBNET.ATG"
+ attributes.Add(section);
+ }
+ if (StartOf(25)) {
+ GetAccessorDecl(
+#line 1384 "VBNET.ATG"
+out getBlock, attributes);
+ if (StartOf(26)) {
+
+#line 1386 "VBNET.ATG"
+ attributes = new List();
+ while (la.kind == 40) {
+ AttributeSection(
+#line 1387 "VBNET.ATG"
+out section);
+
+#line 1387 "VBNET.ATG"
+ attributes.Add(section);
+ }
+ SetAccessorDecl(
+#line 1388 "VBNET.ATG"
+out setBlock, attributes);
+ }
+ } else if (StartOf(27)) {
+ SetAccessorDecl(
+#line 1391 "VBNET.ATG"
+out setBlock, attributes);
+ if (StartOf(28)) {
+
+#line 1393 "VBNET.ATG"
+ attributes = new List();
+ while (la.kind == 40) {
+ AttributeSection(
+#line 1394 "VBNET.ATG"
+out section);
+
+#line 1394 "VBNET.ATG"
+ attributes.Add(section);
+ }
+ GetAccessorDecl(
+#line 1395 "VBNET.ATG"
+out getBlock, attributes);
+ }
+ } else SynErr(272);
+ }
+
+ void EventAccessorDeclaration(
+#line 1338 "VBNET.ATG"
+out EventAddRemoveRegion eventAccessorDeclaration) {
+
+#line 1340 "VBNET.ATG"
+ Statement stmt = null;
+ List p = new List();
+ AttributeSection section;
+ List attributes = new List();
+ eventAccessorDeclaration = null;
+
+ while (la.kind == 40) {
+ AttributeSection(
+#line 1346 "VBNET.ATG"
+out section);
+
+#line 1346 "VBNET.ATG"
+ attributes.Add(section);
+ }
+ if (la.kind == 56) {
+ lexer.NextToken();
+ if (la.kind == 37) {
+ lexer.NextToken();
+ if (StartOf(6)) {
+ FormalParameterList(
+#line 1348 "VBNET.ATG"
+p);
+ }
+ Expect(38);
+ }
+ Expect(1);
+ Block(
+#line 1349 "VBNET.ATG"
+out stmt);
+ Expect(113);
+ Expect(56);
+ EndOfStmt();
+
+#line 1351 "VBNET.ATG"
+ eventAccessorDeclaration = new EventAddRegion(attributes);
+ eventAccessorDeclaration.Block = (BlockStatement)stmt;
+ eventAccessorDeclaration.Parameters = p;
+
+ } else if (la.kind == 193) {
+ lexer.NextToken();
+ if (la.kind == 37) {
+ lexer.NextToken();
+ if (StartOf(6)) {
+ FormalParameterList(
+#line 1356 "VBNET.ATG"
+p);
+ }
+ Expect(38);
+ }
+ Expect(1);
+ Block(
+#line 1357 "VBNET.ATG"
+out stmt);
+ Expect(113);
+ Expect(193);
+ EndOfStmt();
+
+#line 1359 "VBNET.ATG"
+ eventAccessorDeclaration = new EventRemoveRegion(attributes);
+ eventAccessorDeclaration.Block = (BlockStatement)stmt;
+ eventAccessorDeclaration.Parameters = p;
+
+ } else if (la.kind == 189) {
+ lexer.NextToken();
+ if (la.kind == 37) {
+ lexer.NextToken();
+ if (StartOf(6)) {
+ FormalParameterList(
+#line 1364 "VBNET.ATG"
+p);
+ }
+ Expect(38);
+ }
+ Expect(1);
+ Block(
+#line 1365 "VBNET.ATG"
+out stmt);
+ Expect(113);
+ Expect(189);
+ EndOfStmt();
+
+#line 1367 "VBNET.ATG"
+ eventAccessorDeclaration = new EventRaiseRegion(attributes);
+ eventAccessorDeclaration.Block = (BlockStatement)stmt;
+ eventAccessorDeclaration.Parameters = p;
+
+ } else SynErr(273);
+ }
+
+ void OverloadableOperator(
+#line 1278 "VBNET.ATG"
+out OverloadableOperatorType operatorType) {
+
+#line 1279 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.None;
+ switch (la.kind) {
+ case 31: {
+ lexer.NextToken();
+
+#line 1281 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.Add;
+ break;
+ }
+ case 30: {
+ lexer.NextToken();
+
+#line 1283 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.Subtract;
+ break;
+ }
+ case 34: {
+ lexer.NextToken();
+
+#line 1285 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.Multiply;
+ break;
+ }
+ case 24: {
+ lexer.NextToken();
+
+#line 1287 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.Divide;
+ break;
+ }
+ case 25: {
+ lexer.NextToken();
+
+#line 1289 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.DivideInteger;
+ break;
+ }
+ case 23: {
+ lexer.NextToken();
+
+#line 1291 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.Concat;
+ break;
+ }
+ case 150: {
+ lexer.NextToken();
+
+#line 1293 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.Like;
+ break;
+ }
+ case 154: {
+ lexer.NextToken();
+
+#line 1295 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.Modulus;
+ break;
+ }
+ case 60: {
+ lexer.NextToken();
+
+#line 1297 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.BitwiseAnd;
+ break;
+ }
+ case 175: {
+ lexer.NextToken();
+
+#line 1299 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.BitwiseOr;
+ break;
+ }
+ case 236: {
+ lexer.NextToken();
+
+#line 1301 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.ExclusiveOr;
+ break;
+ }
+ case 164: {
+ lexer.NextToken();
+
+#line 1303 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.BitNot;
+ break;
+ }
+ case 32: {
+ lexer.NextToken();
+
+#line 1305 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.Power;
+ break;
+ }
+ case 44: {
+ lexer.NextToken();
+
+#line 1307 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.ShiftLeft;
+ break;
+ }
+ case 45: {
+ lexer.NextToken();
+
+#line 1309 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.ShiftRight;
+ break;
+ }
+ case 20: {
+ lexer.NextToken();
+
+#line 1311 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.Equality;
+ break;
+ }
+ case 41: {
+ lexer.NextToken();
+
+#line 1313 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.InEquality;
+ break;
+ }
+ case 40: {
+ lexer.NextToken();
+
+#line 1315 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.LessThan;
+ break;
+ }
+ case 43: {
+ lexer.NextToken();
+
+#line 1317 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.LessThanOrEqual;
+ break;
+ }
+ case 39: {
+ lexer.NextToken();
+
+#line 1319 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.GreaterThan;
+ break;
+ }
+ case 42: {
+ lexer.NextToken();
+
+#line 1321 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.GreaterThanOrEqual;
+ break;
+ }
+ case 94: {
+ lexer.NextToken();
+
+#line 1323 "VBNET.ATG"
+ operatorType = OverloadableOperatorType.CType;
+ break;
+ }
+ case 2: case 58: case 62: case 64: case 65: case 66: case 67: case 70: case 87: case 98: case 104: case 107: case 116: case 121: case 126: case 133: case 139: case 143: case 146: case 147: case 170: case 176: case 178: case 184: case 203: case 212: case 213: case 223: case 224: case 230: {
+ Identifier();
+
+#line 1327 "VBNET.ATG"
+ string opName = t.val;
+ if (string.Equals(opName, "istrue", StringComparison.InvariantCultureIgnoreCase)) {
+ operatorType = OverloadableOperatorType.IsTrue;
+ } else if (string.Equals(opName, "isfalse", StringComparison.InvariantCultureIgnoreCase)) {
+ operatorType = OverloadableOperatorType.IsFalse;
+ } else {
+ Error("Invalid operator. Possible operators are '+', '-', 'Not', 'IsTrue', 'IsFalse'.");
+ }
+
+ break;
+ }
+ default: SynErr(274); break;
+ }
+ }
+
+ void FormalParameter(
+#line 2951 "VBNET.ATG"
+out ParameterDeclarationExpression p) {
+
+#line 2953 "VBNET.ATG"
+ AttributeSection section;
+ List attributes = new List();
+ TypeReference type = null;
+ ParamModifierList mod = new ParamModifierList(this);
+ Expression expr = null;
+ p = null;
+ ArrayList arrayModifiers = null;
+ Location startLocation = la.Location;
+
+ while (la.kind == 40) {
+ AttributeSection(
+#line 2963 "VBNET.ATG"
+out section);
+
+#line 2963 "VBNET.ATG"
+ attributes.Add(section);
+ }
+ while (StartOf(29)) {
+ ParameterModifier(
+#line 2964 "VBNET.ATG"
+mod);
+ }
+ Identifier();
+
+#line 2965 "VBNET.ATG"
+ string parameterName = t.val;
+ if (
+#line 2966 "VBNET.ATG"
+IsDims()) {
+ ArrayTypeModifiers(
+#line 2966 "VBNET.ATG"
+out arrayModifiers);
+ }
+ if (la.kind == 63) {
+ lexer.NextToken();
+ TypeName(
+#line 2967 "VBNET.ATG"
+out type);
+ }
+
+#line 2969 "VBNET.ATG"
+ if(type != null) {
+ if (arrayModifiers != null) {
+ if (type.RankSpecifier != null) {
+ Error("array rank only allowed one time");
+ } else {
+ type.RankSpecifier = (int[])arrayModifiers.ToArray(typeof(int));
+ }
+ }
+ }
+
+ if (la.kind == 20) {
+ lexer.NextToken();
+ Expr(
+#line 2979 "VBNET.ATG"
+out expr);
+ }
+
+#line 2981 "VBNET.ATG"
+ mod.Check();
+ p = new ParameterDeclarationExpression(type, parameterName, mod.Modifier, expr);
+ p.Attributes = attributes;
+ p.StartLocation = startLocation;
+ p.EndLocation = t.EndLocation;
+
+ }
+
+ void GetAccessorDecl(
+#line 1401 "VBNET.ATG"
+out PropertyGetRegion getBlock, List attributes) {
+
+#line 1402 "VBNET.ATG"
+ Statement stmt = null; Modifiers m;
+ PropertyAccessorAccessModifier(
+#line 1404 "VBNET.ATG"
+out m);
+ Expect(128);
+
+#line 1406 "VBNET.ATG"
+ Location startLocation = t.Location;
+ Expect(1);
+ Block(
+#line 1408 "VBNET.ATG"
+out stmt);
+
+#line 1409 "VBNET.ATG"
+ getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes);
+ Expect(113);
+ Expect(128);
+
+#line 1411 "VBNET.ATG"
+ getBlock.Modifier = m;
+
+#line 1412 "VBNET.ATG"
+ getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation;
+ EndOfStmt();
+ }
+
+ void SetAccessorDecl(
+#line 1417 "VBNET.ATG"
+out PropertySetRegion setBlock, List attributes) {
+
+#line 1419 "VBNET.ATG"
+ Statement stmt = null;
+ List p = new List();
+ Modifiers m;
+
+ PropertyAccessorAccessModifier(
+#line 1424 "VBNET.ATG"
+out m);
+ Expect(198);
+
+#line 1426 "VBNET.ATG"
+ Location startLocation = t.Location;
+ if (la.kind == 37) {
+ lexer.NextToken();
+ if (StartOf(6)) {
+ FormalParameterList(
+#line 1427 "VBNET.ATG"
+p);
+ }
+ Expect(38);
+ }
+ Expect(1);
+ Block(
+#line 1429 "VBNET.ATG"
+out stmt);
+
+#line 1431 "VBNET.ATG"
+ setBlock = new PropertySetRegion((BlockStatement)stmt, attributes);
+ setBlock.Modifier = m;
+ setBlock.Parameters = p;
+
+ Expect(113);
+ Expect(198);
+
+#line 1436 "VBNET.ATG"
+ setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation;
+ EndOfStmt();
+ }
+
+ void PropertyAccessorAccessModifier(
+#line 3745 "VBNET.ATG"
+out Modifiers m) {
+
+#line 3746 "VBNET.ATG"
+ m = Modifiers.None;
+ while (StartOf(30)) {
+ if (la.kind == 188) {
+ lexer.NextToken();
+
+#line 3748 "VBNET.ATG"
+ m |= Modifiers.Public;
+ } else if (la.kind == 187) {
+ lexer.NextToken();
+
+#line 3749 "VBNET.ATG"
+ m |= Modifiers.Protected;
+ } else if (la.kind == 125) {
+ lexer.NextToken();
+
+#line 3750 "VBNET.ATG"
+ m |= Modifiers.Internal;
+ } else {
+ lexer.NextToken();
+
+#line 3751 "VBNET.ATG"
+ m |= Modifiers.Private;
+ }
+ }
+ }
+
+ void ArrayInitializationModifier(
+#line 1534 "VBNET.ATG"
+out List arrayModifiers) {
+
+#line 1536 "VBNET.ATG"
+ arrayModifiers = null;
+
+ Expect(37);
+ InitializationRankList(
+#line 1538 "VBNET.ATG"
+out arrayModifiers);
+ Expect(38);
+ }
+
+ void ArrayNameModifier(
+#line 2778 "VBNET.ATG"
+out ArrayList arrayModifiers) {
+
+#line 2780 "VBNET.ATG"
+ arrayModifiers = null;
+
+ ArrayTypeModifiers(
+#line 2782 "VBNET.ATG"
+out arrayModifiers);
+ }
+
+ void InitializationRankList(
+#line 1542 "VBNET.ATG"
+out List rank) {
+
+#line 1544 "VBNET.ATG"
+ rank = new List();
+ Expression expr = null;
+
+ Expr(
+#line 1547 "VBNET.ATG"
+out expr);
+ if (la.kind == 216) {
+ lexer.NextToken();
+
+#line 1548 "VBNET.ATG"
+ EnsureIsZero(expr);
+ Expr(
+#line 1549 "VBNET.ATG"
+out expr);
+ }
+
+#line 1551 "VBNET.ATG"
+ if (expr != null) { rank.Add(expr); }
+ while (la.kind == 22) {
+ lexer.NextToken();
+ Expr(
+#line 1553 "VBNET.ATG"
+out expr);
+ if (la.kind == 216) {
+ lexer.NextToken();
+
+#line 1554 "VBNET.ATG"
+ EnsureIsZero(expr);
+ Expr(
+#line 1555 "VBNET.ATG"
+out expr);
+ }
+
+#line 1557 "VBNET.ATG"
+ if (expr != null) { rank.Add(expr); }
+ }
+ }
+
+ void CollectionInitializer(
+#line 1562 "VBNET.ATG"
+out CollectionInitializerExpression outExpr) {
+
+#line 1564 "VBNET.ATG"
+ Expression expr = null;
+ CollectionInitializerExpression initializer = new CollectionInitializerExpression();
+ Location startLocation = la.Location;
+
+ Expect(35);
+ if (StartOf(24)) {
+ Expr(
+#line 1570 "VBNET.ATG"
+out expr);
+
+#line 1572 "VBNET.ATG"
+ if (expr != null) { initializer.CreateExpressions.Add(expr); }
+
+ while (
+#line 1575 "VBNET.ATG"
+NotFinalComma()) {
+ Expect(22);
+ Expr(
+#line 1575 "VBNET.ATG"
+out expr);
+
+#line 1576 "VBNET.ATG"
+ if (expr != null) { initializer.CreateExpressions.Add(expr); }
+ }
+ }
+ Expect(36);
+
+#line 1581 "VBNET.ATG"
+ outExpr = initializer;
+ outExpr.StartLocation = startLocation;
+ outExpr.EndLocation = t.EndLocation;
+
+ }
+
+ void EventMemberSpecifier(
+#line 1654 "VBNET.ATG"
+out string name) {
+
+#line 1655 "VBNET.ATG"
+ string eventName;
+ if (StartOf(4)) {
+ Identifier();
+ } else if (la.kind == 158) {
+ lexer.NextToken();
+ } else if (la.kind == 153) {
+ lexer.NextToken();
+ } else SynErr(275);
+
+#line 1658 "VBNET.ATG"
+ name = t.val;
+ Expect(26);
+ IdentifierOrKeyword(
+#line 1660 "VBNET.ATG"
+out eventName);
+
+#line 1661 "VBNET.ATG"
+ name = name + "." + eventName;
+ }
+
+ void IdentifierOrKeyword(
+#line 3678 "VBNET.ATG"
+out string name) {
+ lexer.NextToken();
+
+#line 3680 "VBNET.ATG"
+ name = t.val;
+ }
+
+ void QueryExpr(
+#line 2299 "VBNET.ATG"
+out Expression expr) {
+
+#line 2301 "VBNET.ATG"
+ QueryExpressionVB qexpr = new QueryExpressionVB();
+ qexpr.StartLocation = la.Location;
+ expr = qexpr;
+
+ FromOrAggregateQueryOperator(
+#line 2305 "VBNET.ATG"
+qexpr.Clauses);
+ while (StartOf(31)) {
+ QueryOperator(
+#line 2306 "VBNET.ATG"
+qexpr.Clauses);
+ }
+
+#line 2308 "VBNET.ATG"
+ qexpr.EndLocation = t.EndLocation;
+
+ }
+
+ void LambdaExpr(
+#line 2213 "VBNET.ATG"
+out Expression expr) {
+
+#line 2215 "VBNET.ATG"
+ LambdaExpression lambda = null;
+
+ if (la.kind == 210) {
+ SubLambdaExpression(
+#line 2217 "VBNET.ATG"
+out lambda);
+ } else if (la.kind == 127) {
+ FunctionLambdaExpression(
+#line 2218 "VBNET.ATG"
+out lambda);
+ } else SynErr(276);
+
+#line 2219 "VBNET.ATG"
+ expr = lambda;
+ }
+
+ void DisjunctionExpr(
+#line 1963 "VBNET.ATG"
+out Expression outExpr) {
+
+#line 1965 "VBNET.ATG"
+ Expression expr;
+ BinaryOperatorType op = BinaryOperatorType.None;
+ Location startLocation = la.Location;
+
+ ConjunctionExpr(
+#line 1969 "VBNET.ATG"
+out outExpr);
+ while (la.kind == 175 || la.kind == 177 || la.kind == 236) {
+ if (la.kind == 175) {
+ lexer.NextToken();
+
+#line 1972 "VBNET.ATG"
+ op = BinaryOperatorType.BitwiseOr;
+ } else if (la.kind == 177) {
+ lexer.NextToken();
+
+#line 1973 "VBNET.ATG"
+ op = BinaryOperatorType.LogicalOr;
+ } else {
+ lexer.NextToken();
+
+#line 1974 "VBNET.ATG"
+ op = BinaryOperatorType.ExclusiveOr;
+ }
+ ConjunctionExpr(
+#line 1976 "VBNET.ATG"
+out expr);
+
+#line 1976 "VBNET.ATG"
+ outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation };
+ }
+ }
+
+ void AssignmentOperator(
+#line 1681 "VBNET.ATG"
+out AssignmentOperatorType op) {
+
+#line 1682 "VBNET.ATG"
+ op = AssignmentOperatorType.None;
+ switch (la.kind) {
+ case 20: {
+ lexer.NextToken();
+
+#line 1683 "VBNET.ATG"
+ op = AssignmentOperatorType.Assign;
+ break;
+ }
+ case 54: {
+ lexer.NextToken();
+
+#line 1684 "VBNET.ATG"
+ op = AssignmentOperatorType.ConcatString;
+ break;
+ }
+ case 46: {
+ lexer.NextToken();
+
+#line 1685 "VBNET.ATG"
+ op = AssignmentOperatorType.Add;
+ break;
+ }
+ case 48: {
+ lexer.NextToken();
+
+#line 1686 "VBNET.ATG"
+ op = AssignmentOperatorType.Subtract;
+ break;
+ }
+ case 49: {
+ lexer.NextToken();
+
+#line 1687 "VBNET.ATG"
+ op = AssignmentOperatorType.Multiply;
+ break;
+ }
+ case 50: {
+ lexer.NextToken();
+
+#line 1688 "VBNET.ATG"
+ op = AssignmentOperatorType.Divide;
+ break;
+ }
+ case 51: {
+ lexer.NextToken();
+
+#line 1689 "VBNET.ATG"
+ op = AssignmentOperatorType.DivideInteger;
+ break;
+ }
+ case 47: {
+ lexer.NextToken();
+
+#line 1690 "VBNET.ATG"
+ op = AssignmentOperatorType.Power;
+ break;
+ }
+ case 52: {
+ lexer.NextToken();
+
+#line 1691 "VBNET.ATG"
+ op = AssignmentOperatorType.ShiftLeft;
+ break;
+ }
+ case 53: {
+ lexer.NextToken();
+
+#line 1692 "VBNET.ATG"
+ op = AssignmentOperatorType.ShiftRight;
+ break;
+ }
+ default: SynErr(277); break;
+ }
+ }
+
+ void SimpleExpr(
+#line 1696 "VBNET.ATG"
+out Expression pexpr) {
+
+#line 1697 "VBNET.ATG"
+ string name; Location startLocation = la.Location;
+ SimpleNonInvocationExpression(
+#line 1700 "VBNET.ATG"
+out pexpr);
+ while (StartOf(32)) {
+ if (la.kind == 26) {
+ lexer.NextToken();
+ if (la.kind == 10) {
+ lexer.NextToken();
+ IdentifierOrKeyword(
+#line 1703 "VBNET.ATG"
+out name);
+ Expect(11);
+
+#line 1704 "VBNET.ATG"
+ pexpr = new XmlMemberAccessExpression(pexpr, XmlAxisType.Element, name, true);
+ } else if (StartOf(33)) {
+ IdentifierOrKeyword(
+#line 1705 "VBNET.ATG"
+out name);
+
+#line 1706 "VBNET.ATG"
+ pexpr = new MemberReferenceExpression(pexpr, name) { StartLocation = startLocation, EndLocation = t.EndLocation };
+ } else SynErr(278);
+ if (
+#line 1708 "VBNET.ATG"
+la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) {
+ lexer.NextToken();
+ Expect(169);
+ TypeArgumentList(
+#line 1709 "VBNET.ATG"
+((MemberReferenceExpression)pexpr).TypeArguments);
+ Expect(38);
+ }
+ } else if (la.kind == 29) {
+ lexer.NextToken();
+ IdentifierOrKeyword(
+#line 1711 "VBNET.ATG"
+out name);
+
+#line 1711 "VBNET.ATG"
+ pexpr = new BinaryOperatorExpression(pexpr, BinaryOperatorType.DictionaryAccess, new PrimitiveExpression(name, name) { StartLocation = t.Location, EndLocation = t.EndLocation });
+ } else if (la.kind == 27 || la.kind == 28) {
+
+#line 1712 "VBNET.ATG"
+ XmlAxisType type = XmlAxisType.Attribute; bool isXmlName = false;
+ if (la.kind == 28) {
+ lexer.NextToken();
+ } else if (la.kind == 27) {
+ lexer.NextToken();
+
+#line 1713 "VBNET.ATG"
+ type = XmlAxisType.Descendents;
+ } else SynErr(279);
+ if (la.kind == 10) {
+ lexer.NextToken();
+
+#line 1713 "VBNET.ATG"
+ isXmlName = true;
+ }
+ IdentifierOrKeyword(
+#line 1713 "VBNET.ATG"
+out name);
+ if (la.kind == 11) {
+ lexer.NextToken();
+ }
+
+#line 1714 "VBNET.ATG"
+ pexpr = new XmlMemberAccessExpression(pexpr, type, name, isXmlName);
+ } else {
+ InvocationExpression(
+#line 1715 "VBNET.ATG"
+ref pexpr);
+ }
+ }
+
+#line 1719 "VBNET.ATG"
+ if (pexpr != null) {
+ pexpr.StartLocation = startLocation;
+ pexpr.EndLocation = t.EndLocation;
+ }
+
+ }
+
+ void SimpleNonInvocationExpression(
+#line 1726 "VBNET.ATG"
+out Expression pexpr) {
+
+#line 1728 "VBNET.ATG"
+ Expression expr;
+ CollectionInitializerExpression cie;
+ TypeReference type = null;
+ string name = String.Empty;
+ Location startLocation = la.Location;
+ pexpr = null;
+
+ if (StartOf(34)) {
+ switch (la.kind) {
+ case 3: {
+ lexer.NextToken();
+
+#line 1738 "VBNET.ATG"
+ pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
+ break;
+ }
+ case 4: {
+ lexer.NextToken();
+
+#line 1739 "VBNET.ATG"
+ pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
+ break;
+ }
+ case 7: {
+ lexer.NextToken();
+
+#line 1740 "VBNET.ATG"
+ pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
+ break;
+ }
+ case 6: {
+ lexer.NextToken();
+
+#line 1741 "VBNET.ATG"
+ pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
+ break;
+ }
+ case 5: {
+ lexer.NextToken();
+
+#line 1742 "VBNET.ATG"
+ pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
+ break;
+ }
+ case 9: {
+ lexer.NextToken();
+
+#line 1743 "VBNET.ATG"
+ pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
+ break;
+ }
+ case 8: {
+ lexer.NextToken();
+
+#line 1744 "VBNET.ATG"
+ pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
+ break;
+ }
+ case 217: {
+ lexer.NextToken();
+
+#line 1746 "VBNET.ATG"
+ pexpr = new PrimitiveExpression(true, "true");
+ break;
+ }
+ case 122: {
+ lexer.NextToken();
+
+#line 1747 "VBNET.ATG"
+ pexpr = new PrimitiveExpression(false, "false");
+ break;
+ }
+ case 165: {
+ lexer.NextToken();
+
+#line 1748 "VBNET.ATG"
+ pexpr = new PrimitiveExpression(null, "null");
+ break;
+ }
+ case 37: {
+ lexer.NextToken();
+ Expr(
+#line 1749 "VBNET.ATG"
+out expr);
+ Expect(38);
+
+#line 1749 "VBNET.ATG"
+ pexpr = new ParenthesizedExpression(expr);
+ break;
+ }
+ case 2: case 58: case 62: case 64: case 65: case 66: case 67: case 70: case 87: case 98: case 104: case 107: case 116: case 121: case 126: case 133: case 139: case 143: case 146: case 147: case 170: case 176: case 178: case 184: case 203: case 212: case 213: case 223: case 224: case 230: {
+ Identifier();
+
+#line 1751 "VBNET.ATG"
+ pexpr = new IdentifierExpression(t.val);
+ pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation;
+
+ if (
+#line 1754 "VBNET.ATG"
+la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of) {
+ lexer.NextToken();
+ Expect(169);
+ TypeArgumentList(
+#line 1755 "VBNET.ATG"
+((IdentifierExpression)pexpr).TypeArguments);
+ Expect(38);
+ }
+ break;
+ }
+ case 68: case 71: case 82: case 99: case 100: case 109: case 141: case 151: case 168: case 196: case 201: case 202: case 208: case 221: case 222: case 225: {
+
+#line 1757 "VBNET.ATG"
+ string val = String.Empty;
+ if (StartOf(12)) {
+ PrimitiveTypeName(
+#line 1758 "VBNET.ATG"
+out val);
+ } else if (la.kind == 168) {
+ lexer.NextToken();
+
+#line 1758 "VBNET.ATG"
+ val = "System.Object";
+ } else SynErr(280);
+
+#line 1759 "VBNET.ATG"
+ pexpr = new TypeReferenceExpression(new TypeReference(val, true));
+ break;
+ }
+ case 153: {
+ lexer.NextToken();
+
+#line 1760 "VBNET.ATG"
+ pexpr = new ThisReferenceExpression();
+ break;
+ }
+ case 158: case 159: {
+
+#line 1761 "VBNET.ATG"
+ Expression retExpr = null;
+ if (la.kind == 158) {
+ lexer.NextToken();
+
+#line 1762 "VBNET.ATG"
+ retExpr = new BaseReferenceExpression() { StartLocation = t.Location, EndLocation = t.EndLocation };
+ } else if (la.kind == 159) {
+ lexer.NextToken();
+
+#line 1763 "VBNET.ATG"
+ retExpr = new ClassReferenceExpression() { StartLocation = t.Location, EndLocation = t.EndLocation };
+ } else SynErr(281);
+ Expect(26);
+ IdentifierOrKeyword(
+#line 1765 "VBNET.ATG"
+out name);
+
+#line 1765 "VBNET.ATG"
+ pexpr = new MemberReferenceExpression(retExpr, name) { StartLocation = startLocation, EndLocation = t.EndLocation };
+ break;
+ }
+ case 130: {
+ lexer.NextToken();
+ Expect(26);
+ Identifier();
+
+#line 1767 "VBNET.ATG"
+ type = new TypeReference(t.val ?? "");
+
+#line 1769 "VBNET.ATG"
+ type.IsGlobal = true;
+
+#line 1770 "VBNET.ATG"
+ pexpr = new TypeReferenceExpression(type);
+ break;
+ }
+ case 162: {
+ ObjectCreateExpression(
+#line 1771 "VBNET.ATG"
+out expr);
+
+#line 1771 "VBNET.ATG"
+ pexpr = expr;
+ break;
+ }
+ case 35: {
+ CollectionInitializer(
+#line 1772 "VBNET.ATG"
+out cie);
+
+#line 1772 "VBNET.ATG"
+ pexpr = cie;
+ break;
+ }
+ case 94: case 106: case 219: {
+
+#line 1774 "VBNET.ATG"
+ CastType castType = CastType.Cast;
+ if (la.kind == 106) {
+ lexer.NextToken();
+ } else if (la.kind == 94) {
+ lexer.NextToken();
+
+#line 1776 "VBNET.ATG"
+ castType = CastType.Conversion;
+ } else if (la.kind == 219) {
+ lexer.NextToken();
+
+#line 1777 "VBNET.ATG"
+ castType = CastType.TryCast;
+ } else SynErr(282);
+ Expect(37);
+ Expr(
+#line 1779 "VBNET.ATG"
+out expr);
+ Expect(22);
+ TypeName(
+#line 1779 "VBNET.ATG"
+out type);
+ Expect(38);
+
+#line 1780 "VBNET.ATG"
+ pexpr = new CastExpression(type, expr, castType);
+ break;
+ }
+ case 76: case 77: case 78: case 79: case 80: case 81: case 83: case 85: case 86: case 90: case 91: case 92: case 93: case 95: case 96: case 97: {
+ CastTarget(
+#line 1781 "VBNET.ATG"
+out type);
+ Expect(37);
+ Expr(
+#line 1781 "VBNET.ATG"
+out expr);
+ Expect(38);
+
+#line 1781 "VBNET.ATG"
+ pexpr = new CastExpression(type, expr, CastType.PrimitiveConversion);
+ break;
+ }
+ case 57: {
+ lexer.NextToken();
+ Expr(
+#line 1782 "VBNET.ATG"
+out expr);
+
+#line 1782 "VBNET.ATG"
+ pexpr = new AddressOfExpression(expr);
+ break;
+ }
+ case 129: {
+ lexer.NextToken();
+ Expect(37);
+ GetTypeTypeName(
+#line 1783 "VBNET.ATG"
+out type);
+ Expect(38);
+
+#line 1783 "VBNET.ATG"
+ pexpr = new TypeOfExpression(type);
+ break;
+ }
+ case 220: {
+ lexer.NextToken();
+ SimpleExpr(
+#line 1784 "VBNET.ATG"
+out expr);
+ Expect(144);
+ TypeName(
+#line 1784 "VBNET.ATG"
+out type);
+
+#line 1784 "VBNET.ATG"
+ pexpr = new TypeOfIsExpression(expr, type);
+ break;
+ }
+ case 135: {
+ ConditionalExpression(
+#line 1785 "VBNET.ATG"
+out pexpr);
+ break;
+ }
+ case 10: case 16: case 17: case 18: case 19: {
+ XmlLiteralExpression(
+#line 1786 "VBNET.ATG"
+out pexpr);
+ break;
+ }
+ }
+ } else if (StartOf(35)) {
+ if (la.kind == 26) {
+ lexer.NextToken();
+ if (la.kind == 10) {
+ lexer.NextToken();
+ IdentifierOrKeyword(
+#line 1792 "VBNET.ATG"
+out name);
+ Expect(11);
+
+#line 1793 "VBNET.ATG"
+ pexpr = new XmlMemberAccessExpression(null, XmlAxisType.Element, name, true) { StartLocation = startLocation, EndLocation = t.EndLocation };
+ } else if (StartOf(33)) {
+ IdentifierOrKeyword(
+#line 1794 "VBNET.ATG"
+out name);
+
+#line 1795 "VBNET.ATG"
+ pexpr = new MemberReferenceExpression(null, name) { StartLocation = startLocation, EndLocation = t.EndLocation };
+ } else SynErr(283);
+ } else if (la.kind == 29) {
+ lexer.NextToken();
+ IdentifierOrKeyword(
+#line 1797 "VBNET.ATG"
+out name);
+
+#line 1797 "VBNET.ATG"
+ pexpr = new BinaryOperatorExpression(null, BinaryOperatorType.DictionaryAccess, new PrimitiveExpression(name, name) { StartLocation = t.Location, EndLocation = t.EndLocation });
+ } else {
+
+#line 1798 "VBNET.ATG"
+ XmlAxisType axisType = XmlAxisType.Element; bool isXmlIdentifier = false;
+ if (la.kind == 27) {
+ lexer.NextToken();
+
+#line 1799 "VBNET.ATG"
+ axisType = XmlAxisType.Descendents;
+ } else if (la.kind == 28) {
+ lexer.NextToken();
+
+#line 1799 "VBNET.ATG"
+ axisType = XmlAxisType.Attribute;
+ } else SynErr(284);
+ if (la.kind == 10) {
+ lexer.NextToken();
+
+#line 1800 "VBNET.ATG"
+ isXmlIdentifier = true;
+ }
+ IdentifierOrKeyword(
+#line 1800 "VBNET.ATG"
+out name);
+ if (la.kind == 11) {
+ lexer.NextToken();
+ }
+
+#line 1801 "VBNET.ATG"
+ pexpr = new XmlMemberAccessExpression(null, axisType, name, isXmlIdentifier);
+ }
+ } else SynErr(285);
+
+#line 1806 "VBNET.ATG"
+ if (pexpr != null) {
+ pexpr.StartLocation = startLocation;
+ pexpr.EndLocation = t.EndLocation;
+ }
+
+ }
+
+ void TypeArgumentList(
+#line 2814 "VBNET.ATG"
+List typeArguments) {
+
+#line 2816 "VBNET.ATG"
+ TypeReference typeref;
+
+ TypeName(
+#line 2818 "VBNET.ATG"
+out typeref);
+
+#line 2818 "VBNET.ATG"
+ if (typeref != null) typeArguments.Add(typeref);
+ while (la.kind == 22) {
+ lexer.NextToken();
+ TypeName(
+#line 2821 "VBNET.ATG"
+out typeref);
+
+#line 2821 "VBNET.ATG"
+ if (typeref != null) typeArguments.Add(typeref);
+ }
+ }
+
+ void InvocationExpression(
+#line 1927 "VBNET.ATG"
+ref Expression pexpr) {
+
+#line 1928 "VBNET.ATG"
+ List parameters = null;
+ Expect(37);
+
+#line 1930 "VBNET.ATG"
+ Location start = t.Location;
+ ArgumentList(
+#line 1931 "VBNET.ATG"
+out parameters);
+ Expect(38);
+
+#line 1934 "VBNET.ATG"
+ pexpr = new InvocationExpression(pexpr, parameters);
+
+
+#line 1936 "VBNET.ATG"
+ pexpr.StartLocation = start; pexpr.EndLocation = t.Location;
+ }
+
+ void PrimitiveTypeName(
+#line 3685 "VBNET.ATG"
+out string type) {
+
+#line 3686 "VBNET.ATG"
+ type = String.Empty;
+ switch (la.kind) {
+ case 68: {
+ lexer.NextToken();
+
+#line 3687 "VBNET.ATG"
+ type = "System.Boolean";
+ break;
+ }
+ case 99: {
+ lexer.NextToken();
+
+#line 3688 "VBNET.ATG"
+ type = "System.DateTime";
+ break;
+ }
+ case 82: {
+ lexer.NextToken();
+
+#line 3689 "VBNET.ATG"
+ type = "System.Char";
+ break;
+ }
+ case 208: {
+ lexer.NextToken();
+
+#line 3690 "VBNET.ATG"
+ type = "System.String";
+ break;
+ }
+ case 100: {
+ lexer.NextToken();
+
+#line 3691 "VBNET.ATG"
+ type = "System.Decimal";
+ break;
+ }
+ case 71: {
+ lexer.NextToken();
+
+#line 3692 "VBNET.ATG"
+ type = "System.Byte";
+ break;
+ }
+ case 201: {
+ lexer.NextToken();
+
+#line 3693 "VBNET.ATG"
+ type = "System.Int16";
+ break;
+ }
+ case 141: {
+ lexer.NextToken();
+
+#line 3694 "VBNET.ATG"
+ type = "System.Int32";
+ break;
+ }
+ case 151: {
+ lexer.NextToken();
+
+#line 3695 "VBNET.ATG"
+ type = "System.Int64";
+ break;
+ }
+ case 202: {
+ lexer.NextToken();
+
+#line 3696 "VBNET.ATG"
+ type = "System.Single";
+ break;
+ }
+ case 109: {
+ lexer.NextToken();
+
+#line 3697 "VBNET.ATG"
+ type = "System.Double";
+ break;
+ }
+ case 221: {
+ lexer.NextToken();
+
+#line 3698 "VBNET.ATG"
+ type = "System.UInt32";
+ break;
+ }
+ case 222: {
+ lexer.NextToken();
+
+#line 3699 "VBNET.ATG"
+ type = "System.UInt64";
+ break;
+ }
+ case 225: {
+ lexer.NextToken();
+
+#line 3700 "VBNET.ATG"
+ type = "System.UInt16";
+ break;
+ }
+ case 196: {
+ lexer.NextToken();
+
+#line 3701 "VBNET.ATG"
+ type = "System.SByte";
+ break;
+ }
+ default: SynErr(286); break;
+ }
+ }
+
+ void CastTarget(
+#line 1941 "VBNET.ATG"
+out TypeReference type) {
+
+#line 1943 "VBNET.ATG"
+ type = null;
+
+ switch (la.kind) {
+ case 76: {
+ lexer.NextToken();
+
+#line 1945 "VBNET.ATG"
+ type = new TypeReference("System.Boolean", true);
+ break;
+ }
+ case 77: {
+ lexer.NextToken();
+
+#line 1946 "VBNET.ATG"
+ type = new TypeReference("System.Byte", true);
+ break;
+ }
+ case 90: {
+ lexer.NextToken();
+
+#line 1947 "VBNET.ATG"
+ type = new TypeReference("System.SByte", true);
+ break;
+ }
+ case 78: {
+ lexer.NextToken();
+
+#line 1948 "VBNET.ATG"
+ type = new TypeReference("System.Char", true);
+ break;
+ }
+ case 79: {
+ lexer.NextToken();
+
+#line 1949 "VBNET.ATG"
+ type = new TypeReference("System.DateTime", true);
+ break;
+ }
+ case 81: {
+ lexer.NextToken();
+
+#line 1950 "VBNET.ATG"
+ type = new TypeReference("System.Decimal", true);
+ break;
+ }
+ case 80: {
+ lexer.NextToken();
+
+#line 1951 "VBNET.ATG"
+ type = new TypeReference("System.Double", true);
+ break;
+ }
+ case 91: {
+ lexer.NextToken();
+
+#line 1952 "VBNET.ATG"
+ type = new TypeReference("System.Int16", true);
+ break;
+ }
+ case 83: {
+ lexer.NextToken();
+
+#line 1953 "VBNET.ATG"
+ type = new TypeReference("System.Int32", true);
+ break;
+ }
+ case 85: {
+ lexer.NextToken();
+
+#line 1954 "VBNET.ATG"
+ type = new TypeReference("System.Int64", true);
+ break;
+ }
+ case 97: {
+ lexer.NextToken();
+
+#line 1955 "VBNET.ATG"
+ type = new TypeReference("System.UInt16", true);
+ break;
+ }
+ case 95: {
+ lexer.NextToken();
+
+#line 1956 "VBNET.ATG"
+ type = new TypeReference("System.UInt32", true);
+ break;
+ }
+ case 96: {
+ lexer.NextToken();
+
+#line 1957 "VBNET.ATG"
+ type = new TypeReference("System.UInt64", true);
+ break;
+ }
+ case 86: {
+ lexer.NextToken();
+
+#line 1958 "VBNET.ATG"
+ type = new TypeReference("System.Object", true);
+ break;
+ }
+ case 92: {
+ lexer.NextToken();
+
+#line 1959 "VBNET.ATG"
+ type = new TypeReference("System.Single", true);
+ break;
+ }
+ case 93: {
+ lexer.NextToken();
+
+#line 1960 "VBNET.ATG"
+ type = new TypeReference("System.String", true);
+ break;
+ }
+ default: SynErr(287); break;
+ }
+ }
+
+ void GetTypeTypeName(
+#line 2713 "VBNET.ATG"
+out TypeReference typeref) {
+
+#line 2714 "VBNET.ATG"
+ ArrayList rank = null;
+ NonArrayTypeName(
+#line 2716 "VBNET.ATG"
+out typeref, true);
+ ArrayTypeModifiers(
+#line 2717 "VBNET.ATG"
+out rank);
+
+#line 2718 "VBNET.ATG"
+ if (rank != null && typeref != null) {
+ typeref.RankSpecifier = (int[])rank.ToArray(typeof(int));
+ }
+
+ }
+
+ void ConditionalExpression(
+#line 1893 "VBNET.ATG"
+out Expression expr) {
+
+#line 1895 "VBNET.ATG"
+ ConditionalExpression conditionalExpression = new ConditionalExpression();
+ BinaryOperatorExpression binaryOperatorExpression = new BinaryOperatorExpression();
+ conditionalExpression.StartLocation = binaryOperatorExpression.StartLocation = la.Location;
+
+ Expression condition = null;
+ Expression trueExpr = null;
+ Expression falseExpr = null;
+
+ Expect(135);
+ Expect(37);
+ Expr(
+#line 1904 "VBNET.ATG"
+out condition);
+ Expect(22);
+ Expr(
+#line 1904 "VBNET.ATG"
+out trueExpr);
+ if (la.kind == 22) {
+ lexer.NextToken();
+ Expr(
+#line 1904 "VBNET.ATG"
+out falseExpr);
+ }
+ Expect(38);
+
+#line 1906 "VBNET.ATG"
+ if(falseExpr != null)
+ {
+ conditionalExpression.Condition = condition;
+ conditionalExpression.TrueExpression = trueExpr;
+ conditionalExpression.FalseExpression = falseExpr;
+ conditionalExpression.EndLocation = t.EndLocation;
+
+ expr = conditionalExpression;
+ }
+ else
+ {
+ binaryOperatorExpression.Left = condition;
+ binaryOperatorExpression.Right = trueExpr;
+ binaryOperatorExpression.Op = BinaryOperatorType.NullCoalescing;
+ binaryOperatorExpression.EndLocation = t.EndLocation;
+
+ expr = binaryOperatorExpression;
+ }
+
+ }
+
+ void XmlLiteralExpression(
+#line 1813 "VBNET.ATG"
+out Expression pexpr) {
+
+#line 1815 "VBNET.ATG"
+ List exprs = new List();
+ XmlExpression currentExpression = null;
+
+ if (StartOf(36)) {
+ XmlContentExpression(
+#line 1820 "VBNET.ATG"
+exprs);
+ while (StartOf(36)) {
+ XmlContentExpression(
+#line 1820 "VBNET.ATG"
+exprs);
+ }
+ if (la.kind == 10) {
+ XmlElement(
+#line 1820 "VBNET.ATG"
+out currentExpression);
+
+#line 1820 "VBNET.ATG"
+ exprs.Add(currentExpression);
+ while (StartOf(36)) {
+ XmlContentExpression(
+#line 1820 "VBNET.ATG"
+exprs);
+ }
+ }
+ } else if (la.kind == 10) {
+ XmlElement(
+#line 1822 "VBNET.ATG"
+out currentExpression);
+
+#line 1822 "VBNET.ATG"
+ exprs.Add(currentExpression);
+ while (StartOf(36)) {
+ XmlContentExpression(
+#line 1822 "VBNET.ATG"
+exprs);
+ }
+ } else SynErr(288);
+
+#line 1825 "VBNET.ATG"
+ if (exprs.Count > 1) {
+ pexpr = new XmlDocumentExpression() { Expressions = exprs };
+ } else {
+ pexpr = exprs[0];
+ }
+
+ }
+
+ void XmlContentExpression(
+#line 1833 "VBNET.ATG"
+List exprs) {
+
+#line 1834 "VBNET.ATG"
+ XmlContentExpression expr = null;
+ if (la.kind == 16) {
+ lexer.NextToken();
+
+#line 1836 "VBNET.ATG"
+ expr = new XmlContentExpression(t.val, XmlContentType.Text);
+ } else if (la.kind == 18) {
+ lexer.NextToken();
+
+#line 1837 "VBNET.ATG"
+ expr = new XmlContentExpression(t.val, XmlContentType.CData);
+ } else if (la.kind == 17) {
+ lexer.NextToken();
+
+#line 1838 "VBNET.ATG"
+ expr = new XmlContentExpression(t.val, XmlContentType.Comment);
+ } else if (la.kind == 19) {
+ lexer.NextToken();
+
+#line 1839 "VBNET.ATG"
+ expr = new XmlContentExpression(t.val, XmlContentType.ProcessingInstruction);
+ } else SynErr(289);
+
+#line 1842 "VBNET.ATG"
+ expr.StartLocation = t.Location;
+ expr.EndLocation = t.EndLocation;
+ exprs.Add(expr);
+
+ }
+
+ void XmlElement(
+#line 1868 "VBNET.ATG"
+out XmlExpression expr) {
+
+#line 1869 "VBNET.ATG"
+ XmlElementExpression el = new XmlElementExpression();
+ Expect(10);
+
+#line 1872 "VBNET.ATG"
+ el.StartLocation = t.Location;
+ if (la.kind == 12) {
+ lexer.NextToken();
+
+#line 1873 "VBNET.ATG"
+ Expression innerExpression;
+ Expr(
+#line 1873 "VBNET.ATG"
+out innerExpression);
+ Expect(13);
+
+#line 1874 "VBNET.ATG"
+ el.NameExpression = new XmlEmbeddedExpression() { InlineVBExpression = innerExpression };
+ } else if (StartOf(4)) {
+ Identifier();
+
+#line 1875 "VBNET.ATG"
+ el.XmlName = t.val;
+ } else SynErr(290);
+ while (StartOf(37)) {
+ XmlAttribute(
+#line 1875 "VBNET.ATG"
+el.Attributes);
+ }
+ if (la.kind == 14) {
+ lexer.NextToken();
+
+#line 1876 "VBNET.ATG"
+ el.EndLocation = t.EndLocation;
+ } else if (la.kind == 11) {
+ lexer.NextToken();
+ while (StartOf(38)) {
+
+#line 1876 "VBNET.ATG"
+ XmlExpression child;
+ XmlNestedContent(
+#line 1876 "VBNET.ATG"
+out child);
+
+#line 1876 "VBNET.ATG"
+ el.Children.Add(child);
+ }
+ Expect(15);
+ while (StartOf(39)) {
+ lexer.NextToken();
+ }
+ Expect(11);
+
+#line 1876 "VBNET.ATG"
+ el.EndLocation = t.EndLocation;
+ } else SynErr(291);
+
+#line 1878 "VBNET.ATG"
+ expr = el;
+ }
+
+ void XmlNestedContent(
+#line 1848 "VBNET.ATG"
+out XmlExpression expr) {
+
+#line 1849 "VBNET.ATG"
+ XmlExpression tmpExpr = null; Location start = la.Location;
+ switch (la.kind) {
+ case 16: {
+ lexer.NextToken();
+
+#line 1852 "VBNET.ATG"
+ tmpExpr = new XmlContentExpression(t.val, XmlContentType.Text);
+ break;
+ }
+ case 18: {
+ lexer.NextToken();
+
+#line 1853 "VBNET.ATG"
+ tmpExpr = new XmlContentExpression(t.val, XmlContentType.CData);
+ break;
+ }
+ case 17: {
+ lexer.NextToken();
+
+#line 1854 "VBNET.ATG"
+ tmpExpr = new XmlContentExpression(t.val, XmlContentType.Comment);
+ break;
+ }
+ case 19: {
+ lexer.NextToken();
+
+#line 1855 "VBNET.ATG"
+ tmpExpr = new XmlContentExpression(t.val, XmlContentType.ProcessingInstruction);
+ break;
+ }
+ case 12: {
+ lexer.NextToken();
+
+#line 1856 "VBNET.ATG"
+ Expression innerExpression;
+ Expr(
+#line 1856 "VBNET.ATG"
+out innerExpression);
+ Expect(13);
+
+#line 1856 "VBNET.ATG"
+ tmpExpr = new XmlEmbeddedExpression() { InlineVBExpression = innerExpression };
+ break;
+ }
+ case 10: {
+ XmlElement(
+#line 1857 "VBNET.ATG"
+out tmpExpr);
+ break;
+ }
+ default: SynErr(292); break;
+ }
+
+#line 1860 "VBNET.ATG"
+ if (tmpExpr.StartLocation.IsEmpty)
+ tmpExpr.StartLocation = start;
+ if (tmpExpr.EndLocation.IsEmpty)
+ tmpExpr.EndLocation = t.EndLocation;
+ expr = tmpExpr;
+
+ }
+
+ void XmlAttribute(
+#line 1881 "VBNET.ATG"
+List attrs) {
+
+#line 1882 "VBNET.ATG"
+ Location start = la.Location;
+ if (StartOf(4)) {
+ Identifier();
+
+#line 1884 "VBNET.ATG"
+ string name = t.val;
+ Expect(20);
+
+#line 1885 "VBNET.ATG"
+ string literalValue = null; Expression expressionValue = null; bool useDoubleQuotes = false;
+ if (la.kind == 3) {
+ lexer.NextToken();
+
+#line 1886 "VBNET.ATG"
+ literalValue = t.literalValue.ToString(); useDoubleQuotes = t.val[0] == '"';
+ } else if (la.kind == 12) {
+ lexer.NextToken();
+ Expr(
+#line 1886 "VBNET.ATG"
+out expressionValue);
+ Expect(13);
+ } else SynErr(293);
+
+#line 1887 "VBNET.ATG"
+ attrs.Add(new XmlAttributeExpression() { Name = name, ExpressionValue = expressionValue, LiteralValue = literalValue, UseDoubleQuotes = useDoubleQuotes, StartLocation = start, EndLocation = t.EndLocation });
+ } else if (la.kind == 12) {
+ lexer.NextToken();
+
+#line 1889 "VBNET.ATG"
+ Expression innerExpression;
+ Expr(
+#line 1889 "VBNET.ATG"
+out innerExpression);
+ Expect(13);
+
+#line 1890 "VBNET.ATG"
+ attrs.Add(new XmlEmbeddedExpression() { InlineVBExpression = innerExpression, StartLocation = start, EndLocation = t.EndLocation });
+ } else SynErr(294);
+ }
+
+ void ArgumentList(
+#line 2642 "VBNET.ATG"
+out List arguments) {
+
+#line 2644 "VBNET.ATG"
+ arguments = new List