[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


https://bugzilla.novell.com/show_bug.cgi?id=339012

           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
zero-length.");
}

--------------------------------------------------------------------
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();

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

            // 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