You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by ni...@apache.org on 2006/03/27 16:10:21 UTC

svn commit: r389152 - in /logging/log4net/trunk: src/ src/Core/ src/Util/ tests/ tests/lib/ tests/src/ tests/src/Core/

Author: nicko
Date: Mon Mar 27 06:10:19 2006
New Revision: 389152

URL: http://svn.apache.org/viewcvs?rev=389152&view=rev
Log:
Fix for LOG4NET-72. Moved String.Format call into separate class SystemStringFormat. This class holds the format string and arguments and only performs the String.Format when its ToString method is called.
Added simple test to ensure that the String.Format methods are working correctly and error handling correctly.
Updated the tests project nant.build to copy shared libs into the build output directory.

Added:
    logging/log4net/trunk/src/Util/SystemStringFormat.cs
    logging/log4net/trunk/tests/lib/
    logging/log4net/trunk/tests/lib/prerequisites.txt
    logging/log4net/trunk/tests/src/Core/StringFormatTest.cs
Modified:
    logging/log4net/trunk/src/Core/LogImpl.cs
    logging/log4net/trunk/src/Util/Transform.cs
    logging/log4net/trunk/src/log4net.csproj
    logging/log4net/trunk/tests/nant.build
    logging/log4net/trunk/tests/src/log4net.Tests.csproj

Modified: logging/log4net/trunk/src/Core/LogImpl.cs
URL: http://svn.apache.org/viewcvs/logging/log4net/trunk/src/Core/LogImpl.cs?rev=389152&r1=389151&r2=389152&view=diff
==============================================================================
--- logging/log4net/trunk/src/Core/LogImpl.cs (original)
+++ logging/log4net/trunk/src/Core/LogImpl.cs Mon Mar 27 06:10:19 2006
@@ -216,7 +216,7 @@
 		{
 			if (IsDebugEnabled)
 			{
-				Logger.Log(ThisDeclaringType, m_levelDebug, Transform.StringFormat(CultureInfo.InvariantCulture, format, args), null);
+				Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
 			}
 		}
 
@@ -242,7 +242,7 @@
 		{
 			if (IsDebugEnabled)
 			{
-				Logger.Log(ThisDeclaringType, m_levelDebug, Transform.StringFormat(provider, format, args), null);
+				Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(provider, format, args), null);
 			}
 		}
 
@@ -321,7 +321,7 @@
 		{
 			if (IsInfoEnabled)
 			{
-				Logger.Log(ThisDeclaringType, m_levelInfo, Transform.StringFormat(CultureInfo.InvariantCulture, format, args), null);
+				Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
 			}
 		}
 
@@ -347,7 +347,7 @@
 		{
 			if (IsInfoEnabled)
 			{
-				Logger.Log(ThisDeclaringType, m_levelInfo, Transform.StringFormat(provider, format, args), null);
+				Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(provider, format, args), null);
 			}
 		}
 
@@ -426,7 +426,7 @@
 		{
 			if (IsWarnEnabled)
 			{
-				Logger.Log(ThisDeclaringType, m_levelWarn, Transform.StringFormat(CultureInfo.InvariantCulture, format, args), null);
+				Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
 			}
 		}
 
@@ -452,7 +452,7 @@
 		{
 			if (IsWarnEnabled)
 			{
-				Logger.Log(ThisDeclaringType, m_levelWarn, Transform.StringFormat(provider, format, args), null);
+				Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(provider, format, args), null);
 			}
 		}
 
@@ -531,7 +531,7 @@
 		{
 			if (IsErrorEnabled)
 			{
-				Logger.Log(ThisDeclaringType, m_levelError, Transform.StringFormat(CultureInfo.InvariantCulture, format, args), null);
+				Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
 			}
 		}
 
@@ -557,7 +557,7 @@
 		{
 			if (IsErrorEnabled)
 			{
-				Logger.Log(ThisDeclaringType, m_levelError, Transform.StringFormat(provider, format, args), null);
+				Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(provider, format, args), null);
 			}
 		}
 
@@ -636,7 +636,7 @@
 		{
 			if (IsFatalEnabled)
 			{
-				Logger.Log(ThisDeclaringType, m_levelFatal, Transform.StringFormat(CultureInfo.InvariantCulture, format, args), null);
+				Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
 			}
 		}
 
