Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use DpiAwarenessContext.SystemAware when creating Tool Windows. #934

Merged
merged 1 commit into from
Jun 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -109,6 +110,7 @@ public ITextTemplatingSession CreateSession()
return new TextTemplatingSession();
}

[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious, what object is disposable here? Engine? Asking because the warning may be flagging an actual bug in our code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, Engine. That code has been like that for multiple major versions - so it's stable and I'd rather not destabilize it while trying to fix this urgent issue. Plus we have many suppressions like this - so it's a more general task to go through the code and remove them.

public string ProcessTemplate(string inputFile, string content, ITextTemplatingCallback callback = null)
{
Debug.Assert(!string.IsNullOrEmpty(inputFile), "inputFile is null or empty.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions src/EFTools/EntityDesignPackage/EntityDesignPackage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
</PropertyGroup>
<Import Project="$(RepositoryRoot)tools\EFToolsVsReferences.settings.targets" />
<ItemGroup>
<Reference Condition="'$(VisualStudioVersion)' == '16.0'" Include="Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime, Version=14.0.0.0">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.$(VisualStudioVersion15)" />
<Reference Condition="'$(VisualStudioVersion)' == '16.0'" Include="Microsoft.VisualStudio.Shell.Framework" />
<Reference Include="Microsoft.VisualStudio.Package.LanguageService.$(VisualStudioVersion15)" />
Expand All @@ -66,11 +69,15 @@
<Reference Include="Microsoft.VisualStudio.Shell.Interop.11.0" />
<Reference Condition="'$(VisualStudioVersion)' != '11.0' AND '$(VisualStudioVersion)' != '12.0' AND '$(VisualStudioVersion)' != '14.0'"
Include="Microsoft.VisualStudio.Shell.Interop.15.3.DesignTime" />
<Reference Condition="'$(VisualStudioVersion)' == '16.0'" Include="Microsoft.VisualStudio.Shell.Interop.14.0.DesignTime, Version=14.0.0.0">
Copy link
Contributor

Choose a reason for hiding this comment

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

I am a bit surprised that we pull the 14.0 version of the assemblies for the 16.0 version of VS? Shouldn't the major version numbers match?

Also, is it ok to have Microsoft.VisualStudio.Shell.Interop.15.3.DesignTime (per the previous line) and Microsoft.VisualStudio.Shell.Interop.14.0.DesignTime added as references at the same time? It seems both conditions apply if the version of VS is 16.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The 14.0 version is required in the fix published by the PMA team for this (which is specifically for 16.0 VS onwards). I agree that 15.3 and 14.0 is weird but does not appear to cause any problems and taking out 15.3 would require extensive re-testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And note, 15.3 by itself did not work.

<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.11.0" />
<Reference Include="Microsoft.VisualStudio.DataDesign.Interfaces" />
<Reference Include="Microsoft.VisualStudio.ComponentModelHost" />
<Reference Include="Microsoft.VisualStudio.TemplateWizardInterface" />
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0" />
<Reference Condition="$(VisualStudioVersion)!='11.0' AND $(VisualStudioVersion)!='12.0'" Include="Microsoft.VisualStudio.Utilities" />
<Reference Include="Accessibility" />
<Reference Include="System" />
<Reference Include="System.Xaml" />
Expand Down