Skip to content

Commit 14880e3

Browse files
author
msftbot[bot]
authored
Refactor namespaces for extension types (#3743)
## Related to #3422 <!-- Add the relevant issue number after the "#" mentioned above (for ex: Fixes #1234) which will automatically close the issue once the PR is merged. --> <!-- Add a brief overview here of the feature/bug & fix. --> ## PR Type What kind of change does this PR introduce? <!-- Please uncomment one or more that apply to this PR. --> <!-- - Bugfix --> <!-- - Feature --> <!-- - Code style update (formatting) --> - Refactoring <!-- - Build or CI related changes --> <!-- - Documentation content changes --> <!-- - Sample app changes --> <!-- - Other... Please describe: --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying, or link to a relevant issue. --> Quoting from #3422 (comment), we have the current situation with respect to extension methods in the Toolkit: > On a related note - lately I've been thinking a bit about the various extensions in the toolkit in particular. @mrlacey already pointed this out in the first post in this issue, and I agree that that inconsistency is a bit weird, especially now that newer packages have started to just place them in their respective root namespaces. Basically we have the following situation: > > - `Microsoft.Toolkit.Extensions` (from `Microsoft.Toolkit`)❌ > - `Microsoft.Toolkit.Extensions` (from `Microsoft.Toolkit.Diagnostics`*) ❌ > - `Microsoft.Toolkit.HighPerformance.Extensions` ❌ > - `Microsoft.Toolkit.Mvvm.Messaging` ✅ > - `Microsoft.Toolkit.Uwp.Extensions` ❌ > - `Microsoft.Toolkit.Uwp.UI.Extensions` ❌ > - `Microsoft.Toolkit.Uwp.UI.Animations` ✅ > - `Microsoft.Toolkit.Uwp.UI.Media`** ✅ ## What is the new behavior? <!-- Describe how was this issue resolved or changed? --> This PR moves all the extensions (including XAML markup extensions) to the root namespace of each package. It also fixes some related issues like inconsistent naming, incorrect method locations, etc. ## Open questions Some extension types now have a number of properties that are only relevant when grouped together, as they refer a specific feature. For instance, all the SurfaceDial properties in `TextBoxExtensions`, or the ones related to Regex. @michael-hawker mentioned the "option" pattern that the Graph Controls have been using, which would look something like this: ```xml <TextBox> <ui:TextBoxExtentions.SurfaceDial> <ui:SurfaceDialOptions MinValue="0" MaxValue="10" EnableHapticFeedback="True" ... /> </ui:TextBoxExtensions.SurfaceDial> </TextBox> ``` Do we want to make this change as well while we're at it? Thoughts? 🙂 ## Additional details Haven't fully tested all the samples in the sample app just yet, have just focused on ensuring everything built fine for now. Also, this PR is based on top of #3685, which needs to be merged before this one. ## PR Checklist Please check if your PR fulfills the following requirements: - [X] Tested code with current [supported SDKs](../readme.md#supported) - [ ] ~~Pull Request has been submitted to the documentation repository [instructions](..\contributing.md#docs). Link: <!-- docs PR link -->~~ - [ ] ~~Sample in sample app has been added / updated (for bug fixes / features)~~ - [ ] ~~Icon has been created (if new sample) following the [Thumbnail Style Guide and templates](https://github.com/windows-toolkit/WindowsCommunityToolkit-design-assets)~~ - [X] New major technical changes in the toolkit have or will be added to the [Wiki](https://github.com/windows-toolkit/WindowsCommunityToolkit/wiki) e.g. build changes, source generators, testing infrastructure, sample creation changes, etc... - [X] Tests for the changes have been added (for bug fixes / features) (if applicable) - [X] Header has been added to all new source files (run *build/UpdateHeaders.bat*) - [ ] Contains **NO** breaking changes
2 parents 2c88fd3 + 743dc0f commit 14880e3

File tree

341 files changed

+902
-1269
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

341 files changed

+902
-1269
lines changed

Microsoft.Toolkit.Diagnostics/Extensions/TypeExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#endif
1212
using System.Runtime.CompilerServices;
1313

14-
namespace Microsoft.Toolkit.Extensions
14+
namespace Microsoft.Toolkit.Diagnostics
1515
{
1616
/// <summary>
1717
/// Helpers for working with types.

Microsoft.Toolkit.Diagnostics/Extensions/ValueTypeExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using System.Runtime.CompilerServices;
88
using System.Runtime.InteropServices;
99

10-
namespace Microsoft.Toolkit.Extensions
10+
namespace Microsoft.Toolkit.Diagnostics
1111
{
1212
/// <summary>
1313
/// Helpers for working with value types.

Microsoft.Toolkit.Diagnostics/Generated/ThrowHelper.Collection.g.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System;
99
using System.Collections.Generic;
1010
using System.Diagnostics.CodeAnalysis;
11-
using Microsoft.Toolkit.Extensions;
1211

1312
namespace Microsoft.Toolkit.Diagnostics
1413
{

Microsoft.Toolkit.Diagnostics/Generated/ThrowHelper.Collection.tt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System;
66
using System.Collections.Generic;
77
using System.Diagnostics.CodeAnalysis;
8-
using Microsoft.Toolkit.Extensions;
98

109
namespace Microsoft.Toolkit.Diagnostics
1110
{

Microsoft.Toolkit.Diagnostics/Guard.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
using System.Diagnostics;
77
using System.Diagnostics.CodeAnalysis;
88
using System.Runtime.CompilerServices;
9-
#if NETSTANDARD1_4
10-
using Microsoft.Toolkit.Extensions;
11-
#endif
129

1310
namespace Microsoft.Toolkit.Diagnostics
1411
{

Microsoft.Toolkit.Diagnostics/Internals/Guard.Collection.Generic.ThrowHelper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
using System;
66
using System.Diagnostics.CodeAnalysis;
7-
using Microsoft.Toolkit.Extensions;
87

98
namespace Microsoft.Toolkit.Diagnostics
109
{

Microsoft.Toolkit.Diagnostics/Internals/Guard.Comparable.Generic.ThrowHelper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
using System;
66
using System.Diagnostics.CodeAnalysis;
7-
using Microsoft.Toolkit.Extensions;
87

98
namespace Microsoft.Toolkit.Diagnostics
109
{

Microsoft.Toolkit.Diagnostics/Internals/Guard.Comparable.Numeric.ThrowHelper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
using System;
66
using System.Diagnostics.CodeAnalysis;
7-
using Microsoft.Toolkit.Extensions;
87

98
namespace Microsoft.Toolkit.Diagnostics
109
{

Microsoft.Toolkit.Diagnostics/Internals/Guard.IO.ThrowHelper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System;
66
using System.Diagnostics.CodeAnalysis;
77
using System.IO;
8-
using Microsoft.Toolkit.Extensions;
98

109
namespace Microsoft.Toolkit.Diagnostics
1110
{

Microsoft.Toolkit.Diagnostics/Internals/Guard.Tasks.ThrowHelper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System;
66
using System.Diagnostics.CodeAnalysis;
77
using System.Threading.Tasks;
8-
using Microsoft.Toolkit.Extensions;
98

109
namespace Microsoft.Toolkit.Diagnostics
1110
{

0 commit comments

Comments
 (0)