Migrate to .NET Standard 2.0.

This commit is contained in:
Travis Parks 2018-07-15 18:57:30 -04:00
parent 107b588019
commit 21097a18d7
65 changed files with 200 additions and 457 deletions

1
.gitignore vendored
View File

@ -100,6 +100,7 @@ ClientBin
~$*
*.dbmdl
Generated_Code #added for RIA/Silverlight projects
.vs
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)

Binary file not shown.

View File

@ -1,4 +0,0 @@
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" ../mustache-sharp.sln /p:Configuration=Release
nuget pack ../mustache-sharp/mustache-sharp.csproj -Properties Configuration=Release
nuget push *.nupkg -Source https://www.nuget.org/api/v2/package
del *.nupkg

View File

@ -0,0 +1,5 @@
&dotnet pack "..\MustacheSharp\MustacheSharp.csproj" --configuration Release --output $PWD
.\NuGet.exe push mustache-sharp.*.nupkg -Source https://www.nuget.org/api/v2/package
Remove-Item mustache-sharp.*.nupkg

View File

@ -1249,10 +1249,12 @@ Last";
[TestMethod]
public void TestCompile_Each_ContextAfterIndexTag()
{
List<TestObject> objects = new List<TestObject>();
objects.Add(new TestObject { Name = "name1", Val = "val1" });
objects.Add(new TestObject { Name = "name2", Val = "val2" });
objects.Add(new TestObject { Name = "name3", Val = "val3" });
List<TestObject> objects = new List<TestObject>()
{
new TestObject { Name = "name1", Val = "val1" },
new TestObject { Name = "name2", Val = "val2" },
new TestObject { Name = "name3", Val = "val3" }
};
const string template = @"{{#each this}}
Item Number: {{#index}}<br />{{#newline}}

View File

@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>MustacheSharp.Tests.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.2.1" />
<PackageReference Include="MSTest.TestFramework" Version="1.2.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MustacheSharp\MustacheSharp.csproj" />
</ItemGroup>
</Project>

Binary file not shown.

View File

@ -97,8 +97,7 @@ namespace Mustache.Test
{
var source = new Dictionary<string, string>() { { "Name", "Bob" } };
IDictionary<string, object> result = UpcastDictionary.Create(source);
object value;
bool found = result.TryGetValue("Name", out value);
bool found = result.TryGetValue("Name", out object value);
Assert.IsTrue(found, "The key should have been found.");
Assert.AreSame(source["Name"], value, "The value in the underlying dictionary should have been returned.");
}
@ -108,8 +107,7 @@ namespace Mustache.Test
{
var source = new Dictionary<string, int>() { { "Age", 100 } };
IDictionary<string, object> result = UpcastDictionary.Create(source);
object value;
bool found = result.TryGetValue("Name", out value);
bool found = result.TryGetValue("Name", out object value);
Assert.IsFalse(found, "The key should not have been found.");
Assert.IsNull(value, "The value should be null even if the actual type is a struct.");

31
MustacheSharp.sln Normal file
View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2042
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MustacheSharp", "MustacheSharp\MustacheSharp.csproj", "{3013083D-0FB2-4A71-AFD7-6B7875112553}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MustacheSharp.Tests", "MustacheSharp.Tests\MustacheSharp.Tests.csproj", "{AFCE0299-A701-4648-9D3D-CC0084F85259}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3013083D-0FB2-4A71-AFD7-6B7875112553}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3013083D-0FB2-4A71-AFD7-6B7875112553}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3013083D-0FB2-4A71-AFD7-6B7875112553}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3013083D-0FB2-4A71-AFD7-6B7875112553}.Release|Any CPU.Build.0 = Release|Any CPU
{AFCE0299-A701-4648-9D3D-CC0084F85259}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AFCE0299-A701-4648-9D3D-CC0084F85259}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AFCE0299-A701-4648-9D3D-CC0084F85259}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AFCE0299-A701-4648-9D3D-CC0084F85259}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2A85C61F-B68F-44E2-879C-5DEE6EB01C56}
EndGlobalSection
EndGlobal

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
namespace Mustache
@ -9,15 +8,7 @@ namespace Mustache
/// </summary>
internal sealed class ArgumentCollection
{
private readonly Dictionary<TagParameter, IArgument> _argumentLookup;
/// <summary>
/// Initializes a new instance of an ArgumentCollection.
/// </summary>
public ArgumentCollection()
{
_argumentLookup = new Dictionary<TagParameter, IArgument>();
}
private readonly Dictionary<TagParameter, IArgument> _argumentLookup = new Dictionary<TagParameter, IArgument>();
/// <summary>
/// Associates the given parameter to the key placeholder.
@ -36,15 +27,11 @@ namespace Mustache
/// <param name="parameterName">The name of the parameter.</param>
public string GetKey(TagParameter parameter)
{
IArgument argument;
if (_argumentLookup.TryGetValue(parameter, out argument) && argument != null)
if (_argumentLookup.TryGetValue(parameter, out IArgument argument) && argument != null)
{
return argument.GetKey();
}
else
{
return null;
}
return null;
}
/// <summary>

View File

@ -11,7 +11,7 @@ namespace Mustache
{
private readonly TagDefinition _definition;
private readonly ArgumentCollection _arguments;
private readonly List<IGenerator> _primaryGenerators;
private readonly List<IGenerator> _primaryGenerators = new List<IGenerator>();
private IGenerator _subGenerator;
/// <summary>
@ -23,7 +23,6 @@ namespace Mustache
{
_definition = definition;
_arguments = arguments;
_primaryGenerators = new List<IGenerator>();
}
/// <summary>

View File

@ -69,8 +69,7 @@ namespace Mustache
{
return false;
}
IEnumerable enumerable = condition as IEnumerable;
if (enumerable != null)
if (condition is IEnumerable enumerable)
{
return enumerable.Cast<object>().Any();
}

View File

@ -1,6 +1,4 @@
using System;
namespace Mustache
namespace Mustache
{
/// <summary>
/// Defines a tag that can contain inner text.

View File

@ -1,6 +1,4 @@
using System;
namespace Mustache
namespace Mustache
{
/// <summary>
/// Represents a context within a template.
@ -21,11 +19,11 @@ namespace Mustache
/// <summary>
/// Gets the tag that created the context.
/// </summary>
public string TagName { get; private set; }
public string TagName { get; }
/// <summary>
/// Gets the argument used to create the context.
/// </summary>
public ContextParameter[] Parameters { get; private set; }
public ContextParameter[] Parameters { get; }
}
}

View File

@ -1,6 +1,4 @@
using System;
namespace Mustache
namespace Mustache
{
/// <summary>
/// Holds information describing a parameter that creates a new context.
@ -21,11 +19,11 @@ namespace Mustache
/// <summary>
/// Gets the parameter that is used to create a new context.
/// </summary>
public string Parameter { get; private set; }
public string Parameter { get; }
/// <summary>
/// Gets the key whose corresponding value will be used to create the context.
/// </summary>
public string Argument { get; private set; }
public string Argument { get; }
}
}

View File

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using System.IO;
@ -53,8 +52,7 @@ namespace Mustache
Scope contextScope)
{
object value = arguments[collectionParameter];
IEnumerable enumerable = value as IEnumerable;
if (enumerable == null)
if (!(value is IEnumerable enumerable))
{
yield break;
}

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
namespace Mustache
{

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
namespace Mustache
{

View File

@ -12,19 +12,15 @@ namespace Mustache
/// </summary>
public sealed class FormatCompiler
{
private readonly Dictionary<string, TagDefinition> _tagLookup;
private readonly Dictionary<string, Regex> _regexLookup;
private readonly MasterTagDefinition _masterDefinition;
private readonly Dictionary<string, TagDefinition> _tagLookup = new Dictionary<string, TagDefinition>();
private readonly Dictionary<string, Regex> _regexLookup = new Dictionary<string, Regex>();
private readonly MasterTagDefinition _masterDefinition = new MasterTagDefinition();
/// <summary>
/// Initializes a new instance of a FormatCompiler.
/// </summary>
public FormatCompiler()
{
_tagLookup = new Dictionary<string, TagDefinition>();
_regexLookup = new Dictionary<string, Regex>();
_masterDefinition = new MasterTagDefinition();
IfTagDefinition ifDefinition = new IfTagDefinition();
_tagLookup.Add(ifDefinition.Name, ifDefinition);
ElifTagDefinition elifDefinition = new ElifTagDefinition();
@ -111,12 +107,13 @@ namespace Mustache
private Regex prepareRegex(TagDefinition definition)
{
Regex regex;
if (!_regexLookup.TryGetValue(definition.Name, out regex))
if (!_regexLookup.TryGetValue(definition.Name, out Regex regex))
{
List<string> matches = new List<string>();
matches.Add(getKeyRegex());
matches.Add(getCommentTagRegex());
List<string> matches = new List<string>()
{
getKeyRegex(),
getCommentTagRegex()
};
foreach (string closingTag in definition.ClosingTags)
{
matches.Add(getClosingTagRegex(closingTag));
@ -376,8 +373,7 @@ namespace Mustache
}
else if (RegexHelper.IsNumber(placeholder))
{
decimal number;
if (Decimal.TryParse(placeholder, out number))
if (Decimal.TryParse(placeholder, out decimal number))
{
argument = new NumberArgument(number);
}

View File

@ -11,9 +11,9 @@ namespace Mustache
public sealed class Generator
{
private readonly IGenerator _generator;
private readonly List<EventHandler<KeyFoundEventArgs>> _foundHandlers;
private readonly List<EventHandler<KeyNotFoundEventArgs>> _notFoundHandlers;
private readonly List<EventHandler<ValueRequestEventArgs>> _valueRequestedHandlers;
private readonly List<EventHandler<KeyFoundEventArgs>> _foundHandlers = new List<EventHandler<KeyFoundEventArgs>>();
private readonly List<EventHandler<KeyNotFoundEventArgs>> _notFoundHandlers = new List<EventHandler<KeyNotFoundEventArgs>>();
private readonly List<EventHandler<ValueRequestEventArgs>> _valueRequestedHandlers = new List<EventHandler<ValueRequestEventArgs>>();
/// <summary>
/// Initializes a new instance of a Generator.
@ -22,9 +22,6 @@ namespace Mustache
internal Generator(IGenerator generator)
{
_generator = generator;
_foundHandlers = new List<EventHandler<KeyFoundEventArgs>>();
_notFoundHandlers = new List<EventHandler<KeyNotFoundEventArgs>>();
_valueRequestedHandlers = new List<EventHandler<ValueRequestEventArgs>>();
}
/// <summary>

View File

@ -5,11 +5,10 @@ namespace Mustache
{
public sealed class HtmlFormatCompiler
{
private readonly FormatCompiler compiler;
private readonly FormatCompiler compiler = new FormatCompiler();
public HtmlFormatCompiler()
{
compiler = new FormatCompiler();
compiler.AreExtensionTagsAllowed = true;
compiler.RemoveNewLines = true;
}

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mustache
namespace Mustache
{
public interface IArgument
{

View File

@ -1,6 +1,4 @@
using System;
namespace Mustache
namespace Mustache
{
/// <summary>
/// Defines a tag that renders its content depending on the truthyness

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
namespace Mustache
@ -25,8 +24,7 @@ namespace Mustache
/// <param name="contextScope">Extra data passed along with the context.</param>
public override void GetText(TextWriter writer, Dictionary<string, object> arguments, Scope contextScope)
{
object index;
if (contextScope.TryFind("index", out index))
if (contextScope.TryFind("index", out object index))
{
writer.Write(index);
}

View File

@ -25,16 +25,20 @@ namespace Mustache
void IGenerator.GetText(TextWriter writer, Scope scope, Scope context, Action<Substitution> postProcessor)
{
Dictionary<string, object> arguments;
var arguments = GetArguments(scope, context);
_definition.GetText(writer, arguments, context);
}
private Dictionary<string, object> GetArguments(Scope scope, Scope context)
{
if (_definition.IsSetter)
{
arguments = _arguments.GetArgumentKeyNames();
return _arguments.GetArgumentKeyNames();
}
else
{
arguments = _arguments.GetArguments(scope, context);
}
_definition.GetText(writer, arguments, context);
return _arguments.GetArguments(scope, context);
}
}
}
}

View File

@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Collections.Generic;
namespace Mustache
{

View File

@ -21,12 +21,12 @@ namespace Mustache
/// <summary>
/// Gets the fully-qualified key.
/// </summary>
public string Key { get; private set; }
public string Key { get; }
/// <summary>
/// Gets or sets whether the key appeared within triple curly braces.
/// </summary>
public bool IsExtension { get; private set; }
public bool IsExtension { get; }
/// <summary>
/// Gets or sets the object to use as the substitute.

View File

@ -23,17 +23,17 @@ namespace Mustache
/// <summary>
/// Gets the fully-qualified key.
/// </summary>
public string Key { get; private set; }
public string Key { get; }
/// <summary>
/// Gets the part of the key that could not be found.
/// </summary>
public string MissingMember { get; private set; }
public string MissingMember { get; }
/// <summary>
/// Gets whether the key appeared within triple curly braces.
/// </summary>
public bool IsExtension { get; private set; }
public bool IsExtension { get; }
/// <summary>
/// Gets or sets whether to use the substitute.

View File

@ -0,0 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>NET45;netstandard2.0</TargetFrameworks>
<RootNamespace>Mustache</RootNamespace>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>MustacheSharp.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<AssemblyName>mustache-sharp</AssemblyName>
<Authors>Truncon</Authors>
<Description>An extension of the mustache text template engine for .NET.</Description>
<Copyright>Copyright © 2013</Copyright>
<PackageLicenseUrl>https://github.com/jehugaleahsa/mustache-sharp/blob/master/UNLICENSE.txt</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/jehugaleahsa/mustache-sharp</PackageProjectUrl>
<RepositoryUrl>https://github.com/jehugaleahsa/mustache-sharp.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>mustache handlebars text generation building template</PackageTags>
<PackageReleaseNotes>Migrate to .NET Standard 2.0</PackageReleaseNotes>
<NeutralLanguage>en-US</NeutralLanguage>
</PropertyGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

Binary file not shown.

View File

@ -1,5 +1,4 @@
using System;
using System.IO;
using System.IO;
namespace Mustache
{

View File

@ -1,6 +1,4 @@
using System;
namespace Mustache
namespace Mustache
{
public class NumberArgument : IArgument
{

View File

@ -1,6 +1,4 @@
using System;
namespace Mustache
namespace Mustache
{
public class PlaceholderArgument : IArgument
{

View File

@ -1,5 +1,4 @@
using System;
using Mustache.Properties;
namespace Mustache
{
@ -47,6 +46,6 @@ namespace Mustache
/// <summary>
/// Gets the context where the placeholder was found.
/// </summary>
public Context[] Context { get; private set; }
public Context[] Context { get; }
}
}

View File

@ -0,0 +1,3 @@
using System.Runtime.CompilerServices;
[assembly:InternalsVisibleTo("MustacheSharp.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100fd172e711b4abd8f660ce475c6b888aa47f2e1e37c0a9b0296f2df9f7ab9ec8f7fc28c8e926cc8f77079e4b55dcd74427620e0265ded8aba26576e00dc6de91514b52799ee2ed9bb74be24a370bb77f327c92cb5bd114913b75385beeaeb43bba8b66971d21e330ca274a13bc632d6d2ac7ff595c4df0c199a9d0b9e8e9c67ed")]

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18052
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -19,7 +19,7 @@ namespace Mustache.Properties {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {

View File

@ -13,8 +13,6 @@ namespace Mustache
internal sealed class PropertyDictionary : IDictionary<string, object>
{
private static readonly Dictionary<Type, Dictionary<string, Func<object, object>>> _cache = new Dictionary<Type, Dictionary<string, Func<object, object>>>();
private readonly object _instance;
private readonly Dictionary<string, Func<object, object>> _typeCache;
/// <summary>
@ -23,7 +21,7 @@ namespace Mustache
/// <param name="instance">The instance to wrap in the PropertyDictionary.</param>
public PropertyDictionary(object instance)
{
_instance = instance;
Instance = instance;
if (instance == null)
{
_typeCache = new Dictionary<string, Func<object, object>>();
@ -32,7 +30,7 @@ namespace Mustache
{
lock (_cache)
{
_typeCache = getCacheType(_instance);
_typeCache = getCacheType(instance);
}
}
}
@ -98,10 +96,7 @@ namespace Mustache
/// <summary>
/// Gets the underlying instance.
/// </summary>
public object Instance
{
get { return _instance; }
}
public object Instance { get; }
[EditorBrowsable(EditorBrowsableState.Never)]
void IDictionary<string, object>.Add(string key, object value)
@ -148,7 +143,7 @@ namespace Mustache
value = null;
return false;
}
value = getter(_instance);
value = getter(Instance);
return true;
}
@ -163,7 +158,7 @@ namespace Mustache
List<object> values = new List<object>();
foreach (Func<object, object> getter in getters)
{
object value = getter(_instance);
object value = getter(Instance);
values.Add(value);
}
return values.AsReadOnly();
@ -186,7 +181,7 @@ namespace Mustache
get
{
Func<object, object> getter = _typeCache[key];
return getter(_instance);
return getter(Instance);
}
[EditorBrowsable(EditorBrowsableState.Never)]
set
@ -209,12 +204,11 @@ namespace Mustache
bool ICollection<KeyValuePair<string, object>>.Contains(KeyValuePair<string, object> item)
{
Func<object, object> getter;
if (!_typeCache.TryGetValue(item.Key, out getter))
if (!_typeCache.TryGetValue(item.Key, out Func<object, object> getter))
{
return false;
}
object value = getter(_instance);
object value = getter(Instance);
return Equals(item.Value, value);
}
@ -225,7 +219,7 @@ namespace Mustache
foreach (KeyValuePair<string, Func<object, object>> pair in collection)
{
Func<object, object> getter = pair.Value;
object value = getter(_instance);
object value = getter(Instance);
pairs.Add(new KeyValuePair<string, object>(pair.Key, value));
}
pairs.CopyTo(array, arrayIndex);
@ -262,7 +256,7 @@ namespace Mustache
foreach (KeyValuePair<string, Func<object, object>> pair in _typeCache)
{
Func<object, object> getter = pair.Value;
object value = getter(_instance);
object value = getter(Instance);
yield return new KeyValuePair<string, object>(pair.Key, value);
}
}

View File

@ -1,5 +1,4 @@
using System;
using System.Text.RegularExpressions;
using System.Text.RegularExpressions;
namespace Mustache
{

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Mustache.Properties;
namespace Mustache
@ -86,8 +85,7 @@ namespace Mustache
{
return onKeyFound(name, results.Value, isExtension);
}
object value;
if (onKeyNotFound(name, results.Member, isExtension, out value))
if (onKeyNotFound(name, results.Member, isExtension, out object value))
{
return value;
}
@ -199,8 +197,7 @@ namespace Mustache
{
results.Lookup = toLookup(results.Value);
results.MemberIndex = index;
object value;
results.Found = results.Lookup.TryGetValue(results.Member, out value);
results.Found = results.Lookup.TryGetValue(results.Member, out object value);
results.Value = value;
}
return results;
@ -209,8 +206,7 @@ namespace Mustache
private void tryFindFirst(SearchResults results)
{
results.Lookup = toLookup(_source);
object value;
if (results.Lookup.TryGetValue(results.Member, out value))
if (results.Lookup.TryGetValue(results.Member, out object value))
{
results.Found = true;
results.Value = value;

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
namespace Mustache

View File

@ -8,8 +8,6 @@ namespace Mustache
/// </summary>
internal sealed class StaticGenerator : IGenerator
{
private readonly string value;
/// <summary>
/// Initializes a new instance of a StaticGenerator.
/// </summary>
@ -17,21 +15,18 @@ namespace Mustache
{
if (removeNewLines)
{
this.value = value.Replace(Environment.NewLine, String.Empty);
Value = value.Replace(Environment.NewLine, String.Empty);
}
else
{
this.value = value;
Value = value;
}
}
/// <summary>
/// Gets or sets the static text.
/// </summary>
public string Value
{
get { return value; }
}
public string Value { get; }
void IGenerator.GetText(TextWriter writer, Scope scope, Scope context, Action<Substitution> postProcessor)
{

View File

@ -1,6 +1,4 @@
using System;
namespace Mustache
namespace Mustache
{
public class StringArgument : IArgument
{

View File

@ -1,6 +1,4 @@
using System;
namespace Mustache
namespace Mustache
{
internal class Substitution
{

View File

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using Mustache.Properties;
using System.IO;
using Mustache.Properties;
namespace Mustache
{
@ -10,8 +10,6 @@ namespace Mustache
/// </summary>
public abstract class TagDefinition
{
private readonly string _tagName;
/// <summary>
/// Initializes a new instance of a TagDefinition.
/// </summary>
@ -33,16 +31,13 @@ namespace Mustache
{
throw new ArgumentException(Resources.BlankTagName, "tagName");
}
_tagName = tagName;
Name = tagName;
}
/// <summary>
/// Gets the name of the tag.
/// </summary>
public string Name
{
get { return _tagName; }
}
public string Name { get; private set; }
internal bool IsSetter
{

View File

@ -23,12 +23,12 @@ namespace Mustache
/// <summary>
/// Gets the fully-qualified key.
/// </summary>
public string Key { get; private set; }
public string Key { get; }
/// <summary>
/// Gets or sets whether the key appeared within triple curly braces.
/// </summary>
public bool IsExtension { get; private set; }
public bool IsExtension { get; }
/// <summary>
/// Gets or sets the object to use as the substitute.

View File

@ -8,8 +8,6 @@ namespace Mustache
/// </summary>
public sealed class TagParameter
{
private readonly string _name;
/// <summary>
/// Initializes a new instance of a TagParameter.
/// </summary>
@ -21,34 +19,23 @@ namespace Mustache
{
throw new ArgumentException(Resources.BlankParameterName, "parameterName");
}
_name = parameterName;
Name = parameterName;
}
/// <summary>
/// Gets the name of the parameter.
/// </summary>
public string Name
{
get { return _name; }
}
public string Name { get; }
/// <summary>
/// Gets or sets whether the field is required.
/// </summary>
public bool IsRequired
{
get;
set;
}
public bool IsRequired { get; set; }
/// <summary>
/// Gets or sets the default value to use when an argument is not provided
/// for the parameter.
/// </summary>
public object DefaultValue
{
get;
set;
}
public object DefaultValue { get; set; }
}
}

View File

@ -14,8 +14,7 @@ namespace Mustache
{
return null;
}
IDictionary<string, object> sourceDictionary = source as IDictionary<string, object>;
if (sourceDictionary != null)
if (source is IDictionary<string, object> sourceDictionary)
{
return sourceDictionary;
}
@ -123,8 +122,7 @@ namespace Mustache
public bool TryGetValue(string key, out object value)
{
TValue result;
if (dictionary.TryGetValue(key, out result))
if (dictionary.TryGetValue(key, out TValue result))
{
value = result;
return true;

View File

@ -1,6 +1,4 @@
using System;
namespace Mustache
namespace Mustache
{
public class VariableArgument : IArgument
{

View File

@ -1,5 +1,4 @@
using System;
using Mustache.Properties;
namespace Mustache
{
@ -48,6 +47,6 @@ namespace Mustache
/// <summary>
/// Gets the context where the placeholder was found.
/// </summary>
public Context[] Context { get; private set; }
public Context[] Context { get; }
}
}

View File

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
namespace Mustache

View File

@ -1,29 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mustache-sharp", "mustache-sharp\mustache-sharp.csproj", "{D71B378F-A4BA-4263-A4F0-07A49A0C528D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mustache-sharp.test", "mustache-sharp.test\mustache-sharp.test.csproj", "{7F607362-0680-4751-B1DC-621219294AE3}"
EndProject
Global
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = mustache-sharp.vsmdi
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D71B378F-A4BA-4263-A4F0-07A49A0C528D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D71B378F-A4BA-4263-A4F0-07A49A0C528D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D71B378F-A4BA-4263-A4F0-07A49A0C528D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D71B378F-A4BA-4263-A4F0-07A49A0C528D}.Release|Any CPU.Build.0 = Release|Any CPU
{7F607362-0680-4751-B1DC-621219294AE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7F607362-0680-4751-B1DC-621219294AE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7F607362-0680-4751-B1DC-621219294AE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7F607362-0680-4751-B1DC-621219294AE3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -1,15 +0,0 @@
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("mustache-sharp.test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Truncon")]
[assembly: AssemblyProduct("mustache-sharp.test")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("9975f293-f972-4751-9c8c-e25b17c0c8bc")]
[assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyFileVersion("0.0.0.0")]

View File

@ -1,75 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7F607362-0680-4751-B1DC-621219294AE3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Mustache.Test</RootNamespace>
<AssemblyName>mustache-sharp.test</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>mustache-sharp.test.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Web" />
</ItemGroup>
<ItemGroup>
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
<Visible>False</Visible>
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
<ItemGroup>
<Compile Include="FormatCompilerTester.cs" />
<Compile Include="HtmlFormatCompilerTester.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UpcastDictionaryTester.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\mustache-sharp\mustache-sharp.csproj">
<Project>{d71b378f-a4ba-4263-a4f0-07a49a0c528d}</Project>
<Name>mustache-sharp</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="mustache-sharp.test.snk" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -1,19 +0,0 @@
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("mustache-sharp")]
[assembly: AssemblyDescription("A extension of the mustache text template engine for .NET.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("truncon")]
[assembly: AssemblyProduct("mustache-sharp")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: CLSCompliant(true)]
[assembly: ComVisible(false)]
[assembly: Guid("e5a4263d-d450-4d85-a4d5-44c0a2822668")]
[assembly: AssemblyVersion("0.2.10.0")]
[assembly: AssemblyFileVersion("0.2.10.0")]
[assembly: InternalsVisibleTo("mustache-sharp.test,PublicKey=0024000004800000940000000602000000240000525341310004000001000100755df5a2b24c568812aae0eb194d08a4e3cba960673bcc07a7d446acf52f3f56ae2155b37b8d547bc5d8c562823bd592d1312bef9ad4740a8bb503d0095c31419f9d190882a2fa46090412bf15b13ca0057ba533c85a853333132ec8b70cf19655ef961b06d1c3fc35b3f68680420562be741456cb7a18bd5ab0fa779f8d47b1")]

View File

@ -1,109 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D71B378F-A4BA-4263-A4F0-07A49A0C528D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Mustache</RootNamespace>
<AssemblyName>mustache-sharp</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>mustache-sharp.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="ArgumentCollection.cs" />
<Compile Include="CompoundGenerator.cs" />
<Compile Include="ConditionTagDefinition.cs" />
<Compile Include="ContentTagDefinition.cs" />
<Compile Include="Context.cs" />
<Compile Include="ContextParameter.cs" />
<Compile Include="Substitution.cs" />
<Compile Include="TagFormattedEventArgs.cs" />
<Compile Include="HtmlFormatCompiler.cs" />
<Compile Include="IArgument.cs" />
<Compile Include="NumberArgument.cs" />
<Compile Include="PlaceholderArgument.cs" />
<Compile Include="StringArgument.cs" />
<Compile Include="UpcastDictionary.cs" />
<Compile Include="VariableArgument.cs" />
<Compile Include="VariableFoundEventArgs.cs" />
<Compile Include="SetTagDefinition.cs" />
<Compile Include="NewlineTagDefinition.cs" />
<Compile Include="IndexTagDefinition.cs" />
<Compile Include="KeyFoundEventArgs.cs" />
<Compile Include="InlineTagDefinition.cs" />
<Compile Include="EachTagDefinition.cs" />
<Compile Include="ElifTagDefinition.cs" />
<Compile Include="ElseTagDefinition.cs" />
<Compile Include="FormatCompiler.cs" />
<Compile Include="Generator.cs" />
<Compile Include="IfTagDefinition.cs" />
<Compile Include="IGenerator.cs" />
<Compile Include="InlineGenerator.cs" />
<Compile Include="PlaceholderFoundEventArgs.cs" />
<Compile Include="KeyGenerator.cs" />
<Compile Include="MasterTagDefinition.cs" />
<Compile Include="KeyNotFoundEventArgs.cs" />
<Compile Include="NestedContext.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="PropertyDictionary.cs" />
<Compile Include="RegexHelper.cs" />
<Compile Include="StaticGenerator.cs" />
<Compile Include="TagDefinition.cs" />
<Compile Include="TagParameter.cs" />
<Compile Include="Scope.cs" />
<Compile Include="ValueRequestEventArgs.cs" />
<Compile Include="WithTagDefinition.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="mustache-sharp.snk" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -1,17 +0,0 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<projectUrl>http://github.com/jehugaleahsa/mustache-sharp</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<copyright>Copyright 2013</copyright>
<tags>
mustache handlebars.js text generation building template
</tags>
</metadata>
</package>

Binary file not shown.