Skip to content

Commit 36362ba

Browse files
[Cleaning] Apply full camel case names for static classes
1 parent fc95734 commit 36362ba

File tree

10 files changed

+55
-54
lines changed

10 files changed

+55
-54
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## v2.0.2
44
Updated to .NET 5
5+
Breaking changes: WPFVisualFinders -> WpfVisualFinders and WPFVisualFindersExtensions -> WpfVisualFindersExtensions
56

67
## v2.0.1
78
Updated minimum .Net Core version and package info for better visibility in Nuget feeds.
File renamed without changes.
File renamed without changes.

ExtendedWPFVisualTreeHelper.Tests/Tests/FindChildrenTests.cs renamed to ExtendedWPFVisualTreeHelper.Tests/FindChildrenTests.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ void Inspect(FrameworkElement tree)
2222
var hasContentElementInPath = TestData.HasContentElementWithin(xaml);
2323

2424
// Build generic methods manually, since the type to seek might change for each data set:
25-
var methodInfo = typeof(WPFVisualFinders).GetMethod("FindChild");
25+
var methodInfo = typeof(WpfVisualFinders).GetMethod("FindChild");
2626
var method = methodInfo?.MakeGenericMethod(expected.GetType());
27-
var extMethodInfo = typeof(WPFVisualFindersExtensions).GetMethod("FindChild");
27+
var extMethodInfo = typeof(WpfVisualFindersExtensions).GetMethod("FindChild");
2828
var extMethod = extMethodInfo?.MakeGenericMethod(expected.GetType());
2929

3030
// Test unnamed:
@@ -59,7 +59,7 @@ void Inspect(FrameworkElement tree)
5959
Assert.Same(namedResult, regexExtensionResult);
6060
}
6161

62-
WPFAppTester.RunTestInWindow(Inspect, xaml);
62+
WpfAppTester.RunTestInWindow(Inspect, xaml);
6363
}
6464
#endregion
6565

@@ -76,7 +76,7 @@ void Inspect(FrameworkElement tree)
7676
var hasContentElementInPath = TestData.HasContentElementWithin(xaml);
7777

7878
// Test unnamed:
79-
var result = WPFVisualFinders.FindChildByType(origin, expected.GetType(), allowContentElements: allowContentElements);
79+
var result = WpfVisualFinders.FindChildByType(origin, expected.GetType(), allowContentElements: allowContentElements);
8080
if (relatedInPath && (allowContentElements || !hasContentElementInPath))
8181
{
8282
if (!hasSimilarTypeInPath) // should find destination if not caught a similar type.
@@ -91,13 +91,13 @@ void Inspect(FrameworkElement tree)
9191
Assert.Same(result, extensionResult);
9292

9393
// Test named:
94-
var namedResult = WPFVisualFinders.FindChildByType(origin, expected.GetType(), "End", allowContentElements);
94+
var namedResult = WpfVisualFinders.FindChildByType(origin, expected.GetType(), "End", allowContentElements);
9595
if (relatedInPath && (allowContentElements || !hasContentElementInPath)) // should always find if related in path
9696
Assert.Same(expected, namedResult);
9797
else Assert.Null(namedResult);
9898

9999
// Test with regex:
100-
var regexResult = WPFVisualFinders.FindChildByType(origin, expected.GetType(), @"E[a-z]\D{1}", allowContentElements);
100+
var regexResult = WpfVisualFinders.FindChildByType(origin, expected.GetType(), @"E[a-z]\D{1}", allowContentElements);
101101
Assert.Same(namedResult, regexResult);
102102

103103
// Test extension method with named target and regex:
@@ -107,7 +107,7 @@ void Inspect(FrameworkElement tree)
107107
Assert.Same(namedResult, regexExtensionResult);
108108
}
109109

110-
WPFAppTester.RunTestInWindow(Inspect, xaml);
110+
WpfAppTester.RunTestInWindow(Inspect, xaml);
111111
}
112112
#endregion
113113

@@ -127,9 +127,9 @@ void Inspect(FrameworkElement tree)
127127
var hasContentElementInPath = TestData.HasContentElementWithin(xaml);
128128

129129
// Build generic methods manually, since the type to seek might change for each data set:
130-
var methodInfo = typeof(WPFVisualFinders).GetMethod("FindDirectChild");
130+
var methodInfo = typeof(WpfVisualFinders).GetMethod("FindDirectChild");
131131
var method = methodInfo?.MakeGenericMethod(expected.GetType());
132-
var extMethodInfo = typeof(WPFVisualFindersExtensions).GetMethod("FindDirectChild");
132+
var extMethodInfo = typeof(WpfVisualFindersExtensions).GetMethod("FindDirectChild");
133133
var extMethod = extMethodInfo?.MakeGenericMethod(expected.GetType());
134134

135135
// Test unnamed:
@@ -161,7 +161,7 @@ void Inspect(FrameworkElement tree)
161161
Assert.Same(namedResult, regexExtensionResult);
162162
}
163163

164-
WPFAppTester.RunTestInWindow(Inspect, xaml);
164+
WpfAppTester.RunTestInWindow(Inspect, xaml);
165165
}
166166
#endregion
167167

@@ -181,7 +181,7 @@ void Inspect(FrameworkElement tree)
181181
var hasContentElementInPath = TestData.HasContentElementWithin(xaml);
182182

183183
// Test unnamed:
184-
var result = WPFVisualFinders.FindDirectChildByType(origin, expected.GetType(), allowContentElements: allowContentElements);
184+
var result = WpfVisualFinders.FindDirectChildByType(origin, expected.GetType(), allowContentElements: allowContentElements);
185185
if (hasSimilarTypeInDirectPath && (allowContentElements || !hasContentElementInPath)) // here if caught an intermediary node
186186
Assert.Equal(expected.GetType(), result?.GetType());
187187
else if (inDirectPath && (allowContentElements || !hasContentElementInPath)) // should find destination if not caught a similar type.
@@ -193,13 +193,13 @@ void Inspect(FrameworkElement tree)
193193
Assert.Same(result, extensionResult);
194194

195195
// Test named:
196-
var namedResult = WPFVisualFinders.FindDirectChildByType(origin, expected.GetType(), "End", allowContentElements);
196+
var namedResult = WpfVisualFinders.FindDirectChildByType(origin, expected.GetType(), "End", allowContentElements);
197197
if (inDirectPath && (allowContentElements || !hasContentElementInPath)) // should always find if related in path
198198
Assert.Same(expected, namedResult);
199199
else Assert.Null(namedResult);
200200

201201
// Test with regex:
202-
var regexResult = WPFVisualFinders.FindDirectChildByType(origin, expected.GetType(), @"E[a-z]\D{1}", allowContentElements);
202+
var regexResult = WpfVisualFinders.FindDirectChildByType(origin, expected.GetType(), @"E[a-z]\D{1}", allowContentElements);
203203
Assert.Same(namedResult, regexResult);
204204

205205
// Test extension method with named target and regex:
@@ -209,7 +209,7 @@ void Inspect(FrameworkElement tree)
209209
Assert.Same(namedResult, regexExtensionResult);
210210
}
211211

212-
WPFAppTester.RunTestInWindow(Inspect, xaml);
212+
WpfAppTester.RunTestInWindow(Inspect, xaml);
213213
}
214214
#endregion
215215

@@ -242,9 +242,9 @@ void Inspect(FrameworkElement tree)
242242
x is FrameworkContentElement asFce && Regex.IsMatch(asFce.Name, ".*[A-Z]ibling.*"));
243243

244244
// Build generic methods manually, since the type to seek might change for each data set:
245-
var methodInfo = typeof(WPFVisualFinders).GetMethod("FindAllChildren");
245+
var methodInfo = typeof(WpfVisualFinders).GetMethod("FindAllChildren");
246246
var method = methodInfo?.MakeGenericMethod(targetType);
247-
var extMethodInfo = typeof(WPFVisualFindersExtensions).GetMethod("FindAllChildren");
247+
var extMethodInfo = typeof(WpfVisualFindersExtensions).GetMethod("FindAllChildren");
248248
var extMethod = extMethodInfo?.MakeGenericMethod(targetType);
249249

250250
// Test unnamed:
@@ -272,15 +272,15 @@ void Inspect(FrameworkElement tree)
272272
Assert.Equal(result, extensionResult);
273273

