Skip to content

Commit

Permalink
Add WPF test
Browse files Browse the repository at this point in the history
  • Loading branch information
dfederm committed Mar 27, 2024
1 parent f2c15ea commit 57d1e3e
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Tests/E2ETests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,14 @@ await RunMSBuildAsync(
expectUnusedMsvcLibrariesLog: true);
}

[TestMethod]
public Task WpfApp()
{
return RunMSBuildAsync(
projectFile: "WpfApp/WpfApp.csproj",
expectedWarnings: Array.Empty<Warning>());
}

private static (string ExePath, string Verb) GetMsBuildExeAndVerb()
{
// On Windows, try to find Visual Studio
Expand Down
7 changes: 7 additions & 0 deletions src/Tests/TestData/WpfApp/Dependency/Dependency.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Dependency
{
public static class Foo
{
public static string Bar() => "Baz";
}
}
8 changes: 8 additions & 0 deletions src/Tests/TestData/WpfApp/Dependency/Dependency.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

</Project>
9 changes: 9 additions & 0 deletions src/Tests/TestData/WpfApp/WpfApp/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="WpfApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApp"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
15 changes: 15 additions & 0 deletions src/Tests/TestData/WpfApp/WpfApp/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Configuration;
using System.Data;
using System.Windows;

namespace WpfApp
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
// Use the dependency
public string X = Dependency.Foo.Bar();
}
}
10 changes: 10 additions & 0 deletions src/Tests/TestData/WpfApp/WpfApp/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Windows;

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
12 changes: 12 additions & 0 deletions src/Tests/TestData/WpfApp/WpfApp/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Window x:Class="WpfApp.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:WpfApp"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>

</Grid>
</Window>
24 changes: 24 additions & 0 deletions src/Tests/TestData/WpfApp/WpfApp/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApp
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}
15 changes: 15 additions & 0 deletions src/Tests/TestData/WpfApp/WpfApp/WpfApp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="../Dependency/Dependency.csproj" />
</ItemGroup>

</Project>

0 comments on commit 57d1e3e

Please sign in to comment.