Skip to content

Commit

Permalink
fix: Fix default immutable array (+ docs + namespace update)
Browse files Browse the repository at this point in the history
  • Loading branch information
dr1rrb committed Oct 4, 2024
1 parent d73066d commit 8904cbd
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/Uno.UI.RemoteControl.Host/Extensibility/AddIns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Uno.UI.RemoteControl.Host.Extensibility;

public class AddIns
{
private static ILogger _log = typeof(AddIns).Log();
private static readonly ILogger _log = typeof(AddIns).Log();

public static IImmutableList<string> Discover(string solutionFile)
{
Expand All @@ -30,7 +30,7 @@ public static IImmutableList<string> Discover(string solutionFile)
_log.Log(LogLevel.Warning, new Exception(result.error), $"Failed to get target frameworks of solution '{solutionFile}' (cf. inner exception for details).");
}

return new ImmutableArray<string>();
return ImmutableArray<string>.Empty;
}


Expand Down Expand Up @@ -64,7 +64,7 @@ public static IImmutableList<string> Discover(string solutionFile)
_log.Log(LogLevel.Information, $"Didn't find any add-ins for solution '{solutionFile}'.");
}

return ImmutableList<string>.Empty;
return ImmutableArray<string>.Empty;
}

private static IEnumerable<string> GetConfigurationValue(string msbuildResult, string nodeName)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Linq;
using Microsoft.AspNetCore.Hosting;
using Uno.Extensions.DependencyInjection;
using Uno.Utils.DependencyInjection;
using Uno.UI.RemoteControl.Helpers;

namespace Uno.UI.RemoteControl.Host.Extensibility;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,26 @@
using System.Linq;
using System.Reflection;

namespace Uno.Extensions.DependencyInjection;
namespace Uno.Utils.DependencyInjection;

internal static class AttributeDataExtensions
{
/// <summary>
/// Attempts to create an instance of the specified <typeparamref name="TAttribute"/> type from the provided <see cref="CustomAttributeData"/>.
/// </summary>
/// <remarks>This offers the ability to a project to implements their own compatible version of the given <typeparamref name="TAttribute"/> type to reduce dependencies.</remarks>
/// <param name="data">Data of an attribute.</param>
/// <returns>An instance of <typeparamref name="TAttribute"/> if the provided <paramref name="data"/> was compatible, `null` otherwise.</returns>
public static TAttribute? TryCreate<TAttribute>(this CustomAttributeData data)
=> (TAttribute?)TryCreate(data, typeof(TAttribute));

/// <summary>
/// Attempts to create an instance of the specified <paramref name="attribute"/> type from the provided <see cref="CustomAttributeData"/>.
/// </summary>
/// <remarks>This offers the ability to a project to implements their own compatible version of the given <paramref name="attribute"/> type to reduce dependencies.</remarks>
/// <param name="data">Data of an attribute.</param>
/// <param name="attribute">Type of the attribute to try to instantiate.</param>
/// <returns>An instance of <paramref name="attribute"/> if the provided <paramref name="data"/> was compatible, `null` otherwise.</returns>
public static object? TryCreate(this CustomAttributeData data, Type attribute)
{
if ((!data.AttributeType.FullName?.Equals(attribute.FullName, StringComparison.Ordinal)) ?? true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Linq;
using Microsoft.Extensions.DependencyInjection;

namespace Uno.Extensions.DependencyInjection;
namespace Uno.Utils.DependencyInjection;

/// <summary>
/// Attribute to define a service registration in the service collection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Uno.Extensions;

namespace Uno.Extensions.DependencyInjection;
namespace Uno.Utils.DependencyInjection;

public static class ServiceCollectionServiceExtensions
{
Expand Down

0 comments on commit 8904cbd

Please sign in to comment.