Skip to content

Commit

Permalink
Application Compatibility Flags Howto Sample for .NET Core (microsoft#87
Browse files Browse the repository at this point in the history
)
  • Loading branch information
vatsan-madhavan authored Jun 20, 2019
1 parent 56aec4c commit bae3a98
Show file tree
Hide file tree
Showing 12 changed files with 987 additions and 549 deletions.
93 changes: 93 additions & 0 deletions Compatibility/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
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.
-->

<!--
This file *must* be named App.config, and not App1.config etc.
-->
<!--
This is the list of application compatibility switches in WPF that are set via App.Config.
The values shown below are the defaults for the respective switch.
-->
<configuration>
<appSettings>
<!-- Defined in System.Windows.CoreCompatibilityPreferences -->

<!--https://docs.microsoft.com/en-us/dotnet/api/system.windows.corecompatibilitypreferences.isaltkeyrequiredinaccesskeydefaultscope?view=netcore-3.0-->
<!--<add key="IsAltKeyRequiredInAccessKeyDefaultScope" value="false"/>-->

<!--https://docs.microsoft.com/en-us/dotnet/api/system.windows.corecompatibilitypreferences.enablemultimonitordisplayclipping?view=netcore-3.0#System_Windows_CoreCompatibilityPreferences_EnableMultiMonitorDisplayClipping-->
<!--<add key="EnableMultiMonitorDisplayClipping" value="null"/>-->

<!--GlyphRun.ComputeInkBoundingBox is supposed to return a box that contains
all the ink in the GlyphRun, but in some circumstances it computes a
box that is too small. This was "fixed" in 4.5 by inflating the box
slightly. Apps that depend on the old non-inflated result can opt out
of the fix by setting this to 'false'-->
<!--<add key="IncludeAllInkInBoundingBox" value="true"/>-->



<!-- Defined in System.Windows.BaseCompatibilityPreferences -->

<!--https://docs.microsoft.com/en-us/dotnet/api/system.windows.basecompatibilitypreferences.reusedispatchersynchronizationcontextinstance?view=netframework-4.8#System_Windows_BaseCompatibilityPreferences_ReuseDispatcherSynchronizationContextInstance-->
<!--<add key="ReuseDispatcherSynchronizationContextInstance" value="false"/>-->

<!--https://docs.microsoft.com/en-us/dotnet/api/system.windows.basecompatibilitypreferences.flowdispatchersynchronizationcontextpriority?view=netframework-4.8#System_Windows_BaseCompatibilityPreferences_FlowDispatcherSynchronizationContextPriority-->
<!--<add key="FlowDispatcherSynchronizationContextPriority" value="true"/>-->

<!--https://docs.microsoft.com/en-us/dotnet/api/system.windows.basecompatibilitypreferences.inlinedispatchersynchronizationcontextsend?view=netframework-4.8#System_Windows_BaseCompatibilityPreferences_InlineDispatcherSynchronizationContextSend-->
<!--<add key="InlineDispatcherSynchronizationContextSend" value="true"/>-->

<!--https://docs.microsoft.com/en-us/dotnet/api/system.windows.basecompatibilitypreferences.handledispatcherrequestprocessingfailure?view=netframework-4.8#System_Windows_BaseCompatibilityPreferences_HandleDispatcherRequestProcessingFailure-->
<!--<add key="HandleDispatcherRequestProcessingFailure" value="Continue"/>-->

<!--Instructs WPF to not attempt to set an equivalent XML package signature method for a given digest hash algorithm.
This affects the signing and digest methods used in the packaging APIs. With this set to false, signature methods
will always be SHA1.-->
<!--<add key="MatchPackageSignatureMethodToPackagePartDigestMethod" value="true"/>-->


<!-- Defined in System.Windows.FrameworkCompatibilityPreferenes -->

<!--https://docs.microsoft.com/en-us/dotnet/api/system.windows.frameworkcompatibilitypreferences.areinactiveselectionhighlightbrushkeyssupported?view=netframework-4.8#System_Windows_FrameworkCompatibilityPreferences_AreInactiveSelectionHighlightBrushKeysSupported-->
<!--<add key="AreInactiveSelectionHighlightBrushKeysSupported" value="true"/>-->

