From 3795a773540442b54071f66ac6423f777594dd00 Mon Sep 17 00:00:00 2001 From: Travis Parks Date: Thu, 18 Jul 2013 12:04:12 -0400 Subject: [PATCH] Give more details for unknown tags --- mustache-sharp.test/FormatCompilerTester.cs | 15 + .../Properties/AssemblyInfo.cs | 4 +- mustache-sharp/FormatCompiler.cs | 4 +- mustache-sharp/Properties/AssemblyInfo.cs | 4 +- .../Properties/Resources.Designer.cs | 4 +- mustache-sharp/Properties/Resources.resx | 286 +++++++++--------- 6 files changed, 167 insertions(+), 150 deletions(-) diff --git a/mustache-sharp.test/FormatCompilerTester.cs b/mustache-sharp.test/FormatCompilerTester.cs index f3c3b13..30cec2a 100644 --- a/mustache-sharp.test/FormatCompilerTester.cs +++ b/mustache-sharp.test/FormatCompilerTester.cs @@ -1096,5 +1096,20 @@ Your order total was: $7.50"; } #endregion + + #region Unknown Tags + + /// + /// If an unknown tag is encountered, an exception should be thrown. + /// + [TestMethod] + [ExpectedException(typeof(FormatException))] + public void TestCompile_UnknownTag() + { + FormatCompiler compiler = new FormatCompiler(); + compiler.Compile("{{#split Names}}"); + } + + #endregion } } diff --git a/mustache-sharp.test/Properties/AssemblyInfo.cs b/mustache-sharp.test/Properties/AssemblyInfo.cs index ca24713..0fdb5f2 100644 --- a/mustache-sharp.test/Properties/AssemblyInfo.cs +++ b/mustache-sharp.test/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("0.1.0.0")] -[assembly: AssemblyFileVersion("0.1.0.0")] +[assembly: AssemblyVersion("0.1.1.0")] +[assembly: AssemblyFileVersion("0.1.1.0")] diff --git a/mustache-sharp/FormatCompiler.cs b/mustache-sharp/FormatCompiler.cs index 1f211d2..040e738 100644 --- a/mustache-sharp/FormatCompiler.cs +++ b/mustache-sharp/FormatCompiler.cs @@ -260,7 +260,9 @@ namespace Mustache } else if (match.Groups["unknown"].Success) { - throw new FormatException(Resources.UnknownTag); + string tagName = match.Value; + string message = String.Format(Resources.UnknownTag, tagName); + throw new FormatException(message); } } return formatIndex; diff --git a/mustache-sharp/Properties/AssemblyInfo.cs b/mustache-sharp/Properties/AssemblyInfo.cs index ce96e76..f37dd73 100644 --- a/mustache-sharp/Properties/AssemblyInfo.cs +++ b/mustache-sharp/Properties/AssemblyInfo.cs @@ -34,6 +34,6 @@ using System.Runtime.CompilerServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.1.0.0")] -[assembly: AssemblyFileVersion("0.1.0.0")] +[assembly: AssemblyVersion("0.1.1.0")] +[assembly: AssemblyFileVersion("0.1.1.0")] [assembly: InternalsVisibleTo("mustache-sharp.test")] \ No newline at end of file diff --git a/mustache-sharp/Properties/Resources.Designer.cs b/mustache-sharp/Properties/Resources.Designer.cs index 3257d4e..3d33190 100644 --- a/mustache-sharp/Properties/Resources.Designer.cs +++ b/mustache-sharp/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.296 +// Runtime Version:4.0.30319.18052 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -115,7 +115,7 @@ namespace Mustache.Properties { } /// - /// Looks up a localized string similar to Encountered an unknown tag. It was either not registered or exists in a different context.. + /// Looks up a localized string similar to Encountered an unknown tag: {0}. It was either not registered or exists in a different context.. /// internal static string UnknownTag { get { diff --git a/mustache-sharp/Properties/Resources.resx b/mustache-sharp/Properties/Resources.resx index b428e3c..7756f43 100644 --- a/mustache-sharp/Properties/Resources.resx +++ b/mustache-sharp/Properties/Resources.resx @@ -1,144 +1,144 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - An attempt was made to define a parameter with a null or an invalid identifier. - - - An attempt was made to define a tag with a null or an invalid identifier. - - - A parameter with the same name already exists within the tag. - - - The {0} tag has already been registered. - - - The key {0} could not be found. - - - Expected a matching {0} tag but none was found. - - - Encountered an unknown tag. It was either not registered or exists in a different context. - - - The wrong number of arguments were passed to an {0} tag. - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + An attempt was made to define a parameter with a null or an invalid identifier. + + + An attempt was made to define a tag with a null or an invalid identifier. + + + A parameter with the same name already exists within the tag. + + + The {0} tag has already been registered. + + + The key {0} could not be found. + + + Expected a matching {0} tag but none was found. + + + Encountered an unknown tag: {0}. It was either not registered or exists in a different context. + + + The wrong number of arguments were passed to an {0} tag. + \ No newline at end of file