Skip to content

[Cleanup] Use named arguments in PresentationFramework #10671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ThomasGoulet73
Copy link
Contributor

@ThomasGoulet73 ThomasGoulet73 commented Mar 29, 2025

Contributes to #10018

Description

I replaced comments specifying an argument name with named arguments, which were introduced in C# 7. This improves readability and maintainability.

My changes are in 2 commits. The first commit is automated changes using regexes and the second commit is manual changes where the comment is outdated or formatted differently than the parameter name.

Note: The compiled IL is identical.

Customer Impact

None.

Regression

No.

Testing

Local build + validated IL.

Risk

Low to none.

Microsoft Reviewers: Open in CodeFlow

@ThomasGoulet73 ThomasGoulet73 requested review from a team as code owners March 29, 2025 04:12
@dotnet-policy-service dotnet-policy-service bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Mar 29, 2025
Copy link

codecov bot commented Mar 29, 2025

Codecov Report

Attention: Patch coverage is 0.11211% with 891 lines in your changes missing coverage. Please review.

Project coverage is 11.22373%. Comparing base (2a8258a) to head (e5e0cd4).

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #10671         +/-   ##
===================================================
- Coverage   11.25210%   11.22373%   -0.02838%     
===================================================
  Files           3353        3353                 
  Lines         668062      668058          -4     
  Branches       74980       74980                 
