From bc4db1ec9936e0fe66bdaabeccb3b9bb31d3ab5a Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Wed, 2 Mar 2022 09:29:38 +0100 Subject: [PATCH] fix(FolderPicker): [Skia][WPF] Applied Codacy suggestions --- .../Extensions/Storage/Pickers/FolderPickerExtension.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Uno.UI.Runtime.Skia.Wpf/Extensions/Storage/Pickers/FolderPickerExtension.cs b/src/Uno.UI.Runtime.Skia.Wpf/Extensions/Storage/Pickers/FolderPickerExtension.cs index a4b28732aca0..8b964bd6eab8 100644 --- a/src/Uno.UI.Runtime.Skia.Wpf/Extensions/Storage/Pickers/FolderPickerExtension.cs +++ b/src/Uno.UI.Runtime.Skia.Wpf/Extensions/Storage/Pickers/FolderPickerExtension.cs @@ -12,7 +12,6 @@ namespace Uno.Extensions.Storage.Pickers internal class FolderPickerExtension : IFolderPickerExtension { private readonly FolderPicker _picker; - private WndProc _callback; public Guid? SuggestedStartLocation { get; private set; } @@ -40,9 +39,9 @@ public FolderPickerExtension(FolderPicker owner) NativeMethods.BROWSEINFO pbi = new NativeMethods.BROWSEINFO(); pbi.ulFlags = 0x41; //BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE pbi.pszDisplayName = new string('\0', NativeMethods.MAX_PATH); - _callback = new WndProc(FolderBrowserDialog_BrowseCallbackProc); - var cp = Marshal.GetFunctionPointerForDelegate(_callback); - GC.KeepAlive(_callback); + var callback = new WndProc(FolderBrowserDialog_BrowseCallbackProc); + var cp = Marshal.GetFunctionPointerForDelegate(callback); + GC.KeepAlive(callback); pbi.lpfn = cp; IntPtr pidl = NativeMethods.SHBrowseForFolder(ref pbi); if (pidl != IntPtr.Zero) @@ -116,7 +115,7 @@ private static class NativeMethods private const uint BFFM_SETSELECTIONW = (WM_USER + 103); internal const uint BFFM_ENABLEOK = (WM_USER + 101); internal const uint BFFM_SETOKTEXT = (WM_USER + 105); - internal static uint BFFM_SETSELECTION = Marshal.SystemDefaultCharSize == 1 + internal readonly static uint BFFM_SETSELECTION = Marshal.SystemDefaultCharSize == 1 ? BFFM_SETSELECTIONA : BFFM_SETSELECTIONW; internal const int MAX_PATH = 260;