Skip to content

Move some usings to globals - #14331

Merged
JeremyKuhne merged 1 commit into
dotnet:mainfrom
JeremyKuhne:globally
Feb 25, 2026
Merged

JeremyKuhne merged 1 commit into
dotnet:mainfrom
JeremyKuhne:globally

Conversation

@JeremyKuhne

@JeremyKuhne JeremyKuhne commented Feb 25, 2026

Copy link
Copy Markdown
Member

They're used in a ton of files. Minor cleanup.

Microsoft Reviewers: Open in CodeFlow

They're used in a ton of files. Minor cleanup.
@JeremyKuhne
JeremyKuhne requested a review from a team as a code owner February 25, 2026 18:01
@github-actions github-actions Bot added the area-Clipboard Issues related to Clipboard label Feb 25, 2026
@JeremyKuhne
JeremyKuhne requested review from Copilot and removed request for a team February 25, 2026 18:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR centralizes frequently used System.Runtime.* namespaces into src/System.Private.Windows.Core/src/GlobalUsings.cs, allowing many source files (notably Win32/COM interop and internal helpers) to drop repeated per-file using directives.

Changes:

  • Added global usings for System.Runtime.CompilerServices, System.Runtime.InteropServices, and System.Runtime.InteropServices.Marshalling.
  • Removed now-redundant using directives across Win32 interop, COM, OLE, BinaryFormat, and core utility files.

Reviewed changes

Copilot reviewed 66 out of 66 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/System.Private.Windows.Core/src/Windows/Win32/UI/WindowsAndMessaging/ICONDIRENTRY.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/UI/WindowsAndMessaging/ICONDIR.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/System/Variant/VARIANTVector.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/System/Variant/VARIANT.cs Removed redundant using System.Runtime.CompilerServices; and using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/System/Com/WinFormsComWrappers.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/System/Com/WinFormsComStrategy.cs Removed redundant interop-related usings (now global).
src/System.Private.Windows.Core/src/Windows/Win32/System/Com/SafeArrayScope.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/System/Com/SAFEARRAY.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/System/Com/Lifetime.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/System/Com/IUnknown.CCW.cs Removed redundant using System.Runtime.CompilerServices; / using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/System/Com/IID.cs Removed redundant using System.Runtime.CompilerServices; / using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/System/Com/IDispatch.Interface.cs Removed redundant using System.Runtime.CompilerServices; / using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/System/Com/IComCallableWrapper.cs Removed redundant using System.Runtime.CompilerServices; / using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/System/Com/GlobalInterfaceTable.cs Removed redundant using System.Runtime.InteropServices.Marshalling; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/System/Com/GlobalInterfaceTable.UnknownStrategy.cs Removed redundant using System.Runtime.InteropServices.Marshalling; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/System/Com/ComScope.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/System/Com/ComManagedStream.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/System/Com/ComInterfaceTable.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/System/Com/ComHelpers.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/PInvokeCore.SetWindowLong.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/PInvokeCore.SetClassLong.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/PInvokeCore.PrintDlgEx.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/PInvokeCore.GetWindowText.cs Removed redundant compiler services + conditional interop usings (now global).
src/System.Private.Windows.Core/src/Windows/Win32/PInvokeCore.GetWindowLong.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/PInvokeCore.GetClassLong.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/PInvokeCore.EnumWindows.cs Removed redundant using System.Runtime.CompilerServices; / using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/PInvokeCore.EnumThreadWindows.cs Removed redundant using System.Runtime.CompilerServices; / using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/PInvokeCore.EnumDisplayMonitors.cs Removed redundant using System.Runtime.CompilerServices; / using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/PInvokeCore.EnumChildWindows.cs Removed redundant using System.Runtime.CompilerServices; / using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/Graphics/GdiPlus/StatusExtensions.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/Graphics/Gdi/HDC.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/Graphics/Gdi/ArgbBuffer.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/Graphics/Gdi/ARGB.cs Removed redundant using System.Runtime.CompilerServices; / using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/Foundation/PWSTR.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/Foundation/IHandle.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/Foundation/HandleRef.cs Removed redundant using System.Runtime.CompilerServices; / using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/Foundation/GlobalBuffer.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/Windows/Win32/Foundation/BSTR.cs Removed redundant using System.Runtime.CompilerServices; / using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/System/Value.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/System/Value.Union.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/System/Value.TypeFlag.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/System/Value.StraightCastFlag.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/System/Value.PackedColor.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/System/Value.NullableTemplate.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/System/Text/ValueStringBuilder.cs Removed redundant using System.Runtime.CompilerServices; / using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/System/SpanWriter.cs Removed redundant using System.Runtime.CompilerServices; / using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/System/SpanReader.cs Removed redundant using System.Runtime.CompilerServices; / using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/System/Private/Windows/OsVersion.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/System/Private/Windows/Ole/FormatEnumerator.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/System/Private/Windows/Ole/DragDropHelper.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/System/Private/Windows/Ole/DragDropFormat.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/System/Private/Windows/Ole/Composition.NativeToRuntimeAdapter.cs Removed redundant using System.Runtime.CompilerServices; / using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/System/Private/Windows/Ole/Composition.NativeToManagedAdapter.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/System/Private/Windows/JsonData.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/System/Private/Windows/CoreAppContextSwitches.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/System/Private/Windows/BinaryFormat/Deserializer/ObjectRecordDeserializer.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/System/Private/Windows/BinaryFormat/Deserializer/Deserializer.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/System/Private/Windows/BinaryFormat/Deserializer/ClassRecordDeserializer.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/System/Private/Windows/BinaryFormat/BinaryFormatWriter.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/System/IO/BinaryWriterExtensions.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/System/IO/BinaryReaderExtensions.cs Removed redundant using System.Runtime.CompilerServices; / using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/System/Collections/Generic/ArrayBuilder.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/System/BufferScope.cs Removed redundant using System.Runtime.InteropServices; (now global).
src/System.Private.Windows.Core/src/System/ArgumentValidation.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/Properties/AssemblyInfo.cs Removed redundant using System.Runtime.CompilerServices; (now global).
src/System.Private.Windows.Core/src/GlobalUsings.cs Added global usings for compiler services + interop namespaces to support the cleanup.

@Shyam-Gupta Shyam-Gupta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good.

@JeremyKuhne
JeremyKuhne enabled auto-merge (squash) February 25, 2026 18:28
@codecov

codecov Bot commented Feb 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.23168%. Comparing base (d65e8b0) to head (8d45f0f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #14331         +/-   ##
===================================================
- Coverage   77.23556%   77.23168%   -0.00389%     
===================================================
  Files           3279        3279                 
  Lines         645107      645107                 
  Branches       47731       47731                 
===================================================
- Hits          498252      498227         -25     
- Misses        143161      143183         +22     
- Partials        3694        3697          +3     
Flag Coverage Δ
Debug 77.23168% <ø> (-0.00389%) ⬇️
integration 19.08272% <ø> (-0.00803%) ⬇️
production 52.15860% <ø> (-0.00870%) ⬇️
test 97.41577% <ø> (ø)
unit 49.54694% <ø> (-0.00487%) ⬇️

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.

@JeremyKuhne
JeremyKuhne merged commit 7ea6398 into dotnet:main Feb 25, 2026
14 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-Clipboard Issues related to Clipboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants