dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.08k stars 1.17k forks source link

[Cleanup] Replace comments with named arguments #10018

Open ThomasGoulet73 opened 2 weeks ago

ThomasGoulet73 commented 2 weeks ago

In the codebase, there are a lot of comments specifying an argument value is for what argument when calling a method. These comments were probably written before "Named Arguments" were introduced in C# 7 (Documentation).

Here's an example of code that could use named arguments instead of comments: https://github.com/dotnet/wpf/blob/86ef9ee8e3988a5fdf423551851f16c1a0f81ecc/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlType.cs#L340

Replacing them would make the code more readable and improve the maintainability. It would improve maintainability because renaming the argument in the called method without renaming the named arguments in the calls to said method would break the build instead of making the comments innacurate (Some comments in the code base are already innacurate).

Unfortunately, it's not easy to automate this change. Some comments are to explain the value instead of naming the argument and some comments are innacurate (E.g.: The argument was renamed), this means that it requires some manual work. I'm able to make it work with a couple of regexes and some manual edits.

ThomasGoulet73 commented 2 weeks ago

I assigned this to myself since I plan on working on it. I already did it for a couple of projects locally but I wanted to open the issue for tracking and to have people's opinion.