274274
// Test regex pattern on similar types named "SimilarSiblings":
275-
result = WPFVisualFinders.FindAllChildrenByType(origin, targetType, ".*[A-Z]ibling.*", allowContentElements);
275+
result = WpfVisualFinders.FindAllChildrenByType(origin, targetType, ".*[A-Z]ibling.*", allowContentElements);
276276
Assert.Equal(expectedRegex, result);
277277

278278
// Test extension with regex pattern:
279279
extensionResult = origin.FindAllChildrenByType(targetType, ".*[A-Z]ibling.*", allowContentElements);
280280
Assert.Equal(result, extensionResult);
281281
}
282282

283-
WPFAppTester.RunTestInWindow(Inspect, xaml);
283+
WpfAppTester.RunTestInWindow(Inspect, xaml);
284284
}
285285
#endregion
286286

@@ -310,7 +310,7 @@ void Inspect(FrameworkElement tree)
310310
x is FrameworkContentElement asFce && Regex.IsMatch(asFce.Name, ".*[A-Z]ibling.*"));
311311

312312
// Test unnamed:
313-
var result = WPFVisualFinders.FindAllChildrenByType(origin, targetType, allowContentElements: allowContentElements).ToArray();
313+
var result = WpfVisualFinders.FindAllChildrenByType(origin, targetType, allowContentElements: allowContentElements).ToArray();
314314
Assert.Equal(expected, result);
315315
if (relatedInPath && (allowContentElements || !hasContentElementInPath))
316316
Assert.Contains(expectedSpecificItem, result);
@@ -321,7 +321,7 @@ void Inspect(FrameworkElement tree)
321321
Assert.Equal(result, extensionResult);
322322

323323
// Test named:
324-
result = WPFVisualFinders.FindAllChildrenByType(origin, targetType, "End", allowContentElements).ToArray();
324+
result = WpfVisualFinders.FindAllChildrenByType(origin, targetType, "End", allowContentElements).ToArray();
325325
Assert.Equal(expectedNamed, result);
326326
if (relatedInPath && (allowContentElements || !hasContentElementInPath))
327327
Assert.Contains(expectedSpecificItem, result);
@@ -332,15 +332,15 @@ void Inspect(FrameworkElement tree)
332332
Assert.Equal(result, extensionResult);
333333

334334
// Test regex pattern on similar types named "SameSibling":
335-
result = WPFVisualFinders.FindAllChildrenByType(origin, targetType, ".*[A-Z]ibling.*", allowContentElements).ToArray();
335+
result = WpfVisualFinders.FindAllChildrenByType(origin, targetType, ".*[A-Z]ibling.*", allowContentElements).ToArray();
336336
Assert.Equal(expectedRegex, result);
337337

338338
// Test extension with regex pattern:
339339
extensionResult = origin.FindAllChildrenByType(targetType, ".*[A-Z]ibling.*", allowContentElements);
340340
Assert.Equal(result, extensionResult);
341341
}
342342

343-
WPFAppTester.RunTestInWindow(Inspect, xaml);
343+
WpfAppTester.RunTestInWindow(Inspect, xaml);
344344
}
345345
#endregion
346346
}

ExtendedWPFVisualTreeHelper.Tests/Tests/FindParentsTests.cs renamed to ExtendedWPFVisualTreeHelper.Tests/FindParentsTests.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ void Inspect(FrameworkElement tree)
1919
var hasContentElementInPath = TestData.HasContentElementWithin(xaml);
2020

2121
// Build generic methods manually, since the type to seek might change for each data set:
22-
var methodInfo = typeof(WPFVisualFinders).GetMethod("FindParent");
22+
var methodInfo = typeof(WpfVisualFinders).GetMethod("FindParent");
2323
var method = methodInfo?.MakeGenericMethod(expected.GetType());
24-
var extMethodInfo = typeof(WPFVisualFindersExtensions).GetMethod("FindParent");
24+
var extMethodInfo = typeof(WpfVisualFindersExtensions).GetMethod("FindParent");
2525
var extMethod = extMethodInfo?.MakeGenericMethod(expected.GetType());
2626

2727
// Test unnamed:
@@ -56,7 +56,7 @@ void Inspect(FrameworkElement tree)
5656
Assert.Same(namedResult, regexExtensionResult);
5757
}
5858

