Skip to content

Commit

Permalink
Remove file-scoped namespaces to fix CI issues
Browse files Browse the repository at this point in the history
Also fix a non matching filename
  • Loading branch information
Sergio0694 committed May 25, 2022
1 parent ac35875 commit ba85e32
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 86 deletions.
71 changes: 36 additions & 35 deletions Microsoft.Toolkit.Uwp.Notifications/Common/EnumFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,52 @@

#nullable enable

namespace Microsoft.Toolkit.Uwp.Notifications;

/// <summary>
/// A helper class that can be used to format <see cref="Enum"/> values.
/// </summary>
internal static class EnumFormatter
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// Returns a <see cref="string"/> representation of an enum value with pascal casing.
/// A helper class that can be used to format <see cref="Enum"/> values.
/// </summary>
/// <typeparam name="T">The <see cref="Enum"/> type to format.</typeparam>
/// <param name="value">The <typeparamref name="T"/> value to format.</param>
/// <returns>The pascal case <see cref="string"/> representation of <paramref name="value"/>.</returns>
public static string? ToPascalCaseString<T>(this T? value)
where T : unmanaged, Enum
internal static class EnumFormatter
{
if (value is null)
/// <summary>
/// Returns a <see cref="string"/> representation of an enum value with pascal casing.
/// </summary>
/// <typeparam name="T">The <see cref="Enum"/> type to format.</typeparam>
/// <param name="value">The <typeparamref name="T"/> value to format.</param>
/// <returns>The pascal case <see cref="string"/> representation of <paramref name="value"/>.</returns>
public static string? ToPascalCaseString<T>(this T? value)
where T : unmanaged, Enum
{
return null;
if (value is null)
{
return null;
}

return ToPascalCaseString(value.Value);
}

return ToPascalCaseString(value.Value);
}
/// <summary>
/// Returns a <see cref="string"/> representation of an enum value with pascal casing.
/// </summary>
/// <typeparam name="T">The <see cref="Enum"/> type to format.</typeparam>
/// <param name="value">The <typeparamref name="T"/> value to format.</param>
/// <returns>The pascal case <see cref="string"/> representation of <paramref name="value"/>.</returns>
public static string? ToPascalCaseString<T>(this T value)
where T : unmanaged, Enum
{
string? text = value.ToString();

/// <summary>
/// Returns a <see cref="string"/> representation of an enum value with pascal casing.
/// </summary>
/// <typeparam name="T">The <see cref="Enum"/> type to format.</typeparam>
/// <param name="value">The <typeparamref name="T"/> value to format.</param>
/// <returns>The pascal case <see cref="string"/> representation of <paramref name="value"/>.</returns>
public static string? ToPascalCaseString<T>(this T value)
where T : unmanaged, Enum
{
string? text = value.ToString();
if (text is null or { Length: 0 })
{
return text;
}

if (text is null or { Length: 0 })
{
return text;
}
if (text is { Length: 1 })
{
return text.ToLowerInvariant();
}

if (text is { Length: 1 })
{
return text.ToLowerInvariant();
return $"{char.ToLowerInvariant(text[0])}{text.Substring(1)}";
}

return $"{char.ToLowerInvariant(text[0])}{text.Substring(1)}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@

#nullable enable

namespace Microsoft.Toolkit.Uwp.Notifications;

/// <summary>
/// An interface for a notification XML element with additional properties.
/// </summary>
internal interface IHaveXmlAdditionalProperties
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// Gets the mapping of additional properties.
/// An interface for a notification XML element with additional properties.
/// </summary>
IReadOnlyDictionary<string, string> AdditionalProperties { get; }
}
internal interface IHaveXmlAdditionalProperties
{
/// <summary>
/// Gets the mapping of additional properties.
/// </summary>
IReadOnlyDictionary<string, string> AdditionalProperties { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@

#nullable enable

namespace Microsoft.Toolkit.Uwp.Notifications;

/// <summary>
/// An interface for a notification XML element with additional children.
/// </summary>
internal interface IHaveXmlChildren
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// Gets the children of the current element.
/// An interface for a notification XML element with additional children.
/// </summary>
IEnumerable<object> Children { get; }
internal interface IHaveXmlChildren
{
/// <summary>
/// Gets the children of the current element.
/// </summary>
IEnumerable<object> Children { get; }
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace Microsoft.Toolkit.Uwp.Notifications;

/// <summary>
/// An interface for a notification XML element with a name.
/// </summary>
internal interface IHaveXmlName
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// Gets the name of the current element.
/// An interface for a notification XML element with a name.
/// </summary>
string Name { get; }
internal interface IHaveXmlName
{
/// <summary>
/// Gets the name of the current element.
/// </summary>
string Name { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@

#nullable enable

namespace Microsoft.Toolkit.Uwp.Notifications;

/// <summary>
/// An interface for a notification XML element with named properties.
/// </summary>
internal interface IHaveXmlNamedProperties
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// Enumerates the available named properties for the element.
/// An interface for a notification XML element with named properties.
/// </summary>
/// <returns>A sequence of named properties for the element.</returns>
/// <remarks>The returned values must be valid XML values when <see cref="object.ToString"/> is called on them.</remarks>
IEnumerable<KeyValuePair<string, object?>> EnumerateNamedProperties();
internal interface IHaveXmlNamedProperties
{
/// <summary>
/// Enumerates the available named properties for the element.
/// </summary>
/// <returns>A sequence of named properties for the element.</returns>
/// <remarks>The returned values must be valid XML values when <see cref="object.ToString"/> is called on them.</remarks>
IEnumerable<KeyValuePair<string, object?>> EnumerateNamedProperties();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// An interface for a notification XML element with an explicit XML text content.
/// </summary>
internal interface IHaveXmlText
{
/// <summary>
/// Gets the text content of the current element.
/// </summary>
string Text { get; }
}
}

0 comments on commit ba85e32

Please sign in to comment.