@@ -662,7 +662,7 @@
 		{
 			if (IsFatalEnabled)
 			{
-				Logger.Log(ThisDeclaringType, m_levelFatal, Transform.StringFormat(provider, format, args), null);
+				Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(provider, format, args), null);
 			}
 		}
 

Added: logging/log4net/trunk/src/Util/SystemStringFormat.cs
URL: http://svn.apache.org/viewcvs/logging/log4net/trunk/src/Util/SystemStringFormat.cs?rev=389152&view=auto
==============================================================================
--- logging/log4net/trunk/src/Util/SystemStringFormat.cs (added)
+++ logging/log4net/trunk/src/Util/SystemStringFormat.cs Mon Mar 27 06:10:19 2006
@@ -0,0 +1,217 @@
+#region Copyright & License
+//
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#endregion
+
+using System;
+using System.Text;
+using System.Xml;
+using System.Text.RegularExpressions;
+
+namespace log4net.Util
+{
+	/// <summary>
+	/// Utility class that represents a format string.
+	/// </summary>
+	/// <remarks>
+	/// <para>
+	/// Utility class that represents a format string.
+	/// </para>
+	/// </remarks>
+	/// <author>Nicko Cadell</author>
+	public sealed class SystemStringFormat
+	{
+		private readonly IFormatProvider m_provider;
+		private readonly string m_format;
+		private readonly object[] m_args;
+
+		#region Constructor
+
+		/// <summary>
+		/// Initialise the <see cref="SystemStringFormat"/>
+		/// </summary>
+		/// <param name="provider">An <see cref="System.IFormatProvider"/> that supplies culture-specific formatting information.</param>
+		/// <param name="format">A <see cref="System.String"/> containing zero or more format items.</param>
+		/// <param name="args">An <see cref="System.Object"/> array containing zero or more objects to format.</param>
+		public SystemStringFormat(IFormatProvider provider, string format, params object[] args)
+		{
+			m_provider = provider;
+			m_format = format;
+			m_args = args;
+		}
+
+		#endregion Constructor
+
+		/// <summary>
+		/// Format the string and arguments
+		/// </summary>
+		/// <returns>the formatted string</returns>
+		public override string ToString()
+		{
+			return StringFormat(m_provider, m_format, m_args);
+		}
+
+		#region StringFormat
+
+		/// <summary>
+		/// Replaces the format item in a specified <see cref="System.String"/> with the text equivalent 
+		/// of the value of a corresponding <see cref="System.Object"/> instance in a specified array.
+		/// A specified parameter supplies culture-specific formatting information.
+		/// </summary>
+		/// <param name="provider">An <see cref="System.IFormatProvider"/> that supplies culture-specific formatting information.</param>
+		/// <param name="format">A <see cref="System.String"/> containing zero or more format items.</param>
+		/// <param name="args">An <see cref="System.Object"/> array containing zero or more objects to format.</param>
+		/// <returns>
+		/// A copy of format in which the format items have been replaced by the <see cref="System.String"/> 
+		/// equivalent of the corresponding instances of <see cref="System.Object"/> in args.
+		/// </returns>
+		/// <remarks>
+		/// <para>
+		/// This method does not throw exceptions. If an exception thrown while formatting the result the
+		/// exception and arguments are returned in the result string.
+		/// </para>
+		/// </remarks>
+		private static string StringFormat(IFormatProvider provider, string format, params object[] args)
+		{
+			try
+			{
+				// The format is missing, log null value
+				if (format == null)
+				{
+					return null;
+				}
+
+				// The args are missing - should not happen unless we are called explicitly with a null array
+				if (args == null)
+				{
+					return format;
+				}
+
+				// Try to format the string
+				return String.Format(provider, format, args);
+			}
+			catch(Exception ex)
+			{
+				log4net.Util.LogLog.Warn("StringFormat: Exception while rendering format ["+format+"]", ex);
+				return StringFormatError(ex, format, args);
+			}
+			catch
+			{
+				log4net.Util.LogLog.Warn("StringFormat: Exception while rendering format ["+format+"]");
+				return StringFormatError(null, format, args);
+			}
+		}
+
+		/// <summary>
+		/// Process an error during StringFormat
+		/// </summary>
+		private static string StringFormatError(Exception formatException, string format, object[] args)
+		{
+			try
+			{
+				StringBuilder buf = new StringBuilder("<log4net.Error>");
+
+				if (formatException != null)
+				{
+					buf.Append("Exception during StringFormat: ").Append(formatException.Message);
+				}
+				else
+				{
+					buf.Append("Exception during StringFormat");
+				}
+				buf.Append(" <format>").Append(format).Append("</format>");
+				buf.Append("<args>");
+				RenderArray(args, buf);
+				buf.Append("</args>");
+				buf.Append("</log4net.Error>");
+
+				return buf.ToString();
+			}
+			catch(Exception ex)
+			{
+				log4net.Util.LogLog.Error("StringFormat: INTERNAL ERROR during StringFormat error handling", ex);
+				return "<log4net.Error>Exception during StringFormat. See Internal Log.</log4net.Error>";
+			}
+			catch
+			{
+				log4net.Util.LogLog.Error("StringFormat: INTERNAL ERROR during StringFormat error handling");
+				return "<log4net.Error>Exception during StringFormat. See Internal Log.</log4net.Error>";
+			}
+		}
+
+		/// <summary>
+		/// Dump the contents of an array into a string builder
+		/// </summary>
+		private static void RenderArray(Array array, StringBuilder buffer)
+		{
+			if (array == null)
+			{
+				buffer.Append(SystemInfo.NullText);
+			}
+			else
+			{
+				if (array.Rank != 1)
+				{
+					buffer.Append(array.ToString());
+				}
+				else
+				{
+					buffer.Append("{");
+					int len = array.Length;
+
+					if (len > 0)
+					{
+						RenderObject(array.GetValue(0), buffer);
+						for (int i = 1; i < len; i++)
+						{
+							buffer.Append(", ");
+							RenderObject(array.GetValue(i), buffer);
+						}
+					}
+					buffer.Append("}");
+				}
+			}
+		}
+
+		/// <summary>
+		/// Dump an object to a string
+		/// </summary>
+		private static void RenderObject(Object obj, StringBuilder buffer)
+		{
+			if (obj == null)
+			{
+				buffer.Append(SystemInfo.NullText);
+			}
+			else
+			{
+				try
+				{
+					buffer.Append(obj);
+				}
+				catch(Exception ex)
+				{
+					buffer.Append("<Exception: ").Append(ex.Message).Append(">");
+				}
+				catch
+				{
+					buffer.Append("<Exception>");
+				}
+			}
+		}
+
+		#endregion StringFormat
+	}
+}

Modified: logging/log4net/trunk/src/Util/Transform.cs
URL: http://svn.apache.org/viewcvs/logging/log4net/trunk/src/Util/Transform.cs?rev=389152&r1=389151&r2=389152&view=diff
==============================================================================
--- logging/log4net/trunk/src/Util/Transform.cs (original)
+++ logging/log4net/trunk/src/Util/Transform.cs Mon Mar 27 06:10:19 2006
@@ -139,156 +139,6 @@
 
 		#endregion XML String Methods
 
-		#region StringFormat
-
-		/// <summary>
-		/// Replaces the format item in a specified <see cref="System.String"/> with the text equivalent 
-		/// of the value of a corresponding <see cref="System.Object"/> instance in a specified array.
-		/// A specified parameter supplies culture-specific formatting information.
-		/// </summary>
-		/// <param name="provider">An <see cref="System.IFormatProvider"/> that supplies culture-specific formatting information.</param>
-		/// <param name="format">A <see cref="System.String"/> containing zero or more format items.</param>
-		/// <param name="args">An <see cref="System.Object"/> array containing zero or more objects to format.</param>
-		/// <returns>
-		/// A copy of format in which the format items have been replaced by the <see cref="System.String"/> 
-		/// equivalent of the corresponding instances of <see cref="System.Object"/> in args.
-		/// </returns>
-		/// <remarks>
-		/// <para>
-		/// This method does not throw exceptions. If an exception thrown while formatting the result the
-		/// exception and arguments are returned in the result string.
-		/// </para>
-		/// </remarks>
-		public static string StringFormat(IFormatProvider provider, string format, params object[] args)
-		{
-			try
-			{
-				// The format is missing, log null value
-				if (format == null)
-				{
-					return null;
-				}
-
-				// The args are missing - should not happen unless we are called explicitly with a null array
-				if (args == null)
-				{
-					return format;
-				}
-
-				// Try to format the string
-				return String.Format(provider, format, args);
-			}
-			catch(Exception ex)
-			{
-				log4net.Util.LogLog.Error("StringFormat: Exception while rendering format ["+format+"]", ex);
-				return StringFormatError(ex, format, args);
-			}
-			catch
-			{
-				log4net.Util.LogLog.Error("StringFormat: Exception while rendering format ["+format+"]");
-				return StringFormatError(null, format, args);
-			}
-		}
-
-		/// <summary>
-		/// Process an error during StringFormat
-		/// </summary>
-		private static string StringFormatError(Exception formatException, string format, object[] args)
-		{
-			try
-			{
-				StringBuilder buf = new StringBuilder("<log4net.Error>");
-
-				if (formatException != null)
-				{
-					buf.Append("Exception during StringFormat: ").Append(formatException.Message);
-				}
-				else
-				{
-					buf.Append("Exception during StringFormat");
-				}
-				buf.Append(" <format>").Append(format).Append("</format>");
-				buf.Append("<args>");
-				RenderArray(args, buf);
-				buf.Append("</args>");
-				buf.Append("</log4net.Error>");
-
-				return buf.ToString();
-			}
-			catch(Exception ex)
-			{
-				log4net.Util.LogLog.Error("StringFormat: INTERNAL ERROR during StringFormat error handling", ex);
-				return "<log4net.Error>Exception during StringFormat. See Internal Log.</log4net.Error>";
-			}
-			catch
-			{
-				log4net.Util.LogLog.Error("StringFormat: INTERNAL ERROR during StringFormat error handling");
-				return "<log4net.Error>Exception during StringFormat. See Internal Log.</log4net.Error>";
-			}
-		}
-
-		/// <summary>
-		/// Dump the contents of an array into a string builder
-		/// </summary>
-		private static void RenderArray(Array array, StringBuilder buffer)
-		{
-			if (array == null)
-			{
-				buffer.Append(SystemInfo.NullText);
-			}
-			else
-			{
-				if (array.Rank != 1)
-				{
-					buffer.Append(array.ToString());
-				}
-				else
-				{
-					buffer.Append("{");
-					int len = array.Length;
-
-					if (len > 0)
-					{
-						RenderObject(array.GetValue(0), buffer);
-						for (int i = 1; i < len; i++)
-						{
-							buffer.Append(", ");
-							RenderObject(array.GetValue(i), buffer);
-						}
-					}
-					buffer.Append("}");
-				}
-			}
-		}
-
-		/// <summary>
-		/// Dump an object to a string
-		/// </summary>
-		private static void RenderObject(Object obj, StringBuilder buffer)
-		{
-			if (obj == null)
-			{
-				buffer.Append(SystemInfo.NullText);
-			}
-			else
-			{
-				try
-				{
-					buffer.Append(obj);
-				}
-				catch(Exception ex)
-				{
-					buffer.Append("<Exception: ").Append(ex.Message).Append(">");
-				}
-				catch
-				{
-					buffer.Append("<Exception>");
-				}
-			}
-		}
-
-		#endregion StringFormat
-		
 		#region Private Helper Methods
 
 		/// <summary>

Modified: logging/log4net/trunk/src/log4net.csproj
URL: http://svn.apache.org/viewcvs/logging/log4net/trunk/src/log4net.csproj?rev=389152&r1=389151&r2=389152&view=diff
==============================================================================
--- logging/log4net/trunk/src/log4net.csproj (original)
+++ logging/log4net/trunk/src/log4net.csproj Mon Mar 27 06:10:19 2006
@@ -948,6 +948,11 @@
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "Util\SystemStringFormat.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "Util\TextWriterAdapter.cs"
                     SubType = "Code"
                     BuildAction = "Compile"

Added: logging/log4net/trunk/tests/lib/prerequisites.txt
URL: http://svn.apache.org/viewcvs/logging/log4net/trunk/tests/lib/prerequisites.txt?rev=389152&view=auto
==============================================================================
--- logging/log4net/trunk/tests/lib/prerequisites.txt (added)
+++ logging/log4net/trunk/tests/lib/prerequisites.txt Mon Mar 27 06:10:19 2006
@@ -0,0 +1,34 @@
+Prerequisites for log4net tests
+===============================
+
+
+The nunit.framework.dll assembly version 2.2.7 is required to build 
+the log4net tests.
+
+The NAnt 0.85 nightly builds since 2006/03/04 have included the
+2.2.7 version of the nunit.framework.dll.
+
+The nunit.framework.dll is available as different builds for each 
+version of the .net runtime. To build multiple versions of the
+log4net tests you will need several different copies of the
+nunit.framework.dll.
+
+The log4net tests are currently built for the following runtimes:
+
+Microsoft .NET Framework 1.0
+Microsoft .NET Framework 1.1
+Microsoft .NET Framework 2.0
+
+Under the tests/lib directory you must create the following directory
+structure containing the nunit.framework.dll assembly built for the
+appropriate version of the runtime:
+
+lib\
+  net\
+    1.0\
+      nunit.framework.dll
+    1.1\
+      nunit.framework.dll
+    2.0\
+      nunit.framework.dll
+    

