From 3e5d8400de1a687f0a8dbbee0a367f2d2296ad5a Mon Sep 17 00:00:00 2001
From: Tanzi <1107360+qqblack@user.noreply.gitee.com>
Date: Wed, 27 Sep 2023 09:13:57 +0800
Subject: [PATCH] fix spelling: (1) Pathes -> Paths (2)standart -> standard (3)
expresion -> expression
---
CalcBinding/CalcBinding.cs | 48 ++++++++---------
.../PathAnalysis/PropertyPathAnalyzer.cs | 12 ++---
Tests/PropertyPathAnalyzerTests.cs | 54 +++++++++----------
Tests/StaticPropertiesTests.cs | 2 +-
4 files changed, 58 insertions(+), 58 deletions(-)
diff --git a/CalcBinding/CalcBinding.cs b/CalcBinding/CalcBinding.cs
index 7c82cdf..90f32d0 100644
--- a/CalcBinding/CalcBinding.cs
+++ b/CalcBinding/CalcBinding.cs
@@ -18,7 +18,7 @@ namespace CalcBinding
///
public sealed class Binding : MarkupExtension
{
- // We cannot use PropertyPath instead of string (such as standart Binding) because transformation from xaml value string to Property path
+ // We cannot use PropertyPath instead of string (such as standard Binding) because transformation from xaml value string to Property path
// is doing automatically by PropertyPathConverter and result PropertyPath object could have form, that cannot retranslate to normal string.
// e.g.: (local:MyStaticVM.Prop) -> PropertyPath.Path = (0), Converted to string = MyStaticVM.Prop (but we need to analyze static class with xaml namespace prefix)
public string Path { get; set; }
@@ -29,10 +29,10 @@ public sealed class Binding : MarkupExtension
public FalseToVisibility FalseToVisibility { get; set; } = FalseToVisibility.Collapsed;
///
- /// If true then single quotes and double quotes are considered as single quotes, otherwise - both are considerent as double quotes
+ /// If true then single quotes and double quotes are considered as single quotes, otherwise - both are considerate as double quotes
///
///
- /// Use this flag if you need to use char is path expresion
+ /// Use this flag if you need to use char is path expression
///
public bool SingleQuotes { get; set; } = false;
@@ -61,9 +61,9 @@ public override object ProvideValue(IServiceProvider serviceProvider)
var typeDescriptor = serviceProvider as ITypeDescriptorContext;
var normalizedPath = NormalizePath(Path);
- var pathes = GetSourcePathes(normalizedPath, typeResolver);
+ var paths = GetSourcePaths(normalizedPath, typeResolver);
- var expressionTemplate = GetExpressionTemplate(normalizedPath, pathes, out Dictionary enumParameters);
+ var expressionTemplate = GetExpressionTemplate(normalizedPath, paths, out Dictionary enumParameters);
var mathConverter = new CalcConverter(_parser.Value, FallbackValue, enumParameters)
{
@@ -71,13 +71,13 @@ public override object ProvideValue(IServiceProvider serviceProvider)
StringFormatDefined = StringFormat != null,
};
- var bindingPathes = pathes
+ var bindingPaths = paths
.Where(p => p.PathId.PathType == PathTokenType.Property ||
p.PathId.PathType == PathTokenType.StaticProperty).ToList();
BindingBase resBinding;
- if (bindingPathes.Count == 1)
+ if (bindingPaths.Count == 1)
{
// todo: can enums be binded ? What if one value is Enum? bug..
var binding = new System.Windows.Data.Binding()
@@ -96,13 +96,13 @@ public override object ProvideValue(IServiceProvider serviceProvider)
#endif
};
- var pathId = bindingPathes.Single().PathId;
+ var pathId = bindingPaths.Single().PathId;
// we need to use convert from string for support of static properties
var pathValue = pathId.Value;
if (pathId.PathType == PathTokenType.StaticProperty)
{
- pathValue = string.Format("({0})", pathValue); // need to use brackets for Static property recognition in standart binding
+ pathValue = string.Format("({0})", pathValue); // need to use brackets for Static property recognition in standard binding
}
var resPath = (PropertyPath)new PropertyPathConverter().ConvertFromString(typeDescriptor, pathValue);
binding.Path = resPath;
@@ -119,7 +119,7 @@ public override object ProvideValue(IServiceProvider serviceProvider)
if (StringFormat != null)
binding.StringFormat = StringFormat;
- // we don't use converter if binding is trivial - {0}, except type convertion from bool to visibility
+ // we don't use converter if binding is trivial - {0}, except type conversion from bool to visibility
//todo: use more smart recognition for template (with analysing brackets ({1}) any count )
// trivial binding, CalcBinding converter is not needed
@@ -155,7 +155,7 @@ public override object ProvideValue(IServiceProvider serviceProvider)
if (StringFormat != null)
mBinding.StringFormat = StringFormat;
- foreach (var path in bindingPathes)
+ foreach (var path in bindingPaths)
{
var binding = new System.Windows.Data.Binding();
@@ -164,7 +164,7 @@ public override object ProvideValue(IServiceProvider serviceProvider)
if (path.PathId.PathType == PathTokenType.StaticProperty)
{
- pathValue = string.Format("({0})", pathValue); // need to use brackets for Static property recognition in standart binding
+ pathValue = string.Format("({0})", pathValue); // need to use brackets for Static property recognition in standard binding
}
var resPath = (PropertyPath)new PropertyPathConverter().ConvertFromString(typeDescriptor, pathValue);
@@ -213,10 +213,10 @@ private Type GetPropertyType(IServiceProvider serviceProvider)
}
///
- /// Replace source properties pathes by its numbers
+ /// Replace source properties paths by its numbers
///
///
- ///
+ ///
///
private string GetExpressionTemplate(string path, List properties, out Dictionary enumParameters)
{
@@ -235,7 +235,7 @@ private string GetExpressionTemplate(string path, List properti
{
var propGroup = properties[index];
var propId = propGroup.PathId;
- var targetProp = propGroup.Pathes.FirstOrDefault(token => token.Start == sourceIndex);
+ var targetProp = propGroup.paths.FirstOrDefault(token => token.Start == sourceIndex);
if (targetProp != null)
{
@@ -260,7 +260,7 @@ private string GetExpressionTemplate(string path, List properti
}
else if (propId.PathType == PathTokenType.Enum)
{
- var enumPath = propGroup.Pathes.First() as EnumToken;
+ var enumPath = propGroup.paths.First() as EnumToken;
string enumTypeName = null;
if (enumNames.ContainsKey(propId))
@@ -302,17 +302,17 @@ private string GetEnumName(int i)
}
///
- /// Find all sourceProperties pathes in Path string
+ /// Find all sourceProperties paths in Path string
///
///
- /// List of pathes and its start positions
- private List GetSourcePathes(string normPath, IXamlTypeResolver typeResolver)
+ /// List of paths and its start positions
+ private List GetSourcePaths(string normPath, IXamlTypeResolver typeResolver)
{
var propertyPathAnalyzer = new PropertyPathAnalyzer();
- var pathes = propertyPathAnalyzer.GetPathes(normPath, typeResolver);
+ var paths = propertyPathAnalyzer.GetPaths(normPath, typeResolver);
- var propertiesGroups = pathes.GroupBy(p => p.Id).Select(p => new PathAppearances(p.Key, p.ToList())).ToList();
+ var propertiesGroups = paths.GroupBy(p => p.Id).Select(p => new PathAppearances(p.Key, p.ToList())).ToList();
return propertiesGroups;
}
@@ -551,12 +551,12 @@ class PathAppearances
{
public PathTokenId PathId { get; private set; }
- public IEnumerable Pathes { get; private set; }
+ public IEnumerable Paths { get; private set; }
- public PathAppearances(PathTokenId id, List pathes)
+ public PathAppearances(PathTokenId id, List paths)
{
PathId = id;
- Pathes = pathes;
+ Paths = paths;
}
}
}
diff --git a/CalcBinding/PathAnalysis/PropertyPathAnalyzer.cs b/CalcBinding/PathAnalysis/PropertyPathAnalyzer.cs
index 54edd83..4d000b1 100644
--- a/CalcBinding/PathAnalysis/PropertyPathAnalyzer.cs
+++ b/CalcBinding/PathAnalysis/PropertyPathAnalyzer.cs
@@ -10,8 +10,8 @@
namespace CalcBinding.PathAnalysis
{
///
- /// Idea of parser: to detect right all entries of property pathes, static property pathes etc. without parsing language structures
- /// For full validation of expression there need to write own analizer of C# lanquage whick could determine xaml names too...
+ /// Idea of parser: to detect right all entries of property paths, static property paths etc. without parsing language structures
+ /// For full validation of expression there need to write own analyzer of C# language which could determine xaml names too...
///
public class PropertyPathAnalyzer
{
@@ -55,16 +55,16 @@ static PropertyPathAnalyzer()
#region Parser cycle
- public List GetPathes(string normPath, IXamlTypeResolver typeResolver)
+ public List GetPaths(string normPath, IXamlTypeResolver typeResolver)
{
_typeResolver = typeResolver;
Tracer.TraceDebug(string.Format("Start read {0} ", normPath));
var chunks = GetChunks(normPath);
- var pathes = GetPathes(chunks);
+ var paths = GetPaths(chunks);
- return pathes;
+ return paths;
}
private List GetChunks(string str)
@@ -126,7 +126,7 @@ private List GetChunks(string str)
} while (true);
}
- private List GetPathes(List chunks)
+ private List GetPaths(List chunks)
{
List tokens = new List();
diff --git a/Tests/PropertyPathAnalyzerTests.cs b/Tests/PropertyPathAnalyzerTests.cs
index 70bc5af..de0f69a 100644
--- a/Tests/PropertyPathAnalyzerTests.cs
+++ b/Tests/PropertyPathAnalyzerTests.cs
@@ -33,7 +33,7 @@ public void KnownDelimitersTest()
[TestMethod]
public void PropertyPathTokensTest()
{
- AssertPropertyPathes("MyProp.N+Other+(Next.N5ext1._Next2)-MyProp+4.56-MyProp.N", null, true,
+ AssertPropertyPaths("MyProp.N+Other+(Next.N5ext1._Next2)-MyProp+4.56-MyProp.N", null, true,
new PropertyPathToken(0, 7, new[] { "MyProp", "N" }),
new PropertyPathToken(9, 13, new[] { "Other" }),
new PropertyPathToken(16, 33, new[] { "Next", "N5ext1", "_Next2" }),
@@ -45,7 +45,7 @@ public void PropertyPathTokensTest()
[TestMethod]
public void StaticPropertyPathTokensTest()
{
- AssertPropertyPathes("local:MyClass.MyProp.N^local:MyClass.Other.B/(local:MyClass.Next.Next1.Next24)*(4.34*local:MyClass.MyProp.N)+local:MyClass.MyProp.M-24", null, true,
+ AssertPropertyPaths("local:MyClass.MyProp.N^local:MyClass.Other.B/(local:MyClass.Next.Next1.Next24)*(4.34*local:MyClass.MyProp.N)+local:MyClass.MyProp.M-24", null, true,
new StaticPropertyPathToken(0, 21, "local", "MyClass", new[] { "MyProp", "N" }),
new StaticPropertyPathToken(23, 43, "local", "MyClass", new[] { "Other", "B" }),
new StaticPropertyPathToken(46, 76, "local", "MyClass", new[] { "Next", "Next1", "Next24" }),
@@ -63,7 +63,7 @@ public void EnumPropertyPathTokensTest()
{"local:Enum2", typeof(ExampleEnum2)},
});
- AssertPropertyPathes("(1 > 0) ? local:MyClass.MyProp : local:MyClass.Prop", resolver, true,
+ AssertPropertyPaths("(1 > 0) ? local:MyClass.MyProp : local:MyClass.Prop", resolver, true,
new StaticPropertyPathToken(10, 29, "local", "MyClass", new[] { "MyProp" }),
new StaticPropertyPathToken(33, 50, "local", "MyClass", new[] { "Prop" })
);
@@ -78,43 +78,43 @@ public void ComplexTernarOperatorTest()
{"local:Enum2", typeof(ExampleEnum2)},
});
- AssertPropertyPathes("(1 > 0) ? local:MyClass.MyProp : local:MyClass.Prop", resolver, true,
+ AssertPropertyPaths("(1 > 0) ? local:MyClass.MyProp : local:MyClass.Prop", resolver, true,
new StaticPropertyPathToken(10, 29, "local", "MyClass", new[] {"MyProp"}),
new StaticPropertyPathToken(33, 50, "local", "MyClass", new[] {"Prop"})
);
- AssertPropertyPathes("1 > 0 ? MyProp : local:MyClass.Prop", resolver, true,
+ AssertPropertyPaths("1 > 0 ? MyProp : local:MyClass.Prop", resolver, true,
new PropertyPathToken(8, 13, new[] {"MyProp"}),
new StaticPropertyPathToken(17, 34, "local", "MyClass", new[] {"Prop"})
);
- AssertPropertyPathes("1 > 0 ? Local : Prop", resolver, true,
+ AssertPropertyPaths("1 > 0 ? Local : Prop", resolver, true,
new PropertyPathToken(8, 12, new[] {"Local"}),
new PropertyPathToken(16, 19, new[] {"Prop"})
);
- AssertPropertyPathes("1 > 0 ? Local:Prop.P1 : P2", resolver, true,
+ AssertPropertyPaths("1 > 0 ? Local:Prop.P1 : P2", resolver, true,
new StaticPropertyPathToken(8, 20, "Local", "Prop", new[] {"P1"}),
new PropertyPathToken(24, 25, new [] {"P2"})
);
- AssertPropertyPathes("1 > 0 ? (5+Local:Prop.P1): P2", resolver, true,
+ AssertPropertyPaths("1 > 0 ? (5+Local:Prop.P1): P2", resolver, true,
new StaticPropertyPathToken(11, 23, "Local", "Prop", new[] {"P1"}),
new PropertyPathToken(27, 28, new[] {"P2"})
);
- AssertPropertyPathes("1 > 0 ? (\"5\"+Local:Prop.P1): P2", resolver, true,
+ AssertPropertyPaths("1 > 0 ? (\"5\"+Local:Prop.P1): P2", resolver, true,
new StaticPropertyPathToken(13, 25, "Local", "Prop", new[] { "P1" }),
new PropertyPathToken(29, 30, new[] { "P2" })
);
- AssertPropertyPathes("1 > 0 ? (Local1:Class2.P4+Local:Prop.P1) : P2", resolver, true,
+ AssertPropertyPaths("1 > 0 ? (Local1:Class2.P4+Local:Prop.P1) : P2", resolver, true,
new StaticPropertyPathToken(9, 24, "Local1", "Class2", new[] {"P4"}),
new StaticPropertyPathToken(26, 38, "Local", "Prop", new[] {"P1"}),
new PropertyPathToken(43, 44, new[] {"P2"})
);
- AssertPropertyPathes("1 > 0 ? local:Enum1.Prop1 : local:Enum2.Prop2", resolver, true,
+ AssertPropertyPaths("1 > 0 ? local:Enum1.Prop1 : local:Enum2.Prop2", resolver, true,
new EnumToken(8, 24, "local", typeof(ExampleEnum1), "Prop1"),
new EnumToken(28, 44, "local", typeof(ExampleEnum2), "Prop2")
);
@@ -124,7 +124,7 @@ public void ComplexTernarOperatorTest()
public void ColorsTest()
{
var colorsResolver = new XamlTypeResolverMock(new Dictionary{{"colors:Colors", typeof(Colors)}});
- AssertPropertyPathes("Enabled?colors:Colors.White : colors:Colors.Black", colorsResolver, false,
+ AssertPropertyPaths("Enabled?colors:Colors.White : colors:Colors.Black", colorsResolver, false,
new PropertyPathToken(0, 0, new []{"Enabled"}),
new StaticPropertyPathToken(0, 0, "colors", "Colors", new [] {"White"}),
new StaticPropertyPathToken(0, 0, "colors", "Colors", new[] { "Black" }));
@@ -136,7 +136,7 @@ public void BadUseOfTernarOperator()
var analyzer = new PropertyPathAnalyzer();
var resolver = new XamlTypeResolverMock(null);
- var badPathes = new []{
+ var badPaths = new []{
"(Color>local:Colors.Enum?Color:Color",
"(Color>local:Colors.Enum?Color: Color",
"(Color>local:Colors.Enum?Color :Color",
@@ -144,11 +144,11 @@ public void BadUseOfTernarOperator()
"(Color>local:Colors.Enum?local:Color.prop :Color",
};
- foreach(var path in badPathes)
+ foreach(var path in badPaths)
{
try
{
- analyzer.GetPathes(path, null);
+ analyzer.GetPaths(path, null);
}
catch (Exception e)
{
@@ -161,7 +161,7 @@ public void BadUseOfTernarOperator()
[TestMethod]
public void MathPathTokensTest()
{
- AssertPropertyPathes("Math.PI+Math.Sin(45.5)*Math.Cos(Math.ATan(55))", null, true,
+ AssertPropertyPaths("Math.PI+Math.Sin(45.5)*Math.Cos(Math.ATan(55))", null, true,
new MathToken(0, 6, "PI"),
new MathToken(8, 15, "Sin"),
new MathToken(23, 30, "Cos"),
@@ -174,7 +174,7 @@ public void InternatializationPathTokensTest()
{
var emptyResolver = new XamlTypeResolverMock(null);
- AssertPropertyPathes("1 > 0 ? local:propiedad.icône : local:Класс.中國.český", emptyResolver, true,
+ AssertPropertyPaths("1 > 0 ? local:propiedad.icône : local:Класс.中國.český", emptyResolver, true,
new StaticPropertyPathToken(8, 28, "local", "propiedad", new[] { "icône" }),
new StaticPropertyPathToken(32, 51, "local", "Класс", new[] { "中國", "český" })
);
@@ -185,23 +185,23 @@ public void ParsingPathWithStringConstantsTest()
{
var emptyResolver = new XamlTypeResolverMock(null);
- AssertPropertyPathes("S + \"1\" + \"0\"", emptyResolver, true,
+ AssertPropertyPaths("S + \"1\" + \"0\"", emptyResolver, true,
new PropertyPathToken(0, 0, new[] { "S" })
);
- AssertPropertyPathes("S + \"local:MyClass.Property\" + \"0\"", emptyResolver, true,
+ AssertPropertyPaths("S + \"local:MyClass.Property\" + \"0\"", emptyResolver, true,
new PropertyPathToken(0, 0, new[] { "S" })
);
- AssertPropertyPathes("S + \"'local:MyClass.Property'\" + \"0\"", emptyResolver, true,
+ AssertPropertyPaths("S + \"'local:MyClass.Property'\" + \"0\"", emptyResolver, true,
new PropertyPathToken(0, 0, new[] { "S" })
);
- AssertPropertyPathes("S + \"'local:MyClass.Property\" + \"0\"", emptyResolver, true,
+ AssertPropertyPaths("S + \"'local:MyClass.Property\" + \"0\"", emptyResolver, true,
new PropertyPathToken(0, 0, new[] { "S" })
);
- AssertPropertyPathes("S + \"\" + \"0\"", emptyResolver, true,
+ AssertPropertyPaths("S + \"\" + \"0\"", emptyResolver, true,
new PropertyPathToken(0, 0, new[] { "S" })
);
//"5:5", "local:MyProp.Nested", "'sdfsdf'", "'", "", '' more more..
@@ -212,24 +212,24 @@ public void ParsingPathWithCharConstantsTest()
{
var emptyResolver = new XamlTypeResolverMock(null);
- AssertPropertyPathes("S + '1' + '0'", emptyResolver, true,
+ AssertPropertyPaths("S + '1' + '0'", emptyResolver, true,
new PropertyPathToken(0, 0, new[] { "S" })
);
- AssertPropertyPathes("S + ''", emptyResolver, true,
+ AssertPropertyPaths("S + ''", emptyResolver, true,
new PropertyPathToken(0, 0, new[] { "S" })
);
- AssertPropertyPathes("S + '\"'", emptyResolver, true,
+ AssertPropertyPaths("S + '\"'", emptyResolver, true,
new PropertyPathToken(0, 0, new[] { "S" })
);
}
- private void AssertPropertyPathes(string path, IXamlTypeResolver typeResolver, bool positionsCheck, params PathToken[] expectedTokens)
+ private void AssertPropertyPaths(string path, IXamlTypeResolver typeResolver, bool positionsCheck, params PathToken[] expectedTokens)
{
var analyzer = new PropertyPathAnalyzer();
- var tokens = analyzer.GetPathes(path, typeResolver);
+ var tokens = analyzer.GetPaths(path, typeResolver);
CollectionAssert.AreEqual(expectedTokens.ToList(), tokens, new TestPathComparer(positionsCheck));
}
diff --git a/Tests/StaticPropertiesTests.cs b/Tests/StaticPropertiesTests.cs
index 0998643..b461fdb 100644
--- a/Tests/StaticPropertiesTests.cs
+++ b/Tests/StaticPropertiesTests.cs
@@ -124,7 +124,7 @@ public void TernaryOperatorWithStringTest()
}
[TestMethod]
- public void TwoStaticPropertyPathesTest()
+ public void TwoStaticPropertyPathsTest()
{
BrushBindingAssert("(local:StaticExampleClass.StaticA > 5?m:Brushes.White : m:Brushes.Black) ", null,
() => { StaticExampleClass.StaticA = 4; }, Brushes.Black,