<!--https://docs.microsoft.com/en-us/dotnet/api/system.windows.frameworkcompatibilitypreferences.keeptextboxdisplaysynchronizedwithtextproperty?view=netframework-4.8#System_Windows_FrameworkCompatibilityPreferences_KeepTextBoxDisplaySynchronizedWithTextProperty-->
<!--<add key="KeepTextBoxDisplaySynchronizedWithTextProperty" value="true"/>-->

<!--https://docs.microsoft.com/en-us/dotnet/api/system.windows.frameworkcompatibilitypreferences.shouldthrowoncopyorcutfailure?view=netframework-4.8#System_Windows_FrameworkCompatibilityPreferences_ShouldThrowOnCopyOrCutFailure-->
<!--<add key="ShouldThrowOnCopyOrCutFailure" value="false"/>-->

<!--
Possible values are:
- Throw (.NET 4.0 behavior)
- Allow (default .NET 4.5+, .NET core behavior)
- Disallow
-->
<!--<add key="HandleTwoWayBindingToPropertyWithNonPublicSetter" value="Allow"/>-->

<!--There is a bug in the Windows desktop window manager which can cause
incorrect z-order for windows when several conditions are all met:
(a) windows are parented/owned across different threads or processes
(b) a parent/owner window is also owner of a topmost window (which needn't be visible)
(c) the child window on a different thread/process tries to show an owned topmost window
(like a popup or tooltip) using ShowWindow().
To avoid this window manager bug, this option causes SetWindowPos() to be used instead of
ShowWindow() for topmost windows, avoiding condition (c). Ideally the window manager bug
will be fixed, but the risk of making a change there is considered too great at this time.-->
<!--<add key="UseSetWindowPosForTopmostWindows" value="false"/>-->

<!--VirtualizingStackPanel added support for virtualization-when-grouping in .NET 4.5,
generalizing and subsuming the support for virtualizing a TreeView that existed in .NET 4.0.
The 4.5 algorithm had many flaws, leading to infinite loops, scrolling
to the wrong place, and other bad symptoms. DDCC is worried that fixing
these issues may introduce new compat problems, and asked for a way to opt out
of the fixes. To opt out, set this flag to 'true' in App.Config-->
<!--<add key="VSP45Compat" value="false"/>-->

</appSettings>
</configuration>
14 changes: 14 additions & 0 deletions Compatibility/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!--
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.
-->
<Application x:Class="Wpf_AppCompat_Quirks.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Wpf_AppCompat_Quirks"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
21 changes: 21 additions & 0 deletions Compatibility/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace Wpf_AppCompat_Quirks
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
10 changes: 10 additions & 0 deletions Compatibility/AppCompat-Quirks.netcore.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<OutputType>WinExe</OutputType>
<RootNamespace>AppCompat_Quirks</RootNamespace>
<UseWPF>true</UseWPF>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>

</Project>
14 changes: 14 additions & 0 deletions Compatibility/AppContextInformation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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.

namespace Wpf_AppCompat_Quirks
{
public class CompatSwitchInformation
{
public string Class { get; set; }
public string SwitchName { get; set; }
public string DefaultValue { get; set; }
public string SettingsSource { get; set; }
}
}
27 changes: 27 additions & 0 deletions Compatibility/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
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.
-->
<Window x:Class="Wpf_AppCompat_Quirks.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Wpf_AppCompat_Quirks"
mc:Ignorable="d"
Loaded="Window_Loaded"
Title="Application Compatibility Switches HOWTO Sample" Height="800" Width="900">
<ScrollViewer>
<StackPanel>
<Label>
<TextBlock TextWrapping="Wrap">
See <Run FontWeight="Bold">runtimeconfig.template.json</Run> and <Run FontWeight="Bold">App.config</Run> for a list of supported application compatibility switches, alongwith the respective default values on .NET Core.
</TextBlock>
</Label>
<DataGrid ItemsSource="{Binding AppContextSwitches}" />
<DataGrid ItemsSource="{Binding CompatibilityPreferences}" />
</StackPanel>
</ScrollViewer>

</Window>
Loading

0 comments on commit bae3a98

Please sign in to comment.