Bug 23318 - XComment throws an exception with some inputs
Summary: XComment throws an exception with some inputs
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.XML ()
Version: unspecified
Hardware: PC Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Atsushi Eno
URL:
Depends on:
Blocks:
 
Reported: 2014-09-23 23:29 UTC by Miguel de Icaza [MSFT]
Modified: 2014-11-28 11:56 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Miguel de Icaza [MSFT] 2014-09-23 23:29:21 UTC
The following code throws an exception on Mono, but works on .NET:

var x = new XComment("<--foo-->");
Console.WriteLine(x);

Exception in Mono:
System.ArgumentException: An XML comment cannot end with "-".
  at System.Xml.XmlTextWriter.WriteComment (System.String text) [0x00000] in <filename unknown>:0 
  at System.Xml.DefaultXmlWriter.WriteComment (System.String text) [0x00000] in <filename unknown>:0 
  at System.Xml.Linq.XComment.WriteTo (System.Xml.XmlWriter writer) [0x00000] in <filename unknown>:0 
  at System.Xml.Linq.XNode.ToString (SaveOptions options) [0x00000] in <filename unknown>:0 
  at System.Xml.Linq.XNode.ToString () [0x00000] in <filename unknown>:0 
  at <InteractiveExpressionClass>.Host (System.Object& $retval) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Evaluator.Evaluate (System.String input, System.Object& result, System.Boolean& result_set) [0x00000] in <filename unknown>:0 
  at Mono.CSharpShell.Evaluate (System.String input) [0x00000] in <filename unknown>:0 

Result in .NET:
<!--<- -foo- ->-->
Comment 1 Atsushi Eno 2014-09-24 03:32:39 UTC
Fixed. It was an interesting bug, happened only in ToString() but not in Value.

[master db5275c]
Comment 2 Sunil Kumar 2014-11-28 11:56:15 UTC
I have checked this issue and now it's working fine. I have run the code mentioned in bug description and now it gives the correct result.

Result: <!--<- -foo- ->-->

Screencast: http://www.screencast.com/t/MoBYE00n

Hence, I am closing this issue.

Environment info: 
=== Xamarin Studio ===

Version 5.7 (build 596)
Installation UUID: 561c7a69-0a91-4bae-ad7c-f0c79d594337
Runtime:
	Mono 3.12.0 ((detached/b75fa2b)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000046

=== Apple Developer Tools ===

Xcode 5.1.1 (5085)
Build 5B1008

=== Xamarin.iOS ===

Version: 8.6.0.5 (Trial Edition)
Hash: 880cc21
Branch: 
Build date: 2014-11-25 12:12:17-0500

=== Xamarin.Android ===

Version: 5.0.0.0 (Trial Edition)
Android SDK: /Users/tajinder/Desktop/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Xamarin.Mac ===

Version: 1.11.1.201 (Indie Edition)

=== Build Information ===

Release ID: 507000596
Git revision: d996e9ba6874a0d64241e43e5e6b06322ce29c84
Build date: 2014-11-25 17:17:54-05
Xamarin addins: 8ca19707b41536a391f53364ee4ff9272711feb0

=== Operating System ===

Mac OS X 10.8.4
Darwin Tajinders-iMac.local 12.4.2 Darwin Kernel Version 12.4.2
    Mon Jun 17 18:00:12 PDT 2013
    root:xnu-2050.45.8~1/RELEASE_X86_64 x86_64