Skip to content

Commit 07d579b

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

File tree

2 files changed

+47
-48
lines changed

2 files changed

+47
-48
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.

src/Tasks/Microsoft.NET.Build.Tasks/PickBestRid.cs

Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,54 @@
44
using Microsoft.Build.Framework;
55
using NuGet.RuntimeModel;
66

7-
namespace Microsoft.NET.Build.Tasks
7+
namespace Microsoft.NET.Build.Tasks;
8+
9+
/// <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
11+
/// </summary>
12+
public sealed class PickBestRid : TaskBase
813
{
914
/// <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
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 <see cref="TargetRid"/>
28+
/// </summary>
29+
[Required]
30+
public string[] SupportedRids { get; set; } = Array.Empty<string>();
31+
32+
/// <summary>
33+
/// The RID from among <see cref="SupportedRids"/> that best matches the <see cref="TargetRid"/>, if any.
1134
/// </summary>
12-
public sealed class PickBestRid : TaskBase
35+
[Output]
36+
public string? MatchingRid { get; set; }
37+
38+
protected override void ExecuteCore()
1339
{
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()
40+
if (!File.Exists(RuntimeGraphPath))
41+
{
42+
Log.LogError(Strings.RuntimeGraphFileDoesNotExist, RuntimeGraphPath);
43+
return;
44+
}
45+
46+
RuntimeGraph graph = new RuntimeGraphCache(this).GetRuntimeGraph(RuntimeGraphPath);
47+
var bestRidForPlatform = NuGetUtils.GetBestMatchingRid(graph, TargetRid, SupportedRids, out bool wasInGraph);
48+
49+
if (!wasInGraph || bestRidForPlatform == null)
4250
{
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;
51+
Log.LogError(Strings.UnableToFindMatchingRid, TargetRid, string.Join(",", SupportedRids), RuntimeGraphPath);
52+
return;
5953
}
54+
55+
MatchingRid = bestRidForPlatform;
6056
}
61-
}
57+
}

0 commit comments

Comments
 (0)