[Mono-bugs] [Bug 339012] New: System.IO.Ports.SerialPort. NewLine can be set to an empty string.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Nov 4 21:11:34 EST 2007


           Summary: System.IO.Ports.SerialPort.NewLine can be set to an
                    empty string.
           Product: Mono: Class Libraries
           Version: 1.2
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at ximian.com
        ReportedBy: michaelmattess at rauland.com.au
         QAContact: mono-bugs at ximian.com
          Found By: ---

The System.IO.Ports.SerialPort.NewLine can be set to an empty string where as
in .Net an ArgumentException is thrown.  Below is a little test case.

To fix this add this test to the NewLine setter:
if (value == ""){
    throw new ArgumentException("Argument NewLine cannot be null or

using System;
using System.Collections.Generic;
using System.Text;
using System.IO.Ports;

namespace portNewLineTest{
    class Program{
        static void Main(string[] args){

            SerialPort port = new SerialPort();

                port.NewLine = "";
            catch (Exception e){
                // .Net thows an exception...
                Console.WriteLine("Got exception:" + e.Message);

            // Mono does not...
            Console.WriteLine("Got no exception, NewLine is now'" +
port.NewLine + "'");


Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the mono-bugs mailing list