public void SerializeDeserialize()
        {
            InvalidProjectFileException e = new InvalidProjectFileException(
                "projectFile", 
                1, 2, 3, 4,
                "message",
                "errorSubcategory",
                "errorCode", 
                "helpKeyword");

            using (MemoryStream memstr = new MemoryStream())
            {
                BinaryFormatter frm = new BinaryFormatter();

                frm.Serialize(memstr, e);
                memstr.Position = 0;

                InvalidProjectFileException e2 = (InvalidProjectFileException)frm.Deserialize(memstr);

                Assertion.AssertEquals(e.ColumnNumber, e2.ColumnNumber);
                Assertion.AssertEquals(e.EndColumnNumber, e2.EndColumnNumber);
                Assertion.AssertEquals(e.EndLineNumber, e2.EndLineNumber);
                Assertion.AssertEquals(e.ErrorCode, e2.ErrorCode);
                Assertion.AssertEquals(e.ErrorSubcategory, e2.ErrorSubcategory);
                Assertion.AssertEquals(e.HasBeenLogged, e2.HasBeenLogged);
                Assertion.AssertEquals(e.HelpKeyword, e2.HelpKeyword);
                Assertion.AssertEquals(e.LineNumber, e2.LineNumber);
                Assertion.AssertEquals(e.Message, e2.Message);
                Assertion.AssertEquals(e.ProjectFile, e2.ProjectFile);
            }
        }
		public void TestCtorProjectFile ()
		{
			InvalidProjectFileException ipfe;
			string projectFile = "projectFile";
			int lineNumber = 1;
			int columnNumber = 2;
			int endLineNumber = 3;
			int endColumnNumber = 4;
			string message = "message";
			string errorSubcategory = "errorSubcategory";
			string errorCode = "CS0000";
			string helpKeyword = "helpKeyword";
			
			ipfe = new InvalidProjectFileException (projectFile, lineNumber, columnNumber, endLineNumber, endColumnNumber,
				message, errorSubcategory, errorCode, helpKeyword);
			
			Assert.AreEqual (projectFile, ipfe.ProjectFile, "A1");
			Assert.AreEqual (lineNumber, ipfe.LineNumber, "A2");
			Assert.AreEqual (columnNumber, ipfe.ColumnNumber, "A3");
			Assert.AreEqual (endLineNumber, ipfe.EndLineNumber, "A4");
			Assert.AreEqual (endColumnNumber, ipfe.EndColumnNumber, "A5");
			Assert.AreEqual (message, ipfe.BaseMessage, "A6");
			Assert.AreEqual (message + "  " + projectFile, ipfe.Message, "A7");
			Assert.AreEqual (errorSubcategory, ipfe.ErrorSubcategory, "A8");
			Assert.AreEqual (errorCode, ipfe.ErrorCode, "A9");
			Assert.AreEqual (helpKeyword, ipfe.HelpKeyword, "A10");
		}
 public void CtorMessageArity1()
 {
     InvalidProjectFileException invalidProjectFileException = new InvalidProjectFileException("Message");
     Assertion.AssertEquals("Message", invalidProjectFileException.Message);
     Assertion.AssertEquals(0, invalidProjectFileException.LineNumber);
     Assertion.AssertEquals(0, invalidProjectFileException.ColumnNumber);
 }
 public void Ctor_Arity2InnerException()
 {
     InvalidProjectFileException invalidProjectFileException = new InvalidProjectFileException("Message", new Exception("MessageInner"));
     Assertion.AssertEquals("Message", invalidProjectFileException.Message);
     Assertion.AssertEquals("MessageInner", invalidProjectFileException.InnerException.Message);
     Assertion.AssertEquals(0, invalidProjectFileException.LineNumber);
     Assertion.AssertEquals(0, invalidProjectFileException.ColumnNumber);
 }
		public void TestCtorMessage ()
		{
			InvalidProjectFileException ipfe;
			string message = "message";
			
			ipfe = new InvalidProjectFileException (message);
			
			Assert.AreEqual (message, ipfe.Message, "Message");
		}
 public void SerializationBinaryInnerException()
 {
     MemoryStream memoryStream = null;
     InvalidProjectFileException invalidProjectFileException =
         new InvalidProjectFileException("Message", new Exception("innerException"));
     try
     {
         memoryStream = new MemoryStream();
         IFormatter binaryForamtter = new BinaryFormatter();
         binaryForamtter.Serialize(memoryStream, invalidProjectFileException);
         memoryStream.Position = 0; // reset pointer into stream for read
         Object returnObj = binaryForamtter.Deserialize(memoryStream);
         Assertion.Assert(returnObj is InvalidProjectFileException);
         InvalidProjectFileException outException = ((InvalidProjectFileException)returnObj);
         Assertion.AssertEquals("Message", outException.Message);
         Assertion.AssertEquals("innerException", outException.InnerException.Message);
     }
     finally
     {
         memoryStream.Close();
     }
 }
 public void SerializationBinary()
 {
     string message = "Message";
     string projectFile = @"c:\ProjectFile";
     MemoryStream memoryStream = null;
     InvalidProjectFileException invalidProjectFileException =
         new InvalidProjectFileException(projectFile, 1, 2, 3, 4, message, "errorSubCategory", "errorCode", "HelpKeyword");
     
     try
     {
         memoryStream = new MemoryStream();
         IFormatter binaryForamtter = new BinaryFormatter();
         binaryForamtter.Serialize(memoryStream, invalidProjectFileException);
         memoryStream.Position = 0; // reset pointer into stream for read
         Object returnObj = binaryForamtter.Deserialize(memoryStream);
         Assertion.Assert(returnObj is InvalidProjectFileException);
         InvalidProjectFileException outException = ((InvalidProjectFileException)returnObj);
         Assertion.AssertEquals(message + "  " + projectFile, outException.Message);
         Assertion.AssertEquals("errorSubCategory", outException.ErrorSubcategory);
         Assertion.AssertEquals("errorCode", outException.ErrorCode);
         Assertion.AssertEquals("HelpKeyword", outException.HelpKeyword);
         Assertion.AssertEquals(1, outException.LineNumber);
         Assertion.AssertEquals(2, outException.ColumnNumber);
         Assertion.AssertEquals(3, outException.EndLineNumber);
         Assertion.AssertEquals(4, outException.EndColumnNumber);
         Assertion.AssertEquals(projectFile, outException.ProjectFile);
     }
     finally
     {
         memoryStream.Close();
     }
 }
 public void SerializationXML()
 {
     InvalidProjectFileException toolSetException = new InvalidProjectFileException("Message", new Exception("innerException"));
     MemoryStream memoryStream = null;
     try
     {
         memoryStream = new MemoryStream();
         XmlSerializer xs = new XmlSerializer(typeof(InvalidProjectFileException));
         XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
         xs.Serialize(xmlTextWriter, toolSetException);
         memoryStream = (MemoryStream)xmlTextWriter.BaseStream;
     }
     finally
     {
         memoryStream.Close();
     }
 }
 public void BaseMessage()
 {
     string message = "Message";
     InvalidProjectFileException invalidProjectFileException =
         new InvalidProjectFileException("ProjectFile", 0, 0, 0, 0, message, "errorSubCategory", "errorCode", "HelpKeyword");
     Assertion.AssertEquals(message, invalidProjectFileException.BaseMessage);
 }
		public void TestGetObjectData2 ()
		{
			StreamingContext sc = new StreamingContext ();
			SerializationInfo si = new SerializationInfo (typeof (InvalidProjectFileException), new FormatterConverter ());
			InvalidProjectFileException ipfe;
			string projectFile = "projectFile";
			int lineNumber = 1;
			int columnNumber = 2;
			int endLineNumber = 3;
			int endColumnNumber = 4;
			string message = "message";
			string errorSubcategory = "errorSubcategory";
			string errorCode = "CS0000";
			string helpKeyword = "helpKeyword";

			ipfe = new InvalidProjectFileException (projectFile, lineNumber, columnNumber, endLineNumber, endColumnNumber,
				message, errorSubcategory, errorCode, helpKeyword);
			ipfe.GetObjectData (si, sc);

			Assert.AreEqual (projectFile, si.GetString ("projectFile"), "A1");
			Assert.AreEqual (lineNumber, si.GetInt32 ("lineNumber"), "A2");
			Assert.AreEqual (columnNumber, si.GetInt32 ("columnNumber"), "A3");
			Assert.AreEqual (endLineNumber, si.GetInt32 ("endLineNumber"), "A4");
			Assert.AreEqual (endColumnNumber, si.GetInt32 ("endColumnNumber"), "A5");
			Assert.AreEqual (message, si.GetString ("Message"), "A6");
			Assert.AreEqual (errorSubcategory, si.GetString ("errorSubcategory"), "A7");
			Assert.AreEqual (errorCode, si.GetString ("errorCode"), "A8");
			Assert.AreEqual (helpKeyword, si.GetString ("helpKeyword"), "A9");
		}
 public void CtorMessageArity1_null()
 {
     string nullString = null; // typed null as to hit correct ctor overloaded.
     InvalidProjectFileException invalidProjectFileException = new InvalidProjectFileException(nullString);
     InvalidProjectFileException invalidProjectFileException2 = new InvalidProjectFileException(nullString, new Exception("MessageInner"));
 }
 public void CtorArity4_NullMessageString()
 {
     string message = null;
     InvalidProjectFileException invalidProjectFileException =
             new InvalidProjectFileException(new XmlDocument().CreateElement("name"), message, "subcategory", "ErrorCode", "HelpKeyword");
     Assertion.AssertEquals(String.Empty, invalidProjectFileException.ProjectFile);
     Assertion.AssertEquals(message, invalidProjectFileException.Message);
     Assertion.AssertNull(invalidProjectFileException.ErrorSubcategory);
     Assertion.AssertEquals("ErrorCode", invalidProjectFileException.ErrorCode);
     Assertion.AssertEquals("HelpKeyword", invalidProjectFileException.HelpKeyword);
     Assertion.AssertEquals(0, invalidProjectFileException.LineNumber);
     Assertion.AssertEquals(0, invalidProjectFileException.ColumnNumber);
 }
Esempio n. 13
0
        /// <summary>
        /// Logs an error regarding an invalid project file with all registered loggers.
        /// </summary>
        /// <owner>SumedhK</owner>
        /// <param name="invalidProjectFileException"></param>
        virtual internal void LogInvalidProjectFileError(BuildEventContext buildEventContext, InvalidProjectFileException invalidProjectFileException)
        {
            ErrorUtilities.VerifyThrow(invalidProjectFileException != null, "Need exception context.");

            // Don't log the exception more than once.
            if (!invalidProjectFileException.HasBeenLogged)
            {
                BuildErrorEventArgs e =
                    new BuildErrorEventArgs
                    (
                        invalidProjectFileException.ErrorSubcategory,
                        invalidProjectFileException.ErrorCode,
                        invalidProjectFileException.ProjectFile,
                        invalidProjectFileException.LineNumber,
                        invalidProjectFileException.ColumnNumber,
                        invalidProjectFileException.EndLineNumber,
                        invalidProjectFileException.EndColumnNumber,
                        invalidProjectFileException.BaseMessage,
                        invalidProjectFileException.HelpKeyword,
                        "MSBuild"
                    );
                e.BuildEventContext = buildEventContext;
                PostLoggingEvent(e);

                invalidProjectFileException.HasBeenLogged = true;
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Logs an error regarding an invalid project file with all registered loggers.
        /// </summary>
        /// <owner>SumedhK</owner>
        /// <param name="invalidProjectFileException"></param>
        virtual internal void LogInvalidProjectFileError(BuildEventContext buildEventContext, InvalidProjectFileException invalidProjectFileException)
        {
            ErrorUtilities.VerifyThrow(invalidProjectFileException != null, "Need exception context.");

            // Don't log the exception more than once.
            if (!invalidProjectFileException.HasBeenLogged)
            {
                BuildErrorEventArgs e =
                    new BuildErrorEventArgs
                    (
                        invalidProjectFileException.ErrorSubcategory,
                        invalidProjectFileException.ErrorCode,
                        invalidProjectFileException.ProjectFile,
                        invalidProjectFileException.LineNumber,
                        invalidProjectFileException.ColumnNumber,
                        invalidProjectFileException.EndLineNumber,
                        invalidProjectFileException.EndColumnNumber,
                        invalidProjectFileException.BaseMessage,
                        invalidProjectFileException.HelpKeyword,
                        "MSBuild"
                    );
                e.BuildEventContext = buildEventContext;
                PostLoggingEvent(e);

                invalidProjectFileException.HasBeenLogged = true;
            }
        }
 public void CtorDefault()
 {
     InvalidProjectFileException invalidProjectFileException = new InvalidProjectFileException();
 }
 public void CtorArity4_EmptyMessageString()
 {
     string message = String.Empty;
     InvalidProjectFileException invalidProjectFileException =
             new InvalidProjectFileException(new XmlDocument().CreateElement("Name"), message, String.Empty, String.Empty, String.Empty);
 }
        public void CtorArity4_NullStringOtherParams()
        {
            string message = "Message";
            InvalidProjectFileException invalidProjectFileException =
                new InvalidProjectFileException(new XmlDocument().CreateElement("Name"), message, null, null, null);
            Assertion.AssertEquals(String.Empty, invalidProjectFileException.ProjectFile);

            // preserve a bug in Orcas SP1:  if projectFile is empty but non-null, extra spaces get added to the message.
            Assertion.AssertEquals(message + "  ", invalidProjectFileException.Message);
            Assertion.AssertEquals(null, invalidProjectFileException.ErrorSubcategory);
            Assertion.AssertEquals(null, invalidProjectFileException.ErrorCode);
            Assertion.AssertEquals(null, invalidProjectFileException.HelpKeyword);
        }
 public void CtorMessageArity1_empty()
 {
     InvalidProjectFileException invalidProjectFileException = new InvalidProjectFileException(String.Empty);
     InvalidProjectFileException invalidProjectFileException2 = new InvalidProjectFileException(String.Empty, new Exception("MessageInner"));
 }
 public void CtorArity9NegativeInts()
 {
     string message = "Message";
     string projectFile = @"c:\ProjectFile";
     InvalidProjectFileException invalidProjectFileException =
         new InvalidProjectFileException(projectFile, -1, -10, -11, -12, message, "errorSubCategory", "errorCode", "HelpKeyword");
     Assertion.AssertEquals(message + "  " + projectFile, invalidProjectFileException.Message);
     Assertion.AssertEquals("errorSubCategory", invalidProjectFileException.ErrorSubcategory);
     Assertion.AssertEquals("errorCode", invalidProjectFileException.ErrorCode);
     Assertion.AssertEquals("HelpKeyword", invalidProjectFileException.HelpKeyword);
     Assertion.AssertEquals(-1, invalidProjectFileException.LineNumber);
     Assertion.AssertEquals(-10, invalidProjectFileException.ColumnNumber);
     Assertion.AssertEquals(-11, invalidProjectFileException.EndLineNumber);
     Assertion.AssertEquals(-12, invalidProjectFileException.EndColumnNumber);
     Assertion.AssertEquals(projectFile, invalidProjectFileException.ProjectFile);
 }
        public void CtorArity4()
        {
            string message = "Message";
            InvalidProjectFileException invalidProjectFileException =
                    new InvalidProjectFileException(new XmlDocument().CreateElement("name"), message, "errorSubCategory", "errorCode", "HelpKeyword");
            Assertion.AssertEquals(String.Empty, invalidProjectFileException.ProjectFile);

            // preserve a bug in Orcas SP1:  if projectFile is empty but non-null, extra spaces get added to the message.
            Assertion.AssertEquals(message + "  ", invalidProjectFileException.Message);
            Assertion.AssertEquals("errorSubCategory", invalidProjectFileException.ErrorSubcategory);
            Assertion.AssertEquals("errorCode", invalidProjectFileException.ErrorCode);
            Assertion.AssertEquals("HelpKeyword", invalidProjectFileException.HelpKeyword);
            Assertion.AssertEquals(0, invalidProjectFileException.LineNumber);
            Assertion.AssertEquals(0, invalidProjectFileException.ColumnNumber);
        }
		public void TestGetObjectData1 ()
		{
			InvalidProjectFileException ipfe = new InvalidProjectFileException ();
			ipfe.GetObjectData (null, new StreamingContext ());
		}