Modified: logging/log4net/trunk/tests/nant.build
URL: http://svn.apache.org/viewcvs/logging/log4net/trunk/tests/nant.build?rev=389152&r1=389151&r2=389152&view=diff
==============================================================================
--- logging/log4net/trunk/tests/nant.build (original)
+++ logging/log4net/trunk/tests/nant.build Mon Mar 27 06:10:19 2006
@@ -73,9 +73,30 @@
                 <include name="*.*" />
             </fileset>
         </copy>
+        <!-- copy referenced libraries to build output -->
         <copy todir="${current.bin.dir}">
             <fileset basedir="${log4net.basedir}/tests/lib">
-                <include name="nunit.framework.dll" />
+                <include name="/*.dll" />
+            </fileset>
+        </copy>
+        <copy todir="${current.bin.dir}">
+            <fileset basedir="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}">
+                <include name="*.dll" />
+            </fileset>
+        </copy>
+        <copy todir="${current.bin.dir}">
+            <fileset basedir="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}">
+                <include name="*.dll" />
+            </fileset>
+        </copy>
+        <copy todir="${current.bin.dir}">
+            <fileset basedir="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}">
+                <include name="*.dll" />
+            </fileset>
+        </copy>
+        <copy todir="${current.bin.dir}">
+            <fileset basedir="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}">
+                <include name="*.dll" />
             </fileset>
         </copy>
         <csc nostdlib="true" noconfig="true" warnaserror="true" target="library" debug="${current.build.debug}" define="${current.build.defines.csc}" output="${current.bin.dir}/log4net.Tests.dll">
@@ -91,10 +112,11 @@
                 <include name="System.Xml.dll" />
                 <include name="System.Runtime.Remoting.dll" />
                 <include name="${current.bin.dir}/log4net.dll" frompath="false" />
-                <include name="${current.bin.dir}/nunit.framework.dll" frompath="false" />
                 <!-- allow for third party assemblies to be referenced by just storing them in the lib/<framework>/<framework version>/<build configuration> directory -->
-                <include name="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}/*.dll" />
-                <include name="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}/*.dll" />
+                <include name="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}/*.dll" frompath="false" />
+                <include name="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/*.dll" frompath="false" />
+                <include name="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}/*.dll" frompath="false" />
+                <include name="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/*.dll" frompath="false" />
             </references>
         </csc>
     </target>
@@ -107,9 +129,30 @@
                 <include name="*.*" />
             </fileset>
         </copy>
+        <!-- copy referenced libraries to build output -->
         <copy todir="${current.bin.dir}">
             <fileset basedir="${log4net.basedir}/tests/lib">