59-
WPFAppTester.RunTestInWindow(Inspect, xaml);
59+
WpfAppTester.RunTestInWindow(Inspect, xaml);
6060
}
6161
#endregion
6262

@@ -73,7 +73,7 @@ void Inspect(FrameworkElement tree)
7373
var hasContentElementInPath = TestData.HasContentElementWithin(xaml);
7474

7575
// Test unnamed:
76-
var result = WPFVisualFinders.FindParentByType(origin, expected.GetType(), allowContentElements: allowContentElements);
76+
var result = WpfVisualFinders.FindParentByType(origin, expected.GetType(), allowContentElements: allowContentElements);
7777
if (relatedInPath && (allowContentElements || !hasContentElementInPath))
7878
{
7979
if (!hasSimilarTypeInPath) // should find destination if not caught a similar type.
@@ -88,13 +88,13 @@ void Inspect(FrameworkElement tree)
8888
Assert.Same(result, extensionResult);
8989

9090
// Test named:
91-
var namedResult = WPFVisualFinders.FindParentByType(origin, expected.GetType(), "End", allowContentElements);
91+
var namedResult = WpfVisualFinders.FindParentByType(origin, expected.GetType(), "End", allowContentElements);
9292
if (relatedInPath && (allowContentElements || !hasContentElementInPath)) // should always find if related in path
9393
Assert.Same(expected, namedResult);
9494
else Assert.Null(result);
9595

9696
// Test with regex:
97-
var regexResult = WPFVisualFinders.FindParentByType(origin, expected.GetType(), @"E[a-z]\D{1}", allowContentElements);
97+
var regexResult = WpfVisualFinders.FindParentByType(origin, expected.GetType(), @"E[a-z]\D{1}", allowContentElements);
9898
Assert.Same(namedResult, regexResult);
9999

100100
// Test extension method with named target and regex:
@@ -104,7 +104,7 @@ void Inspect(FrameworkElement tree)
104104
Assert.Same(namedResult, regexExtensionResult);
105105
}
106106

107-
WPFAppTester.RunTestInWindow(Inspect, xaml);
107+
WpfAppTester.RunTestInWindow(Inspect, xaml);
108108
}
109109
#endregion
110110

@@ -123,7 +123,7 @@ void Inspect(FrameworkElement tree)
123123
var hasContentElementInPath = TestData.HasContentElementWithin(xaml);
124124

125125
// Test bare method:
126-
var result = WPFVisualFinders.FindParentByLevel(origin, level, allowContentElements);
126+
var result = WpfVisualFinders.FindParentByLevel(origin, level, allowContentElements);
127127
if (relatedInPath && (allowContentElements || !hasContentElementInPath))
128128
Assert.Equal(expected, result);
129129
else Assert.NotEqual(expected, result); // may find something close but not our target.
@@ -133,7 +133,7 @@ void Inspect(FrameworkElement tree)
133133
Assert.Same(result, extensionResult);
134134
}
135135

136-
WPFAppTester.RunTestInWindow(Inspect, xaml);
136+
WpfAppTester.RunTestInWindow(Inspect, xaml);
137137
}
138138
#endregion
139139

@@ -155,7 +155,7 @@ void Inspect(FrameworkElement tree)
155155
do
156156
{
157157
var currentNode = parent;
158-
parent = WPFVisualFinders.GetParentExtended(currentNode);
158+
parent = WpfVisualFinders.GetParentExtended(currentNode);
159159

160160
var parentExt = currentNode.GetParentExtended();
161161
Assert.Equal(parent, parentExt);
@@ -167,7 +167,7 @@ void Inspect(FrameworkElement tree)
167167
Assert.Equal(relatedInPath, foundExpected);
168168
}
169169

170-
WPFAppTester.RunTestInWindow(Inspect, xaml);
170+
WpfAppTester.RunTestInWindow(Inspect, xaml);
171171
}
172172
#endregion
173173
}
File renamed without changes.

