Skip to content

Commit 11c3644

Browse files
committed
apply feedback from Yanni and update copilot instructions to account for formatting
1 parent a52611e commit 11c3644

File tree

2 files changed

+46
-50
lines changed

2 files changed

+46
-50
lines changed

.github/copilot-instructions.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ Coding Style and Changes:
22
- Code should match the style of the file it's in.
33
- Changes should be minimal to resolve a problem in a clean way.
44
- User-visible changes to behavior should be considered carefully before committing. They should always be flagged.
5+
- When generating code, run `dotnet format` to ensure uniform formatting.
6+
- Prefer using file-based namespaces for new code.
7+
- Do not allow unused `using` directives to be committed.
58

69
Testing:
710
- Large changes should always include test changes.
Lines changed: 43 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,54 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using Microsoft.Build.Framework;
5-
using NuGet.RuntimeModel;
4+
namespace Microsoft.NET.Build.Tasks;
65

7-
namespace Microsoft.NET.Build.Tasks
6+
/// <summary>
7+
/// This task uses the given RID graph in a given SDK to pick the best match from among a set of supported RIDs for the current RID
8+
/// </summary>
9+
public sealed class PickBestRid : TaskBase
810
{
911
/// <summary>
10-
/// This task uses the given RID graph in a given SDK to pick the best match from among a set of supported RIDs for the current RID
12+
/// The path to the RID graph to read
1113
/// </summary>
12-
public sealed class PickBestRid : TaskBase
14+
[Required]
15+
public string RuntimeGraphPath { get; set; } = "";
16+
17+
/// <summary>
18+
/// The RID to find the best fit for
19+
/// </summary>
20+
[Required]
21+
public string TargetRid { get; set; } = "";
22+
23+
/// <summary>
24+
/// All of the RIDs that are allowed to match against the <see cref="TargetRid"/>
25+
/// </summary>
26+
[Required]
27+
public string[] SupportedRids { get; set; } = Array.Empty<string>();
28+
29+
/// <summary>
30+
/// The RID from among <see cref="SupportedRids"/> that best matches the <see cref="TargetRid"/>, if any.
31+
/// </summary>
32+
[Output]
33+
public string? MatchingRid { get; set; }
34+
35+
protected override void ExecuteCore()
1336
{
14-
/// <summary>
15-
/// The path to the RID graph to read
16-
/// </summary>
17-
[Required]
18-
public string RuntimeGraphPath { get; set; } = "";
19-
20-
/// <summary>
21-
/// The RID to find the best fit for
22-
/// </summary>
23-
[Required]
24-
public string TargetRid { get; set; } = "";
25-
26-
/// <summary>
27-
/// All of the RIDs that are allowed to match against the Target RID
28-
/// </summary>
29-
[Required]
30-
public string[] SupportedRids { get; set; } = Array.Empty<string>();
31-
32-
/// <summary>
33-
/// The solution to the puzzle
34-
/// </summary>
35-
[Output]
36-
public string? MatchingRid { get; set; }
37-
38-
/// <summary>
39-
/// Finds the best matching RID from the supported RIDs using the runtime graph.
40-
/// </summary>
41-
protected override void ExecuteCore()
37+
if (!File.Exists(RuntimeGraphPath))
4238
{
43-
if (!File.Exists(RuntimeGraphPath))
44-
{
45-
Log.LogError(Strings.RuntimeGraphFileDoesNotExist, RuntimeGraphPath);
46-
return;
47-
}
48-
49-
RuntimeGraph graph = new RuntimeGraphCache(this).GetRuntimeGraph(RuntimeGraphPath);
50-
string bestRidForPlatform = NuGetUtils.GetBestMatchingRid(graph, TargetRid, SupportedRids, out bool wasInGraph);
51-
52-
if (!wasInGraph || bestRidForPlatform == null)
53-
{
54-
Log.LogError(Strings.UnableToFindMatchingRid, TargetRid, string.Join(",", SupportedRids), RuntimeGraphPath);
55-
return;
56-
}
57-
58-
MatchingRid = bestRidForPlatform;
39+
Log.LogError(Strings.RuntimeGraphFileDoesNotExist, RuntimeGraphPath);
40+
return;
5941
}
42+
43+
RuntimeGraph graph = new RuntimeGraphCache(this).GetRuntimeGraph(RuntimeGraphPath);
44+
string bestRidForPlatform = NuGetUtils.GetBestMatchingRid(graph, TargetRid, SupportedRids, out bool wasInGraph);
45+
46+
if (!wasInGraph || bestRidForPlatform == null)
47+
{
48+
Log.LogError(Strings.UnableToFindMatchingRid, TargetRid, string.Join(",", SupportedRids), RuntimeGraphPath);
49+
return;
50+
}
51+
52+
MatchingRid = bestRidForPlatform;
6053
}
61-
}
54+
}

0 commit comments

Comments
 (0)