Double generic types and members with non-generic equivalents
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 38/100
Hướng nghiên cứu
Bắt đầu bằng việc xem xét API generic ParseResult.GetValue hiện có và các constructor của Option, lấy các overload dựa trên Type được đề xuất làm phạm vi. So sánh pattern này với API DI không generic, sau đó xác minh rằng các phương án thay thế hỗ trợ use case AOT không dùng reflection được nêu, đồng thời vẫn giữ nguyên hành vi generic.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Examples
// In addition to these:
T? ParseResult.GetValue<T>(Option<T> option);
new Option<T>(string name, params string[] aliases);
// etc...
// Make it possible to call them like this:
object? ParseResult.GetValue(Option option, Type valueType);
new Option(Type valueType, string name, params string[] aliases);
This is somewhat similar to what we have in DI:
// We can add service like this:
services.AddSignleton<T>();
// Or this:
services.AddSingleton(Type serviceType);
Justification
I am making my own library that adds proper hosting API, making using System.CommandLine similar to any regular ASP.NET project.
For example:
Program.cs
app.MapCommand("foo", ([Option] FileInfo file) =>
{
foreach (string line in File.ReadLines(file.FullName))
Console.WriteLine(line);
});
ShellApplication.cs
public void MapCommand(string name, Delegate command)
{
RootCommand rootCommand = [];
ParameterInfo[] parameters = command.Method.GetParameters();
foreach (ParameterInfo parameterInfo in parameters)
{
if (parameterInfo.GetCustomAttribute<OptionAttribute>() is not null)
{
Option option = (typeof(Option<>).MakeGenericType(parameterInfo.ParameterType).GetConstructor([typeof(string), typeof(string[])])!.Invoke([name]) as Option)!;
rootCommand.Options.Add(option);
}
}
// etc...
}
At first glance this looks fine – just make a generic type using reflection. Only the problem is that this is not AOT compatible and will cause exceptions. Adding alternatives that accept types as parameters would solve this.
Additional context
I've glossed over the codebase, and it doesn't look like it will be that hard to implement changes. If that's ok with you, I can prepare a PR myself.
- Ngôn ngữ chính
- C#
- Star
- 3.7k
- Fork
- 434
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của dotnet/command-line-api
-
German localization is incompleteCó thể đã có người làm @b-v-d-e-v đã nhận 7 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
dotnet/command-line-api#2852 ·
-
Incomplete French (fr) translation: RequiredOptionWasNotProvided not translatedCó thể đã có người làm @JPBlanc đã nhận 104 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
dotnet/command-line-api#2822 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
dotnet/command-line-api#2792 · 2 bình luận · 15 reaction ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
dotnet/command-line-api#2704 ·
-
GetCompletions should check exit code of invoked applicationCó thể đã có người làm @baradgur đã nhận 1275 ngày trước. Đang mởArea-Completions bug help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
dotnet/command-line-api#2137 · 1 bình luận · 3 reaction ·
Tất cả issue của dotnet/command-line-api
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
stryker-mutator/stryker-net#3892 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
MobiFlight/MobiFlight-Connector#3419 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`Source` with an `avares://` URI and a `#fragment` throws instead of scrolling to the anchorĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Kryptos-FR/MarkView.Avalonia#105 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[辞書]Đang mở提案 辞書
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
microsoft/fluentui-blazor#5410 ·
Maintainer thường phản hồi trong vòng 1 ngày