Title: Bug: string format called with too few arguments

In RC3, nant-0.85-rc3\rc\NAnt.Core\Element.cs line 921 there is a call to string format:

// make sure the element is strongly typed

if (elementType == null || !typeof(Element).IsAssignableFrom(elementType)) {

    throw new BuildException(string.Format(CultureInfo.InvariantCulture,

                    ResourceUtils.GetString("NA1140"), Name),

                    Location);

}

This string.Format() call only passes one additional parameter (Name). When you look in the resource file, the format string is expecting 2 parameters.

    <!--Messages From: \NAnt.Core/Tasks/NAntSchemaTask.cs-->

    <data name="NA1140">

        <value>BuildElementArrayAttribute and BuildElementCollectionAttribute should have an element type assigned that derives from Element for {0}.{1}.</value>

        <comment>BuildElementArrayAttribute and BuildElementCollectionAttribute</comment>

    </data>


The resource NA1140 is used in two locations. Once in Element.cs (line 921) and once in NAntSchemaTask.cs (line 559). Im guessing someone changed the message for NAntSchemaTask and didnt realize it was being used elsewhere.

This results in the following exception:

System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

   at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args)

   at System.String.Format(IFormatProvider provider, String format, Object[] args)

   at NAnt.Core.AttributeConfigurator.InitializeBuildElementCollection(PropertyInfo propertyInfo) in c:\Don\Download\nant-0.85-rc3-src\nant-0.85-rc3\

rc\NAnt.Core\Element.cs:line 921

   at NAnt.Core.AttributeConfigurator.Initialize() in c:\Don\Download\nant-0.85-rc3-src\nant-0.85-rc3\src\NAnt.Core\Element.cs:line 645

   at NAnt.Core.Element.InitializeXml(XmlNode elementNode, PropertyDictionary properties, FrameworkInfo framework) in c:\Don\Download\nant-0.85-rc3-s

c\nant-0.85-rc3\src\NAnt.Core\Element.cs:line 310

   at NAnt.Core.Element.Initialize(XmlNode elementNode, PropertyDictionary properties, FrameworkInfo framework) in c:\Don\Download\nant-0.85-rc3-src\

ant-0.85-rc3\src\NAnt.Core\Element.cs:line 292

   at NAnt.Core.Element.Initialize(XmlNode elementNode) in c:\Don\Download\nant-0.85-rc3-src\nant-0.85-rc3\src\NAnt.Core\Element.cs:line 215

   at NAnt.Core.Project.CreateTask(XmlNode taskNode, Target target) in c:\Don\Download\nant-0.85-rc3-src\nant-0.85-rc3\src\NAnt.Core\Project.cs:line

024

   at NAnt.Core.Target.Execute() in c:\Don\Download\nant-0.85-rc3-src\nant-0.85-rc3\src\NAnt.Core\Target.cs:line 245

   at NAnt.Core.Project.Execute(String targetName, Boolean forceDependencies) in c:\Don\Download\nant-0.85-rc3-src\nant-0.85-rc3\src\NAnt.Core\Projec

.cs:line 887

   at NAnt.Core.Project.Execute() in c:\Don\Download\nant-0.85-rc3-src\nant-0.85-rc3\src\NAnt.Core\Project.cs:line 839

   at NAnt.Core.Project.Run() in c:\Don\Download\nant-0.85-rc3-src\nant-0.85-rc3\src\NAnt.Core\Project.cs:line 924

Please send bug report to [EMAIL PROTECTED]

==============================================================================
This communication, together with any attachments hereto or links contained herein, is for the sole use of the intended recipient(s) and may contain information that is confidential or legally protected. If you are not the intended recipient, you are hereby notified that any review, disclosure, copying, dissemination, distribution or use of this communication is STRICTLY PROHIBITED. If you have received this communication in error, please notify the sender immediately by return e-mail message and delete the original and all copies of the communication, along with any attachments hereto or links herein, from your system.

==============================================================================
The St. Paul Travelers e-mail system made this annotation on 07/05/2005, 09:39:09 AM.

Reply via email to