dotnet / dotnet/wpf

[Cleanup] Replace comments with named arguments

Open
#10,018 1 comment 7 reactions 1 assignee Claimed by @ThomasGoulet73 View on GitHub
Work Item
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

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](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/named-and-optional-arguments)).

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.