Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Global Usings and aliases to reduce #ifdef usage #285

Open
michael-hawker opened this issue Nov 15, 2024 · 0 comments
Open

Use Global Usings and aliases to reduce #ifdef usage #285

michael-hawker opened this issue Nov 15, 2024 · 0 comments

Comments

@michael-hawker
Copy link
Contributor

I noticed a number of ifdefs just for doc comments like so:

#if WinUI
    /// <summary>
    /// An action that will change the state of the specified <seealso cref="Microsoft.UI.Xaml.Media.Animation.Storyboard"/> when executed.
    /// </summary>
#else
    /// <summary>
    /// An action that will change the state of the specified <seealso cref="Windows.UI.Xaml.Media.Animation.Storyboard"/> when executed.
    /// </summary>
#endif

As well as many at the top of files:

#if WinUI
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media.Animation;
#else
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media.Animation;
#endif

By using global usings and aliasing, we can reduce this duplication within the project. References:

By moving the general Microsoft/Windows usings to the csproj as globals, this can remove the namespaces at the top of each file making it cleaner to maintain and get to the functional code.

By using aliases, if not in the csproj at the top, it can make it easier to maintain comments for classes. See after here:

// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Diagnostics.CodeAnalysis;

// This could also be moved to alias in csproj if desired... as we don't have too many unique types for these or they are commonly used otherwise.
#if WinUI
using Storyboard = Microsoft.UI.Xaml.Media.Animation.Storyboard;
#else
using Storyboard = Windows.UI.Xaml.Media.Animation.Storyboard;
#endif

namespace Microsoft.Xaml.Interactivity
{
    /// <summary>
    /// An action that will change the state of the specified <seealso cref="Storyboard"/> when executed.
    /// </summary>
    public sealed class ControlStoryboardAction : DependencyObject, IAction
    {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant