Move some usings to globals - #14331
Merged
Merged
Conversation
They're used in a ton of files. Minor cleanup.
Contributor
There was a problem hiding this comment.
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, andSystem.Runtime.InteropServices.Marshalling. - Removed now-redundant
usingdirectives 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. |
JeremyKuhne
enabled auto-merge (squash)
February 25, 2026 18:28
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
They're used in a ton of files. Minor cleanup.
Microsoft Reviewers: Open in CodeFlow