===================================================
- Hits           75171       74981        -190     
- Misses        591642      591833        +191     
+ Partials        1249        1244          -5     
Flag Coverage Δ
Debug 11.22373% <0.11211%> (-0.02838%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -91,7 +91,7 @@ internal void ActivateDynamicBehavior(EditingBehavior dynamicBehavior, InputDevi
//we pass true for userInitiated because we've simply consulted the InputDevice
//(and only StylusDevice or MouseDevice) for the current position of the device
InitializeCapture(inputDevice, (IStylusEditing)dynamicBehavior,
true /*userInitiated*/, false/*Don't reset the RTI*/);
userInitiated: true, false/*Don't reset the RTI*/);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears like you missed one here, Don't reset the RTI -> resetDynamicRenderer

Copy link
Contributor

@jizc jizc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more. Some may be on purpose, but I though it best to point them out. One appears to be an error that wasn't caught because it's inside a preprocessor directive.

@@ -3405,7 +3405,7 @@ private void RaiseEventForFormerFirstIMEVisibleNode(TextTreeNode node)

// Next node was the old first node. Its IMECharCount
// just bumped up, report that.
AddChange(startEdgePosition, /* symbolCount */ 0, /* IMECharCount */ 1, PrecursorTextChangeType.ContentAdded);
AddChange(startEdgePosition, symbolCount: 0, /* IMECharCount */ 1, PrecursorTextChangeType.ContentAdded);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMECharCount -> charCount

@@ -3417,7 +3417,7 @@ private void RaiseEventForNewFirstIMEVisibleNode(TextTreeNode node)

// node was the old second node. Its IMECharCount
// just dropped down, report that.
AddChange(startEdgePosition, /* symbolCount */ 0, /* IMECharCount */ 1, PrecursorTextChangeType.ContentRemoved);
AddChange(startEdgePosition, symbolCount: 0, /* IMECharCount */ 1, PrecursorTextChangeType.ContentRemoved);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMECharCount -> charCount

@@ -415,7 +415,7 @@ internal void TargetOnDragOver(DragEventArgs e)
Brush caretBrush = TextSelection.GetCaretBrush(_textEditor);

// Show the caret on the dropable position.
_caretDragDrop.Update(/*visible:*/true, caretRectangle, caretBrush, 0.5, italic, CaretScrollMethod.None, /*wordWrappingPosition*/ double.NaN);
_caretDragDrop.Update(visible: true, caretRectangle, caretBrush, 0.5, italic, CaretScrollMethod.None, /*wordWrappingPosition*/ double.NaN);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wordWrappingPosition -> scrollToOriginPosition

@@ -1180,7 +1180,7 @@ internal static TextRange InsertRows(TextRange textRange, int rowCount)
{
// Create new cell and transfer all formatting properties to it from a source cell.
// All properties except for RowSpan will be transferred.
AddCellCopy(newRow, currentCell, -1/*negative means at the endPosition*/, /*copyRowSpan:*/false, /*copyColumnSpan:*/true);
AddCellCopy(newRow, currentCell, -1/*negative means at the endPosition*/, copyRowSpan: false, copyColumnSpan: true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this was skipped on purpose, but if not: negative means at the endPosition -> cellInsertionIndex

@@ -150,7 +150,7 @@ internal override void OnEndEdit(UnsafeNativeMethods.ITfContext context,

#if UNUSED_IME_HIGHLIGHT_LAYER
// Need to pass the foreground and background color of the composition
_highlightLayer.Add(start, end, /*TextDecorationCollection:*/null);
_highlightLayer.Add(start, end, TextDecorationCollection: null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be an error, the parameter is textDecorations

}

protected override XamlMember LookupAttachableMember(string name)
{
return FindMember(name, true /* isAttached */, false /* skipReadOnlyCheck doens't matter for Attached */);
return FindMember(name, isAttached: true, false /* skipReadOnlyCheck doens't matter for Attached */);
Copy link
Contributor

@jizc jizc Mar 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May have been skipped on purpose, but maybe change it to skipReadOnlyCheck: false /* doens't matter for Attached */

@dotnet-policy-service dotnet-policy-service bot added the 📭 waiting-author-feedback To request more information from author. label Mar 30, 2025
@@ -447,7 +447,7 @@ internal List<AutomationPeer> GetCellItemPeers()

if (column != null)
{
DataGridCellItemAutomationPeer peer = GetOrCreateCellItemPeer(column,/*addParentInfo*/ false );
DataGridCellItemAutomationPeer peer = GetOrCreateCellItemPeer(column,addParentInfo: false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: spacing

Copy link
Contributor

@jizc jizc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing nits, feel free to ignore

@@ -894,7 +894,7 @@ internal static Rect GetCharacterRect(ITextPointer thisPointer, LogicalDirection
}
else if (thisPointer.TextContainer.Parent is Visual)
{
Invariant.Assert(textView.RenderScope == thisPointer.TextContainer.Parent || ((Visual)thisPointer.TextContainer.Parent).IsAncestorOf( /*descendant:*/textView.RenderScope),
Invariant.Assert(textView.RenderScope == thisPointer.TextContainer.Parent || ((Visual)thisPointer.TextContainer.Parent).IsAncestorOf( descendant: textView.RenderScope),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: spacing

@@ -903,10 +903,10 @@ internal static Rect GetCharacterRect(ITextPointer thisPointer, LogicalDirection
templatedParent = null;
}

if (templatedParent != null && templatedParent.IsAncestorOf( /*descendant:*/textView.RenderScope))
if (templatedParent != null && templatedParent.IsAncestorOf( descendant: textView.RenderScope))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: spacing

@@ -628,7 +628,7 @@ internal bool InDeferredSection
#if !PBTCOMPILER
internal ParserContext ScopedCopy()
{
return ScopedCopy( true /* copyNameScopeStack */ );
return ScopedCopy( copyNameScopeStack: true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: spacing

@@ -218,7 +218,7 @@ internal int Read(byte[] buffer, int offset, int count)
int bufferIndex;

byte[] readBuffer = GetBufferFromFilePosition(
ReadPosition,true /*reader*/,
ReadPosition,reader: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: spacing

@@ -4777,7 +4777,7 @@ private static void DeferActions( TriggerBase triggerBase,
if( !deferredActions.TryGetValue(triggerContainer, out actionList) )
{
actionList = new List<DeferredAction>();
deferredActions.Add(/* key */triggerContainer,/* value */actionList);
deferredActions.Add(key: triggerContainer,value: actionList);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: spacing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Contribution A label for all community Contributions 📭 waiting-author-feedback To request more information from author. PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants