From eea876618a5f5efe24cae8ad2361ed2d80f4a05a Mon Sep 17 00:00:00 2001 From: h3xds1nz Date: Fri, 9 Aug 2024 20:31:07 +0200 Subject: [PATCH 1/5] remove unnecessary split allocation, return extensions as ROS --- .../Microsoft/Win32/FileDialog.cs | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs index ca5e661559f..befb9e12b09 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs @@ -19,9 +19,21 @@ // deferred to the derived classes. // +using MS.Internal; +using MS.Internal.AppModel; +using MS.Internal.Interop; + + +using System.Runtime.InteropServices; +using System.Collections.Generic; +using System.ComponentModel; +using System.Windows; +using System.IO; +using System; namespace Microsoft.Win32 { + /// /// Provides a common base class for wrappers around both the /// File Open and File Save common dialog boxes. Derives from @@ -312,11 +324,11 @@ public string Filter set { - if (String.CompareOrdinal(value, _filter) != 0) // different filter than what we have stored already + if (!string.Equals(value, _filter, StringComparison.Ordinal)) // different filter than what we have stored already { string updatedFilter = value; - if (!String.IsNullOrEmpty(updatedFilter)) + if (!string.IsNullOrEmpty(updatedFilter)) { // Require the number of segments of the filter string to be even - // in other words, there must only be matched pairs of description and @@ -584,7 +596,7 @@ private bool ProcessFileNames() // a list of valid extensions from the filter(s). // The first extension from FilterExtensions is the // default extension. - string[] extensions = GetFilterExtensions(); + ReadOnlySpan extensions = GetFilterExtensions(); // For each filename: // - Process AddExtension @@ -600,15 +612,14 @@ private bool ProcessFileNames() for (int j = 0; j < extensions.Length; j++) { // Assert for a valid extension - Invariant.Assert(!extensions[j].StartsWith(".", StringComparison.Ordinal), + Invariant.Assert(!extensions[j].StartsWith('.'), "FileDialog.GetFilterExtensions should not return things starting with '.'"); string currentExtension = Path.GetExtension(fileName); // Assert to make sure Path.GetExtension behaves as we think it should, returning // "" if the string is empty and something beginnign with . otherwise. - // Use StringComparison.Ordinal as per FxCop CA1307 and CA130. - Invariant.Assert(currentExtension.Length == 0 || currentExtension.StartsWith(".", StringComparison.Ordinal), + Invariant.Assert(currentExtension.Length == 0 || currentExtension.StartsWith('.'), "Path.GetExtension should return something that starts with '.'"); // Because we check Path.HasExtension above, files should @@ -620,7 +631,7 @@ private bool ProcessFileNames() // of the filename in s. string newFilename; - if (((ReadOnlySpan)extensions[j]).IndexOfAny('*', '?') != -1) + if (extensions[j].AsSpan().IndexOfAny('*', '?') != -1) { // we don't want to append the extension if it contains wild cards newFilename = fileName.Substring(0, fileName.Length - currentExtension.Length); @@ -708,10 +719,10 @@ private static COMDLG_FILTERSPEC[] GetFilterItems(string filter) /// /// Thrown if the filter string stored in the dialog is invalid. /// - private string[] GetFilterExtensions() + private ReadOnlySpan GetFilterExtensions() { - string filter = this._filter; - List extensions = new List(); + string filter = _filter; + List extensions = new(); // Always make the default extension the first in the list, // because other functions process files in order accepting the first @@ -756,27 +767,27 @@ private string[] GetFilterExtensions() { // Find our filter in the tokens list, then split it on the // ';' character (which is the filter extension delimiter) - string[] exts = tokens[indexOfExtension].Split(';'); + ReadOnlySpan exts = tokens[indexOfExtension].AsSpan(); - foreach (string ext in exts) + foreach (Range ext in exts.Split(';')) { // Filter extensions should be in the form *.txt or .txt, // so we strip out everything before and including the '.' // before adding the extension to our list. // If the extension has no '.', we just ignore it as invalid. - int i = ext.LastIndexOf('.'); + int i = exts[ext].LastIndexOf('.'); if (i >= 0) { - // start the substring one beyond the location of the '.' + // start the slice one beyond the location of the '.' // (i) and continue to the end of the string - extensions.Add(ext.Substring(i + 1, ext.Length - (i + 1))); + extensions.Add(exts[ext].Slice(i + 1, exts[ext].Length - (i + 1)).ToString()); } } } } - return extensions.ToArray(); + return CollectionsMarshal.AsSpan(extensions); } #endregion Private Properties From 1a8ea1bc991c57c16db455d2306868aaa2c7f326 Mon Sep 17 00:00:00 2001 From: h3xds1nz Date: Sun, 18 Aug 2024 16:45:25 +0200 Subject: [PATCH 2/5] remove CAS remarks, finish up with the rest --- .../MS/Internal/AppModel/ShellProvider.cs | 12 +++-- .../Microsoft/Win32/CommonDialog.cs | 15 ++---- .../Microsoft/Win32/CommonItemDialog.cs | 6 +-- .../Microsoft/Win32/FileDialog.cs | 50 +++++++------------ .../Microsoft/Win32/OpenFileDialog.cs | 9 ---- .../Microsoft/Win32/OpenFolderDialog.cs | 3 -- .../Microsoft/Win32/SaveFileDialog.cs | 12 ----- 7 files changed, 34 insertions(+), 73 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ShellProvider.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ShellProvider.cs index 01987ea9e74..f8d0e4aa16b 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ShellProvider.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ShellProvider.cs @@ -24,12 +24,18 @@ namespace MS.Internal.AppModel #region Structs [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct COMDLG_FILTERSPEC + internal readonly struct COMDLG_FILTERSPEC { [MarshalAs(UnmanagedType.LPWStr)] - public string pszName; + public readonly string pszName; [MarshalAs(UnmanagedType.LPWStr)] - public string pszSpec; + public readonly string pszSpec; + + public COMDLG_FILTERSPEC(string name, string spec) + { + pszName = name; + pszSpec = spec; + } } [StructLayout(LayoutKind.Sequential, Pack = 4)] diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonDialog.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonDialog.cs index ff0b4044409..cfdd82a77a7 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonDialog.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonDialog.cs @@ -28,9 +28,6 @@ namespace Microsoft.Win32 /// /// An abstract base class for displaying common dialogs. /// - /// - /// InheritanceDemand for UIPermission (UIPermissionWindow.AllWindows) - /// public abstract class CommonDialog { //--------------------------------------------------- @@ -60,10 +57,7 @@ public abstract class CommonDialog /// performs initialization tasks for all common dialogs and then /// calls RunDialog. /// - /// - /// Callers must have UIPermission(UIPermissionWindow.AllWindows) to call this API. - /// - public virtual Nullable ShowDialog() + public virtual bool? ShowDialog() { CheckPermissionsToShowDialog(); @@ -126,10 +120,7 @@ public virtual Nullable ShowDialog() /// /// Runs a common dialog box, with the owner as the given Window /// - /// - /// Callers must have UIPermission(UIPermissionWindow.AllWindows) to call this API. - /// - public Nullable ShowDialog(Window owner) + public bool? ShowDialog(Window owner) { CheckPermissionsToShowDialog(); @@ -373,7 +364,7 @@ private void MoveToScreenCenter(HandleRef hWnd) // Private variable used to store data for the Tag property private object _userData; - private Thread _thread = Thread.CurrentThread; + private readonly Thread _thread = Thread.CurrentThread; /// /// The owner hwnd passed into the dialog is stored as a private diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonItemDialog.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonItemDialog.cs index 5d1daaee60c..99ad3d809e7 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonItemDialog.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonItemDialog.cs @@ -697,10 +697,10 @@ private protected sealed class VistaDialogEvents : IFileDialogEvents, IDisposabl { public delegate bool OnOkCallback(IFileDialog dialog); - private IFileDialog _dialog; + private readonly IFileDialog _dialog; - private OnOkCallback _okCallback; - uint _eventCookie; + private readonly OnOkCallback _okCallback; + private readonly uint _eventCookie; public VistaDialogEvents(IFileDialog dialog, OnOkCallback okCallback) { diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs index befb9e12b09..af8a4db0e3b 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs @@ -23,7 +23,6 @@ using MS.Internal.AppModel; using MS.Internal.Interop; - using System.Runtime.InteropServices; using System.Collections.Generic; using System.ComponentModel; @@ -193,7 +192,7 @@ public string FileName { // UNDONE : This broke the save file dialog. //string temp = Path.GetFullPath(value); // ensure filename is valid... - MutableItemNames = new string[] { value }; + MutableItemNames = [value]; } } } @@ -281,9 +280,7 @@ public string DefaultExt { if (value != null) { - // Use Ordinal here as per FxCop CA1307 - if (value.StartsWith(".", StringComparison.Ordinal)) // Allow calling code to provide - // extensions like ".ext" - + if (value.StartsWith('.')) // Allow calling code to provide extensions like ".ext" - { value = value.Substring(1); // but strip out the period to leave only "ext" } @@ -310,9 +307,6 @@ public string DefaultExt /// Thrown in the setter if the new filter string does not have an even number of tokens /// separated by the vertical bar character '|' (that is, the new filter string is invalid.) /// - /// - /// Callers must have FileIOPermission(PermissionState.Unrestricted) to call this API. - /// public string Filter { get @@ -337,10 +331,11 @@ public string Filter // This implicitly requires there to be at least one vertical bar in // the filter string - or else formats.Length will be 1, resulting in an // ArgumentException. + int formatsCount = 0; + foreach (Range range in updatedFilter.AsSpan().Split('|')) + formatsCount++; - string[] formats = updatedFilter.Split('|'); - - if (formats.Length % 2 != 0) + if (formatsCount % 2 != 0) { throw new ArgumentException(SR.FileDialogInvalidFilter); } @@ -438,10 +433,7 @@ public bool RestoreDirectory /// protected override void OnItemOk(CancelEventArgs e) { - if (FileOk != null) - { - FileOk(this, e); - } + FileOk?.Invoke(this, e); } #endregion Protected Methods @@ -609,18 +601,17 @@ private bool ProcessFileNames() if (AddExtension && !Path.HasExtension(fileName)) { // Loop through all extensions, starting with the default extension - for (int j = 0; j < extensions.Length; j++) + foreach (string extension in extensions) { // Assert for a valid extension - Invariant.Assert(!extensions[j].StartsWith('.'), - "FileDialog.GetFilterExtensions should not return things starting with '.'"); + Invariant.Assert(!extension.StartsWith('.'), "FileDialog.GetFilterExtensions should not return things starting with '.'"); string currentExtension = Path.GetExtension(fileName); // Assert to make sure Path.GetExtension behaves as we think it should, returning // "" if the string is empty and something beginnign with . otherwise. Invariant.Assert(currentExtension.Length == 0 || currentExtension.StartsWith('.'), - "Path.GetExtension should return something that starts with '.'"); + "Path.GetExtension should return something that starts with '.'"); // Because we check Path.HasExtension above, files should // theoretically not have extensions at this stage - but @@ -631,14 +622,14 @@ private bool ProcessFileNames() // of the filename in s. string newFilename; - if (extensions[j].AsSpan().IndexOfAny('*', '?') != -1) + if (extension.AsSpan().IndexOfAny('*', '?') != -1) { // we don't want to append the extension if it contains wild cards newFilename = fileName.Substring(0, fileName.Length - currentExtension.Length); } else { - newFilename = $"{fileName.AsSpan(0, fileName.Length - currentExtension.Length)}.{extensions[j]}"; + newFilename = $"{fileName.AsSpan(0, fileName.Length - currentExtension.Length)}.{extension}"; } // If FOS_FILEMUSTEXIST is not set, or if it is set but the filename we generated @@ -681,25 +672,22 @@ private static COMDLG_FILTERSPEC[] GetFilterItems(string filter) { // Expecting pipe delimited filter string pairs. // First is the label, second is semi-colon delimited list of extensions. - var extensions = new List(); + COMDLG_FILTERSPEC[] extensions = null; if (!string.IsNullOrEmpty(filter)) { string[] tokens = filter.Split('|'); - if (0 == tokens.Length % 2) + if (tokens.Length % 2 == 0) { - for (int i = 1; i < tokens.Length; i += 2) + extensions = new COMDLG_FILTERSPEC[tokens.Length / 2]; + for (int i = 0; i < extensions.Length; i++) { - extensions.Add( - new COMDLG_FILTERSPEC - { - pszName = tokens[i - 1], - pszSpec = tokens[i], - }); + extensions[i] = new(tokens[i * 2], tokens[i * 2 + 1]); } } } - return extensions.ToArray(); + + return extensions ?? Array.Empty(); } #endregion Private Methods diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/OpenFileDialog.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/OpenFileDialog.cs index f9c60fe0c46..d600202ac80 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/OpenFileDialog.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/OpenFileDialog.cs @@ -61,9 +61,6 @@ public OpenFileDialog() : base() /// /// Thrown if there are no filenames stored in the OpenFileDialog. /// - /// - /// Callers must have FileDialogPermission(FileDialogPermissionAccess.Open) to call this API. - /// public Stream OpenFile() { string filename = CriticalItemName; @@ -85,9 +82,6 @@ public Stream OpenFile() /// /// Thrown if there are no filenames stored in the OpenFileDialog /// - /// - /// Callers must have FileDialogPermission(FileDialogPermissionAccess.Open) to call this API. - /// public Stream[] OpenFiles() { // Cache ItemNames to avoid perf issues as per @@ -124,9 +118,6 @@ public Stream[] OpenFiles() /// /// Resets all properties to their default values. /// - /// - /// Callers must have FileIOPermission(PermissionState.Unrestricted) to call this API. - /// public override void Reset() { diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/OpenFolderDialog.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/OpenFolderDialog.cs index 36a88c43a68..c20a0c6c0de 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/OpenFolderDialog.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/OpenFolderDialog.cs @@ -57,9 +57,6 @@ public OpenFolderDialog() : base() /// /// Resets all properties to their default values. /// - /// - /// Callers must have FileIOPermission(PermissionState.Unrestricted) to call this API. - /// public override void Reset() { base.Reset(); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/SaveFileDialog.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/SaveFileDialog.cs index 70884c5c9c6..fa6bbb7488b 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/SaveFileDialog.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/SaveFileDialog.cs @@ -60,9 +60,6 @@ public SaveFileDialog() : base() /// /// Thrown if there are no filenames stored in the SaveFileDialog. /// - /// - /// Callers must have UIPermission.AllWindows to call this API. - /// public Stream OpenFile() { @@ -87,9 +84,6 @@ public Stream OpenFile() /// /// Resets all properties to their default values. /// - /// - /// Callers must have UIPermission.AllWindows to call this API. - /// public override void Reset() { @@ -124,9 +118,6 @@ public override void Reset() /// Gets or sets a value indicating whether the dialog box prompts the user for /// permission to create a file if the user specifies a file that does not exist. /// - /// - /// Callers must have UIPermission.AllWindows to call this API. - /// public bool CreatePrompt { get; set; } /// @@ -156,9 +147,6 @@ public bool CreateTestFile /// Gets or sets a value indicating whether the Save As dialog box displays a /// warning if the user specifies a file name that already exists. /// - /// - /// Callers must have UIPermission.AllWindows to call this API. - /// public bool OverwritePrompt { get; set; } #endregion Public Properties From fc142784d12087a6847d53224dbd76dadc396c6e Mon Sep 17 00:00:00 2001 From: h3xds1nz Date: Tue, 20 Aug 2024 19:29:52 +0200 Subject: [PATCH 3/5] use MemoryExtensions.Count instead of SpanSplitEnumerator (edwardneal) --- .../PresentationFramework/Microsoft/Win32/FileDialog.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs index af8a4db0e3b..80ca762a51d 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs @@ -329,13 +329,11 @@ public string Filter // file extensions. // // This implicitly requires there to be at least one vertical bar in - // the filter string - or else formats.Length will be 1, resulting in an + // the filter string - or else formatsCount will be 1, resulting in an // ArgumentException. - int formatsCount = 0; - foreach (Range range in updatedFilter.AsSpan().Split('|')) - formatsCount++; + int formatsCount = updatedFilter.AsSpan().Count('|'); - if (formatsCount % 2 != 0) + if (formatsCount % 2 == 0) { throw new ArgumentException(SR.FileDialogInvalidFilter); } From f1ef682c2d082e42fa2e593acdfdb91a2315a69b Mon Sep 17 00:00:00 2001 From: h3xds1nz Date: Thu, 22 Aug 2024 23:41:12 +0200 Subject: [PATCH 4/5] simplify Slice, use ContainsAny instead of IndexAny (halgab) --- .../src/PresentationFramework/Microsoft/Win32/FileDialog.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs index 80ca762a51d..10d39f1ab00 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs @@ -620,7 +620,7 @@ private bool ProcessFileNames() // of the filename in s. string newFilename; - if (extension.AsSpan().IndexOfAny('*', '?') != -1) + if (extension.AsSpan().ContainsAny('*', '?')) { // we don't want to append the extension if it contains wild cards newFilename = fileName.Substring(0, fileName.Length - currentExtension.Length); @@ -767,7 +767,7 @@ private ReadOnlySpan GetFilterExtensions() { // start the slice one beyond the location of the '.' // (i) and continue to the end of the string - extensions.Add(exts[ext].Slice(i + 1, exts[ext].Length - (i + 1)).ToString()); + extensions.Add(exts[ext].Slice(i + 1).ToString()); } } } From e4b63e22bfa52e1be85e86abb8c6df6e8c95bd98 Mon Sep 17 00:00:00 2001 From: h3xds1nz Date: Fri, 31 Jan 2025 11:43:24 +0100 Subject: [PATCH 5/5] Post-merge issues --- .../Microsoft/Win32/CommonDialog.cs | 48 ----------------- .../Microsoft/Win32/CommonItemDialog.cs | 8 --- .../Microsoft/Win32/FileDialog.cs | 40 ++------------ .../Microsoft/Win32/OpenFileDialog.cs | 50 +---------------- .../Microsoft/Win32/OpenFolderDialog.cs | 53 +++---------------- .../Microsoft/Win32/SaveFileDialog.cs | 50 +---------------- 6 files changed, 11 insertions(+), 238 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonDialog.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonDialog.cs index cfdd82a77a7..75626592812 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonDialog.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonDialog.cs @@ -30,14 +30,6 @@ namespace Microsoft.Win32 /// public abstract class CommonDialog { - //--------------------------------------------------- - // - // Constructors - // - //--------------------------------------------------- - //#region Constructors - //#endregion Constructors - //--------------------------------------------------- // // Public Methods @@ -191,14 +183,6 @@ public object Tag #endregion Public Properties - //--------------------------------------------------- - // - // Public Events - // - //--------------------------------------------------- - //#region Public Events - //#endregion Public Events - //--------------------------------------------------- // // Protected Methods @@ -322,38 +306,6 @@ private void MoveToScreenCenter(HandleRef hWnd) #endregion Internal Methods - //--------------------------------------------------- - // - // Internal Properties - // - //--------------------------------------------------- - //#region Internal Properties - //#endregion Internal Properties - - //--------------------------------------------------- - // - // Internal Events - // - //--------------------------------------------------- - //#region Internal Events - //#endregion Internal Events - - //--------------------------------------------------- - // - // Private Methods - // - //--------------------------------------------------- - //#region Private Methods - //#endregion Private Methods - - //--------------------------------------------------- - // - // Protected Properties - // - //--------------------------------------------------- - //#region Protected Properties - //#endregion Protected Properties - //--------------------------------------------------- // // Private Fields diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonItemDialog.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonItemDialog.cs index 99ad3d809e7..aa0a7025867 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonItemDialog.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/CommonItemDialog.cs @@ -500,14 +500,6 @@ private protected string[] CloneItemNames() #endregion Internal Properties - //--------------------------------------------------- - // - // Internal Events - // - //--------------------------------------------------- - //#region Internal Events - //#endregion Internal Events - //--------------------------------------------------- // // Private Methods diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs index 10d39f1ab00..5d907debbc7 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs @@ -2,13 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using MS.Internal; -using MS.Internal.AppModel; -using MS.Internal.Interop; -using System.ComponentModel; -using System.IO; -using System.Windows; - // // // Description: @@ -19,16 +12,13 @@ // deferred to the derived classes. // -using MS.Internal; -using MS.Internal.AppModel; -using MS.Internal.Interop; - using System.Runtime.InteropServices; -using System.Collections.Generic; using System.ComponentModel; +using MS.Internal.AppModel; +using MS.Internal.Interop; using System.Windows; +using MS.Internal; using System.IO; -using System; namespace Microsoft.Win32 { @@ -411,14 +401,6 @@ public bool RestoreDirectory #endregion Public Events - //--------------------------------------------------- - // - // Public Events - // - //--------------------------------------------------- - // #region Public Events - // #endregion Public Events - //--------------------------------------------------- // // Protected Methods @@ -527,22 +509,6 @@ private protected override void RevertItemOk(object state) #endregion - //--------------------------------------------------- - // - // Internal Properties - // - //--------------------------------------------------- - //#region Internal Properties - //#endregion Internal Properties - - //--------------------------------------------------- - // - // Internal Events - // - //--------------------------------------------------- - //#region Internal Events - //#endregion Internal Events - //--------------------------------------------------- // // Private Methods diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/OpenFileDialog.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/OpenFileDialog.cs index d600202ac80..10526c558ea 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/OpenFileDialog.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/OpenFileDialog.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. @@ -195,22 +195,6 @@ public bool Multiselect #endregion Public Properties - //--------------------------------------------------- - // - // Public Events - // - //--------------------------------------------------- - //#region Public Events - //#endregion Public Events - - //--------------------------------------------------- - // - // Protected Methods - // - //--------------------------------------------------- - // #region Protected Methods - // #endregion Protected Methods - //--------------------------------------------------- // // Internal Methods @@ -225,22 +209,6 @@ private protected override IFileDialog CreateDialog() #endregion Internal Methods - //--------------------------------------------------- - // - // Internal Properties - // - //--------------------------------------------------- - //#region Internal Properties - //#endregion Internal Properties - - //--------------------------------------------------- - // - // Internal Events - // - //--------------------------------------------------- - //#region Internal Events - //#endregion Internal Events - //--------------------------------------------------- // // Private Methods @@ -268,21 +236,5 @@ private void Initialize() } #endregion Private Methods - - //--------------------------------------------------- - // - // Private Properties - // - //--------------------------------------------------- - //#region Private Properties - //#endregion Private Properties - - //--------------------------------------------------- - // - // Private Fields - // - //--------------------------------------------------- - //#region Private Fields - //#endregion Private Fields } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/OpenFolderDialog.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/OpenFolderDialog.cs index c20a0c6c0de..14de05150f2 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/OpenFolderDialog.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/OpenFolderDialog.cs @@ -1,13 +1,7 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.ComponentModel; -using System.IO; - -using MS.Internal.AppModel; -using MS.Internal.Interop; - // // // Description: @@ -16,6 +10,11 @@ // additional properties relevant only to folder open dialog. // +using System.ComponentModel; +using MS.Internal.AppModel; +using MS.Internal.Interop; +using System.IO; + namespace Microsoft.Win32 { /// @@ -222,14 +221,6 @@ public bool Multiselect #endregion Public Events - //--------------------------------------------------- - // - // Public Events - // - //--------------------------------------------------- - //#region Public Events - //#endregion Public Events - //--------------------------------------------------- // // Protected Methods @@ -261,22 +252,6 @@ private protected override IFileDialog CreateDialog() #endregion Internal Methods - //--------------------------------------------------- - // - // Internal Properties - // - //--------------------------------------------------- - //#region Internal Properties - //#endregion Internal Properties - - //--------------------------------------------------- - // - // Internal Events - // - //--------------------------------------------------- - //#region Internal Events - //#endregion Internal Events - //--------------------------------------------------- // // Private Methods @@ -306,21 +281,5 @@ private void Initialize() } #endregion Private Methods - - //--------------------------------------------------- - // - // Private Properties - // - //--------------------------------------------------- - //#region Private Properties - //#endregion Private Properties - - //--------------------------------------------------- - // - // Private Fields - // - //--------------------------------------------------- - //#region Private Fields - //#endregion Private Fields } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/SaveFileDialog.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/SaveFileDialog.cs index fa6bbb7488b..286b7735a90 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/SaveFileDialog.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/SaveFileDialog.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. @@ -151,22 +151,6 @@ public bool CreateTestFile #endregion Public Properties - //--------------------------------------------------- - // - // Public Events - // - //--------------------------------------------------- - //#region Public Events - //#endregion Public Events - - //--------------------------------------------------- - // - // Protected Methods - // - //--------------------------------------------------- - //#region Protected Methods - //#endregion Protected Methods - //--------------------------------------------------- // // Internal Methods @@ -238,22 +222,6 @@ private protected override IFileDialog CreateDialog() #endregion Internal Methods - //--------------------------------------------------- - // - // Internal Properties - // - //--------------------------------------------------- - //#region Internal Properties - //#endregion Internal Properties - - //--------------------------------------------------- - // - // Internal Events - // - //--------------------------------------------------- - //#region Internal Events - //#endregion Internal Events - //--------------------------------------------------- // // Private Methods @@ -302,21 +270,5 @@ private bool PromptFileOverwrite(string fileName) } #endregion Private Methods - - //--------------------------------------------------- - // - // Private Properties - // - //--------------------------------------------------- - //#region Private Properties - //#endregion Private Properties - - //--------------------------------------------------- - // - // Private Fields - // - //--------------------------------------------------- - //#region Private Fields - //#endregion Private Fields } }