-                <include name="nunit.framework.dll" />
+                <include name="/*.dll" />
+            </fileset>
+        </copy>
+        <copy todir="${current.bin.dir}">
+            <fileset basedir="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}">
+                <include name="*.dll" />
+            </fileset>
+        </copy>
+        <copy todir="${current.bin.dir}">
+            <fileset basedir="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}">
+                <include name="*.dll" />
+            </fileset>
+        </copy>
+        <copy todir="${current.bin.dir}">
+            <fileset basedir="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}">
+                <include name="*.dll" />
+            </fileset>
+        </copy>
+        <copy todir="${current.bin.dir}">
+            <fileset basedir="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}">
+                <include name="*.dll" />
             </fileset>
         </copy>
         <csc nostdlib="true" noconfig="true" warnaserror="true" target="library" debug="${current.build.debug}" define="${current.build.defines.csc}" output="${current.bin.dir}/log4net.Tests.dll">
@@ -125,10 +168,11 @@
                 <include name="System.Xml.dll" />
                 <include name="System.Runtime.Remoting.dll" />
                 <include name="${current.bin.dir}/log4net.dll" frompath="false" />
-                <include name="${current.bin.dir}/nunit.framework.dll" frompath="false" />
                 <!-- allow for third party assemblies to be referenced by just storing them in the lib/<framework>/<framework version>/<build configuration> directory -->
-                <include name="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}/*.dll" />
-                <include name="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}/*.dll" />
+                <include name="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}/*.dll" frompath="false" />
+                <include name="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/*.dll" frompath="false" />
+                <include name="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}/*.dll" frompath="false" />
+                <include name="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/*.dll" frompath="false" />
             </references>
         </csc>
     </target>
@@ -140,9 +184,30 @@
                 <include name="*.*" />
             </fileset>
         </copy>
+        <!-- copy referenced libraries to build output -->
         <copy todir="${current.bin.dir}">
             <fileset basedir="${log4net.basedir}/tests/lib">
-                <include name="nunit.framework.dll" />
+                <include name="/*.dll" />
+            </fileset>
+        </copy>
+        <copy todir="${current.bin.dir}">
+            <fileset basedir="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}">
+                <include name="*.dll" />
+            </fileset>
+        </copy>
+        <copy todir="${current.bin.dir}">
+            <fileset basedir="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}">
+                <include name="*.dll" />
+            </fileset>
+        </copy>
+        <copy todir="${current.bin.dir}">
+            <fileset basedir="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}">
+                <include name="*.dll" />
+            </fileset>
+        </copy>
+        <copy todir="${current.bin.dir}">
+            <fileset basedir="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}">
+                <include name="*.dll" />
             </fileset>
         </copy>
         <csc nostdlib="true" noconfig="true" warnaserror="true" target="library" debug="${current.build.debug}" define="${current.build.defines.csc}" output="${current.bin.dir}/log4net.Tests.dll">
@@ -158,10 +223,11 @@
                 <include name="System.Xml.dll" />
                 <include name="System.Runtime.Remoting.dll" />
                 <include name="${current.bin.dir}/log4net.dll" frompath="false" />
-                <include name="${current.bin.dir}/nunit.framework.dll" frompath="false" />
                 <!-- allow for third party assemblies to be referenced by just storing them in the lib/<framework>/<framework version>/<build configuration> directory -->
-                <include name="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}/*.dll" />
-                <include name="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}/*.dll" />
+                <include name="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}/*.dll" frompath="false" />
+                <include name="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/*.dll" frompath="false" />
+                <include name="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}/*.dll" frompath="false" />
+                <include name="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/*.dll" frompath="false" />
             </references>
         </csc>
     </target>

Added: logging/log4net/trunk/tests/src/Core/StringFormatTest.cs
URL: http://svn.apache.org/viewcvs/logging/log4net/trunk/tests/src/Core/StringFormatTest.cs?rev=389152&view=auto
==============================================================================
--- logging/log4net/trunk/tests/src/Core/StringFormatTest.cs (added)
+++ logging/log4net/trunk/tests/src/Core/StringFormatTest.cs Mon Mar 27 06:10:19 2006
@@ -0,0 +1,95 @@
+#region Copyright & License
+//
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#endregion
+
+using System;
+using System.IO;
+
+using log4net.Config;
+using log4net.Layout;
+using log4net.Core;
+using log4net.Repository;
+using log4net.Tests.Appender;
+using log4net.Util;
+using NUnit.Framework;
+
+namespace log4net.Tests.Core
+{
+	/// <summary>
+	/// Used for internal unit testing the <see cref="PatternLayoutTest"/> class.
+	/// </summary>
+	/// <remarks>
+	/// Used for internal unit testing the <see cref="PatternLayoutTest"/> class.
+	/// </remarks>
+	[TestFixture] public class StringFormatTest
+	{
+		[Test] public void TestThreadPropertiesPattern()
+		{
+			StringAppender stringAppender = new StringAppender();
+			stringAppender.Layout = new PatternLayout("%message");
+
+			ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
+			BasicConfigurator.Configure(rep, stringAppender);
+
+			ILog log1 = LogManager.GetLogger(rep.Name, "TestThreadProperiesPattern");
+
+			// ***
+			log1.Info("TestMessage");
+			Assert.AreEqual("TestMessage", stringAppender.GetString(), "Test simple INFO event");
+			stringAppender.Reset();
+
+
+			// ***
+			log1.DebugFormat("Before {0} After", "Middle");
+			Assert.AreEqual("Before Middle After", stringAppender.GetString(), "Test simple formatted DEBUG event");
+			stringAppender.Reset();
+
+			// ***
+			log1.InfoFormat("Before {0} After", "Middle");
+			Assert.AreEqual("Before Middle After", stringAppender.GetString(), "Test simple formatted INFO event");
+			stringAppender.Reset();
+
+			// ***
+			log1.WarnFormat("Before {0} After", "Middle");
+			Assert.AreEqual("Before Middle After", stringAppender.GetString(), "Test simple formatted WARN event");
+			stringAppender.Reset();
+
+			// ***
+			log1.ErrorFormat("Before {0} After", "Middle");
+			Assert.AreEqual("Before Middle After", stringAppender.GetString(), "Test simple formatted ERROR event");
+			stringAppender.Reset();
+
+			// ***
+			log1.FatalFormat("Before {0} After", "Middle");
+			Assert.AreEqual("Before Middle After", stringAppender.GetString(), "Test simple formatted FATAL event");
+			stringAppender.Reset();
+
+
+			// ***
+			log1.InfoFormat("Before {0} After {1}", "Middle", "End");
+			Assert.AreEqual("Before Middle After End", stringAppender.GetString(), "Test simple formatted INFO event 2");
+			stringAppender.Reset();
+
+			// ***
+			log1.InfoFormat("Before {0} After {1} {2}", "Middle", "End");
+			Assert.AreEqual(STRING_FORMAT_ERROR, stringAppender.GetString(), "Test formatting error");
+			stringAppender.Reset();
+		}
+
+		private const string STRING_FORMAT_ERROR = "<log4net.Error>Exception during StringFormat: Index (zero based) must be greater than or equal to zero and less than the size of the argument list. <format>Before {0} After {1} {2}</format><args>{Middle, End}</args></log4net.Error>";
+	}
+}

Modified: logging/log4net/trunk/tests/src/log4net.Tests.csproj
URL: http://svn.apache.org/viewcvs/logging/log4net/trunk/tests/src/log4net.Tests.csproj?rev=389152&r1=389151&r2=389152&view=diff
==============================================================================
--- logging/log4net/trunk/tests/src/log4net.Tests.csproj (original)
+++ logging/log4net/trunk/tests/src/log4net.Tests.csproj Mon Mar 27 06:10:19 2006
@@ -73,11 +73,6 @@
                     HintPath = "..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.XML.dll"
                 />
                 <Reference
-                    Name = "nunit.framework"
-                    AssemblyName = "nunit.framework"
-                    HintPath = "..\lib\nunit.framework.dll"
-                />
-                <Reference
                     Name = "log4net"
                     Project = "{F6A02431-167E-4347-BC43-65532C31CDB7}"
                     Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
@@ -87,6 +82,11 @@
                     AssemblyName = "System.Runtime.Remoting"
                     HintPath = "..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.0.3705\System.Runtime.Remoting.dll"
                 />
+                <Reference
+                    Name = "nunit.framework"
+                    AssemblyName = "nunit.framework"
+                    HintPath = "..\lib\net\1.0\nunit.framework.dll"
+                />
             </References>
         </Build>
         <Files>
@@ -149,6 +149,11 @@
                 />
                 <File
                     RelPath = "Core\ShutdownTest.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "Core\StringFormatTest.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
                 />