[MonoDevelop] RE:more compilation problems

Todd Berman tberman@sevenl.net
Wed, 21 Jan 2004 17:03:08 -0500


These are all legal in cvs, and the attribute has to be legal on .NET
cause its what #D uses and compiles with on windows :)

For MD you *must* be using mono and gtk-sharp from cvs for right now.

I know this is an inconveinence, but we needed patches in both to get
working what we have :)

--Todd

On Wed, 2004-01-21 at 16:37, Blair Jennings wrote:
> Here are the two main compile fixes. I came across these yesterday after 
> doing a totally clean rebuild of my box (I have been out of town for the 
> last week and a half). I checked the MenuItemCodon.cs against the .NET 
> spec and the attribute was defined wrong (calling for as new char() is 
> illegal in an attribute). The ConvertXml.cs issue is one of 
> appropriateness the call in the one in the svn repository is .NET 
> version 1.1 but mono 0.29 is still .NET 1.0 for the System.Xml.Xsl 
> Namespace (I have confirmed this in the Ximian CVS for mcs).
> 
> Blair Jennings
> 
> ______________________________________________________________________
> // <file>
> //     <copyright see="prj:///doc/copyright.txt"/>
> //     <license see="prj:///doc/license.txt"/>
> //     <owner name="Mike Krger" email="mike@icsharpcode.net"/>
> //     <version value="$version"/>
> // </file>
> 
> using System;
> using System.IO;
> using System.Xml;
> using System.Xml.XPath;
> using System.Xml.Xsl;
> using System.Security;
> using System.Security.Permissions;
> 
> namespace ICSharpCode.SharpDevelop.Internal.Project
> {
> 	/// <summary>
> 	/// This class is used to convert xml files using xslt
> 	/// </summary>
> 	public class ConvertXml
> 	{
> 		/// <remarks>
> 		/// The main module loads the three required input vars
> 		/// and performs the transform
> 		/// </remarks>
> 		/// <param name="args">
> 		/// arg1 - the input file (preferably VS.NET .csproj)
> 		/// arg2 - path to XSL transform file
> 		/// arg3 - path to output file (preferably SD .prjx)
> 		/// </param>
> 		public static void Convert(string inputFile, string xslPath, string outputFile)
> 		{
> 			Convert(inputFile, xslPath, outputFile, null);
> 		}
> 		public static void Convert(string inputFile, string xslPath, string outputFile, XsltArgumentList xsltArgList)
> 		{
> 			// Transform the file
> 			XmlReader reader = GetXML(inputFile);
> 			XmlReader oTransformed = TransformXmlToXml(reader, xslPath, xsltArgList);
> 			reader.Close();
> 			
> 			// Output results to file path
> 			XmlDocument myDoc = new XmlDocument();
> 			myDoc.Load(oTransformed);
> 			myDoc.Save(outputFile);
> 		}
> 		
> 		public static void Convert(string inputFile, XmlReader xslReader, string outputFile, XsltArgumentList xsltArgList)
> 		{
> 			// Transform the file
> 			XmlReader reader = GetXML(inputFile);
> 			XmlReader oTransformed = TransformXmlToXml(reader, xslReader, xsltArgList);
> 			reader.Close();
> 			
> 			// Output results to file path
> 			XmlDocument myDoc = new XmlDocument();
> 			myDoc.Load(oTransformed);
> 			myDoc.Save(outputFile);
> 		}
> 
> 		public static string ConvertToString(string inputFile, string xslPath)
> 		{
> 			return ConvertToString(inputFile, xslPath, null);
> 		}
> 		
> 		public static string ConvertToString(string inputFile, string xslPath, XsltArgumentList xsltArgList)
> 		{
> 			// Transform the file
> 			XmlReader reader = GetXML(inputFile);
> 			XmlReader oTransformed = TransformXmlToXml(reader, xslPath, xsltArgList);
> 			reader.Close();
> 			
> 			// Output results to string
> 			XmlDocument myDoc = new XmlDocument();
> 			myDoc.Load(oTransformed);
> 			StringWriter sw = new StringWriter();
> 			myDoc.Save(sw);
> 			return sw.ToString();
> 		}
> 		
> 		public static string ConvertData(string inputXml, string xslPath, XsltArgumentList xsltArgList)
> 		{
> 			XmlReader reader = new XmlTextReader(new StringReader(inputXml));
> 			XmlReader oTransformed = TransformXmlToXml(reader, xslPath, xsltArgList);
> 			reader.Close();
> 			
> 			// Output results to string
> 			XmlDocument myDoc = new XmlDocument();
> 			myDoc.Load(oTransformed);
> 			StringWriter sw = new StringWriter();
> 			myDoc.Save(sw);
> 			return sw.ToString();
> 		}
> 		
> 		public static string ConvertData(string inputXml, XmlReader xslReader, XsltArgumentList xsltArgList)
> 		{
> 			XmlReader reader = new XmlTextReader(new StringReader(inputXml));
> 			XmlReader oTransformed = TransformXmlToXml(reader, xslReader, xsltArgList);
> 			reader.Close();
> 			
> 			// Output results to string
> 			XmlDocument myDoc = new XmlDocument();
> 			myDoc.Load(oTransformed);
> 			StringWriter sw = new StringWriter();
> 			myDoc.Save(sw);
> 			return sw.ToString();
> 		}
> 		
> 		public static XmlReader TransformXmlToXml(XmlReader oXML, string XSLPath, XsltArgumentList xsltArgList)
> 		{
> 			XslTransform xslt = new XslTransform();
> 			xslt.Load(XSLPath);
> 			
> 			XPathDocument inputData = new XPathDocument(oXML);
> 			xslt.XmlResolver = new XmlSecureResolver(new XmlUrlResolver(), new PermissionSet(PermissionState.Unrestricted));
> 			
> 			return xslt.Transform(inputData, xsltArgList);
> 		}
> 		
> 		public static XmlReader TransformXmlToXml(XmlReader oXML, XmlReader XSLReader, XsltArgumentList xsltArgList)
> 		{
> 			XslTransform xslt = new XslTransform();
> 			xslt.Load(XSLReader, new XmlSecureResolver(new XmlUrlResolver(), new PermissionSet(PermissionState.Unrestricted)), null);
> 			
> 			XPathDocument inputData = new XPathDocument(oXML);
> 			xslt.XmlResolver = new XmlSecureResolver(new XmlUrlResolver(), new PermissionSet(PermissionState.Unrestricted));
> 			return xslt.Transform(inputData, xsltArgList);
> 		}
> 		
> 		/// <summary>
> 		/// GetXML returns an XmlReader dependent on the contents
> 		/// of the passed input param.
> 		/// GetXML checks for the following conditions:
> 		/// blank string returns an empty XmlReader
> 		/// less-than at start assumes an XML file
> 		/// back-slash at start assumes UNC path
> 		/// otherwise, URL is assumed
> 		/// </summary>
> 		/// <param name="strInput"></param>
> 		/// <returns></returns>
> 		public static XmlReader GetXML(string strInput)
> 		{
> 			// Check if string is blank
> 			if (strInput.Length == 0) {
> 				// Return the empty xml reader
> 				return new XmlTextReader("");
> 			} else {
> 					// Check if string starts with "<"
> 					// If it does, it is an XML file
> 					if (strInput.Substring(0,1) == "<")
> 					{
> 						//String could be an xml file - load
> 						return new XmlTextReader(new StringReader(strInput));
> 					}
> 					else
> 						{
> 							// Assume this is a file path - return loaded XML
> 							return new XmlTextReader(strInput);
> 						}
> 				}
> 		}
> 	}
> }
> 
> ______________________________________________________________________
> // <file>
> //     <copyright see="prj:///doc/copyright.txt"/>
> //     <license see="prj:///doc/license.txt"/>
> //     <owner name="Mike Krger" email="mike@icsharpcode.net"/>
> //     <version value="$version"/>
> // </file>
> 
> using System;
> using System.Diagnostics;
> using System.Collections;
> using System.Reflection;
> //using System.Windows.Forms;
> 
> using ICSharpCode.Core.Properties;
> using ICSharpCode.Core.AddIns.Conditions;
> 
> using ICSharpCode.Core.Services;
> 
> using ICSharpCode.SharpDevelop.Services;
> using ICSharpCode.SharpDevelop.Gui;
> using ICSharpCode.SharpDevelop.Gui.Components;
> using ICSharpCode.SharpDevelop.Commands;
> 
> namespace ICSharpCode.Core.AddIns.Codons
> {
> 	[CodonName("MenuItem")]
> 	public class MenuItemCodon : AbstractCodon
> 	{
> 		[XmlMemberAttribute("label", IsRequired=true)]
> 		string label       = null;
> 		
> 		[XmlMemberAttribute("description")]
> 		string description = null;
> 		
> 		[XmlMemberArrayAttribute("shortcut",Separator='|')]
> 		string[] shortcut    = null;
> 		
> 		[XmlMemberAttribute("icon")]
> 		string icon        = null;
> 		
> 		[XmlMemberAttribute("link")]
> 		string link        = null;
> 		
> 		public string Link {
> 			get {
> 				return link;
> 			}
> 			set {
> 				link = value;
> 			}
> 		}
> 		
> 		public override bool HandleConditions {
> 			get {
> 				return true;
> 			}
> 		}
> 		
> 		public string Label {
> 			get {
> 				return label;
> 			}
> 			set {
> 				label = value;
> 			}
> 		}
> 		
> 		public string Description {
> 			get {
> 				return description;
> 			}
> 			set {
> 				description = value;
> 			}
> 		}
> 		
> 		public string Icon {
> 			get {
> 				return icon;
> 			}
> 			set {
> 				icon = value;
> 			}
> 		}
> 		
> 		public string[] Shortcut {
> 			get {
> 				return shortcut;
> 			}
> 			set {
> 				shortcut = value;
> 			}
> 		}
> 		
> 		/// <summary>
> 		/// Creates an item with the specified sub items. And the current
> 		/// Condition status for this item.
> 		/// </summary>
> 		public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
> 		{
> 			Gtk.MenuItem newItem = null;
> 			if (Label == "-") {
> 				newItem = new SdMenuSeparator(conditions, owner);
> 			} else  if (Link != null) {
> 				newItem = new SdMenuCommand(conditions, null, Label,  Link.StartsWith("http") ? (IMenuCommand)new GotoWebSite(Link) : (IMenuCommand)new GotoLink(Link));
> 			} else {
> 				object o = null;
> 				if (Class != null) {
> 					o = AddIn.CreateObject(Class);
> 				}
> 				if (o != null) {
> 					if (o is IMenuCommand) {
> 						IMenuCommand menuCommand = (IMenuCommand)o;
> 						menuCommand.Owner = owner;
> 						if (o is ICheckableMenuCommand) {
> 							newItem = new SdMenuCheckBox(conditions, owner, Label, (ICheckableMenuCommand)menuCommand);
> 						} else {
> 							newItem = new SdMenuCommand(conditions, owner, Label, menuCommand);
> 						}
> 					} else if (o is ISubmenuBuilder) {
> 						return o;
> 					}
> 				}
> 			}
> 			if (newItem == null) {
> 				SdMenu newMenu = new SdMenu(conditions, owner, Label);
> 				if (subItems != null && subItems.Count > 0) {
> 					foreach (object item in subItems) {
> 						if (item != null) {
> 							newMenu.SubItems.Add(item);
> 						}
> 					}
> 				}
> 				newMenu.UpdateStatus ();
> 				newItem = newMenu;
> 			}
> 			Debug.Assert(newItem != null);
> 			
> 			if (Icon != null && newItem is SdMenuCommand) {
> 				ResourceService resourceService = (ResourceService)ServiceManager.Services.GetService(typeof(IResourceService));
> 				((SdMenuCommand)newItem).Image = resourceService.GetImage(Icon, Gtk.IconSize.Menu);
> 			}
> 			
> 			if (newItem is SdMenuCommand) {
> 				((SdMenuCommand)newItem).Description = description;
> 			}
> 			
> 			if (Shortcut != null && newItem is SdMenuCommand) {
> 				try {
> 					((SdMenuCommand)newItem).SetAccel (shortcut);
> 					//foreach (string key in this.shortcut) {
> 					//	((SdMenuCommand)newItem).Shortcut |= (System.Windows.Forms.Keys)Enum.Parse(typeof(System.Windows.Forms.Keys), key);
> 					//}
> 				} catch (Exception) {
> 					//((SdMenuCommand)newItem).Shortcut = System.Windows.Forms.Keys.None;
> 				}
> 			}
> 			//newItem.IsEnabled = true; //action != ConditionFailedAction.Disable;
> 			return newItem;
> 		}
> 	}
> }