Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Prev Previous commit
Next Next commit
Update nullable annotations for Required properties to use null! pattern
Co-authored-by: baronfel <[email protected]>
  • Loading branch information
2 people authored and github-actions committed Sep 16, 2025
commit f351342b1ce21ba3f7fdbf1e5574490f332894a1
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ public class SelectRuntimeIdentifierSpecificItems : TaskBase
/// The target runtime identifier to check compatibility against.
/// </summary>
[Required]
public string? TargetRuntimeIdentifier { get; set; }
public string TargetRuntimeIdentifier { get; set; } = null!;

/// <summary>
/// The list of candidate items to filter.
/// </summary>
[Required]
public ITaskItem[]? Items { get; set; }
public ITaskItem[] Items { get; set; } = null!;

/// <summary>
/// The name of the MSBuild metadata to check on each item. Defaults to "RuntimeIdentifier".
Expand All @@ -37,7 +37,7 @@ public class SelectRuntimeIdentifierSpecificItems : TaskBase
/// Path to the RuntimeIdentifierGraph file.
/// </summary>
[Required]
public string? RuntimeIdentifierGraphPath { get; set; }
public string RuntimeIdentifierGraphPath { get; set; } = null!;

/// <summary>
/// The filtered items that are compatible with the target runtime identifier.
Expand All @@ -47,29 +47,15 @@ public class SelectRuntimeIdentifierSpecificItems : TaskBase

protected override void ExecuteCore()
{
if (Items == null || Items.Length == 0)
if (Items.Length == 0)
{
SelectedItems = Array.Empty<ITaskItem>();
return;
}

string targetRid = TargetRuntimeIdentifier ?? string.Empty;
string ridGraphPath = RuntimeIdentifierGraphPath ?? string.Empty;
string ridMetadata = RuntimeIdentifierItemMetadata ?? "RuntimeIdentifier";

if (string.IsNullOrEmpty(targetRid))
{
Log.LogError("TargetRuntimeIdentifier is required but was not provided.");
return;
}

if (string.IsNullOrEmpty(ridGraphPath))
{
Log.LogError("RuntimeIdentifierGraphPath is required but was not provided.");
return;
}

RuntimeGraph runtimeGraph = new RuntimeGraphCache(this).GetRuntimeGraph(ridGraphPath);
RuntimeGraph runtimeGraph = new RuntimeGraphCache(this).GetRuntimeGraph(RuntimeIdentifierGraphPath);

var selectedItems = new List<ITaskItem>();

Expand All @@ -84,7 +70,7 @@ protected override void ExecuteCore()
}

// Check if the item's runtime identifier is compatible with the target runtime identifier
if (runtimeGraph.AreCompatible(targetRid, itemRuntimeIdentifier))
if (runtimeGraph.AreCompatible(TargetRuntimeIdentifier, itemRuntimeIdentifier))
{
selectedItems.Add(item);
}
Expand Down