From 2e0ba7864a0e9c4f10ccf7d34494b2a466796651 Mon Sep 17 00:00:00 2001 From: lajones Date: Thu, 20 Jun 2019 14:33:25 -0700 Subject: [PATCH] Use DpiAwarenessContext.SystemAware when creating Tool Windows. (#934) --- .../CodeGeneration/Generators/TextTemplatingHost.cs | 2 ++ .../CustomCode/MicrosoftDataEntityDesignPackage.cs | 11 +++++++++-- .../EntityDesignPackage/EntityDesignPackage.csproj | 7 +++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/EFTools/EntityDesign/CodeGeneration/Generators/TextTemplatingHost.cs b/src/EFTools/EntityDesign/CodeGeneration/Generators/TextTemplatingHost.cs index 065682a25e..a4bfb3d3fd 100644 --- a/src/EFTools/EntityDesign/CodeGeneration/Generators/TextTemplatingHost.cs +++ b/src/EFTools/EntityDesign/CodeGeneration/Generators/TextTemplatingHost.cs @@ -4,6 +4,7 @@ using System.CodeDom.Compiler; using System.Collections.Generic; using System.Diagnostics; + using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Text; @@ -109,6 +110,7 @@ public ITextTemplatingSession CreateSession() return new TextTemplatingSession(); } + [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] public string ProcessTemplate(string inputFile, string content, ITextTemplatingCallback callback = null) { Debug.Assert(!string.IsNullOrEmpty(inputFile), "inputFile is null or empty."); diff --git a/src/EFTools/EntityDesignPackage/CustomCode/MicrosoftDataEntityDesignPackage.cs b/src/EFTools/EntityDesignPackage/CustomCode/MicrosoftDataEntityDesignPackage.cs index 1a9ca59695..b1b2f9fac6 100644 --- a/src/EFTools/EntityDesignPackage/CustomCode/MicrosoftDataEntityDesignPackage.cs +++ b/src/EFTools/EntityDesignPackage/CustomCode/MicrosoftDataEntityDesignPackage.cs @@ -22,6 +22,7 @@ namespace Microsoft.Data.Entity.Design.Package using Microsoft.VisualStudio.DataDesign.Interfaces; using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell.Interop; + using Microsoft.VisualStudio.Utilities; using ModelChangeEventArgs = Microsoft.Data.Entity.Design.VisualStudio.Package.ModelChangeEventArgs; [ProvideToolWindow(typeof(EntityDesignExplorerWindow), @@ -478,7 +479,10 @@ public ExplorerWindow ExplorerWindow { if (_explorerWindow == null) { - _explorerWindow = FindToolWindow(typeof(EntityDesignExplorerWindow), 0, true) as ExplorerWindow; + using (DpiAwareness.EnterDpiScope(DpiAwarenessContext.SystemAware)) + { + _explorerWindow = FindToolWindow(typeof(EntityDesignExplorerWindow), 0, true) as ExplorerWindow; + } } return _explorerWindow; } @@ -490,7 +494,10 @@ public MappingDetailsWindow MappingDetailsWindow { if (_mappingDetailsWindow == null) { - _mappingDetailsWindow = GetToolWindow(typeof(MappingDetailsWindow), true) as MappingDetailsWindow; + using (DpiAwareness.EnterDpiScope(DpiAwarenessContext.SystemAware)) + { + _mappingDetailsWindow = GetToolWindow(typeof(MappingDetailsWindow), true) as MappingDetailsWindow; + } } return _mappingDetailsWindow; } diff --git a/src/EFTools/EntityDesignPackage/EntityDesignPackage.csproj b/src/EFTools/EntityDesignPackage/EntityDesignPackage.csproj index d772f33a4e..48dea7f913 100644 --- a/src/EFTools/EntityDesignPackage/EntityDesignPackage.csproj +++ b/src/EFTools/EntityDesignPackage/EntityDesignPackage.csproj @@ -55,6 +55,9 @@ + + True + @@ -66,11 +69,15 @@ + + True + +