ExtendedWPFVisualTreeHelper.Tests/TestUtils/WPFAppTester.cs renamed to ExtendedWPFVisualTreeHelper.Tests/Utils/WpfAppTester.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace EMA.ExtendedWPFVisualTreeHelper.Tests.Utils
1212
/// <summary>
1313
/// Offers ways to run a test from a dedicated <see cref="Window"/>.
1414
/// </summary>
15-
public static class WPFAppTester
15+
public static class WpfAppTester
1616
{
1717
/// <summary>
1818
/// Parses a Xaml content.
@@ -31,9 +31,9 @@ public static object LoadFromXaml(string xaml)
3131
/// </summary>
3232
/// <param name="testMethod">Test method to be invoked. The window content will be injected as <see cref="FrameworkElement"/> parameter.</param>
3333
/// <param name="windowContent">Content of the window, should be a raw Xaml content as string or a valid content for the window.</param>
34-
/// <param name="hide_window">Optionally shows generated window for the tests.</param>
35-
/// <param name="timeout_ms">Optionally sets a timeout in milliseconds to be triggered for abnormally pending tests.</param>
36-
public static void RunTestInWindow(Action<FrameworkElement> testMethod, object windowContent, bool show_window = false, int timeout_ms = 200000)
34+
/// <param name="showWindow">Optionally shows generated window for the tests.</param>
35+
/// <param name="timeoutMs">Optionally sets a timeout in milliseconds to be triggered for abnormally pending tests.</param>
36+
public static void RunTestInWindow(Action<FrameworkElement> testMethod, object windowContent, bool showWindow = false, int timeoutMs = 200000)
3737
{
3838
var exceptionInfo = (ExceptionDispatchInfo)null;
3939

@@ -45,7 +45,7 @@ public static void RunTestInWindow(Action<FrameworkElement> testMethod, object w
4545
Content = windowContent is string xaml ? LoadFromXaml(xaml) : windowContent
4646
};
4747

48-
if (!show_window)
48+
if (!showWindow)
4949
{
5050
window.Height = window.Width = 0;
5151
window.ShowInTaskbar = false;
@@ -57,7 +57,7 @@ public static void RunTestInWindow(Action<FrameworkElement> testMethod, object w
5757
{
5858
try
5959
{
60-
testMethod.Invoke((FrameworkElement)window);
60+
testMethod.Invoke(window);
6161
}
6262
catch (Exception e) // register any exception during test execution
6363
{
@@ -76,7 +76,7 @@ public static void RunTestInWindow(Action<FrameworkElement> testMethod, object w
7676
testThread.Start();
7777

7878
// Timeout if worker is not ending quickly enough:
79-
var joined = testThread.Join(TimeSpan.FromMilliseconds(timeout_ms));
79+
var joined = testThread.Join(TimeSpan.FromMilliseconds(timeoutMs));
8080
Assert.True(joined, "Test thread did not respond");
8181

8282
// Rethrow exception caught in our worker if any:

ExtendedWPFVisualTreeHelper/ExtendedWPFVisualTreeHelper.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<PackageDescription>A compilation of useful WPF visual tree helper methods.</PackageDescription>
77
<PackageTags>WPF;Visual Tree;VisualTreeHelper</PackageTags>
88
<UseWPF>true</UseWPF>
9-
<Version>2.0.1</Version>
9+
<Version>2.0.2</Version>
1010
<Authors>David Le Bourdais</Authors>
1111
<Copyright>Copyright © 2019-2020</Copyright>
1212
<PackageLicenseExpression>MIT</PackageLicenseExpression>

ExtendedWPFVisualTreeHelper/WPFVisualFinders.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace EMA.ExtendedWPFVisualTreeHelper
1313
/// Provides a set of helpers to navigate a visual tree and either find
1414
/// a specific child or parent of a dependency object.
1515
/// </summary>
16-
public static class WPFVisualFinders
16+
public static class WpfVisualFinders
1717
{
1818
#region Find children
1919
/// <summary>
@@ -34,7 +34,7 @@ public static T FindChild<T>(DependencyObject node, string name = null, bool all
3434
if (node is Visual || node is Visual3D)
3535
{
3636
var childrenCount = VisualTreeHelper.GetChildrenCount(node);
37-
for (int i = 0; i < childrenCount; i++)
37+
for (var i = 0; i < childrenCount; i++)
3838
{
3939
var child = VisualTreeHelper.GetChild(node, i);
4040

0 commit comments

Comments
 (0)