Merge branch 'master' into feature/win2dparser
This commit is contained in:
Коммит
7360ed979e
|
@ -124,9 +124,6 @@
|
|||
<PackageReference Include="Microsoft.Xaml.Behaviors.Uwp.Managed">
|
||||
<Version>2.0.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Text.Json">
|
||||
<Version>4.7.2</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NotificationsVisualizerLibrary">
|
||||
<Version>1.0.5</Version>
|
||||
</PackageReference>
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// Using a DependencyProperty as the backing store for KeyFrameDuration. This enables animation, styling, binding, etc
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty KeyFrameDurationProperty =
|
||||
DependencyProperty.RegisterAttached("KeyFrameDuration", typeof(TimeSpan), typeof(InAppNotification), new PropertyMetadata(0, OnKeyFrameAnimationChanged));
|
||||
DependencyProperty.RegisterAttached("KeyFrameDuration", typeof(TimeSpan), typeof(InAppNotification), new PropertyMetadata(TimeSpan.Zero, OnKeyFrameAnimationChanged));
|
||||
|
||||
private static void OnKeyFrameAnimationChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="4.7.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Storage;
|
||||
|
||||
|
@ -20,7 +21,9 @@ namespace Microsoft.Toolkit.Uwp.Helpers
|
|||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BaseObjectStorageHelper"/> class,
|
||||
/// which can read and write data using the provided <see cref="IObjectSerializer"/>;
|
||||
/// if none is provided, a default Json serializer will be used.
|
||||
/// if none is provided, a default Json serializer will be used (based on <see cref="DataContractSerializer"/>).
|
||||
/// In 6.1 and older the default Serializer was based on Newtonsoft.Json and the new default Serializer may behave differently.
|
||||
/// To implement a <see cref="IObjectSerializer"/> based on Newtonsoft.Json or System.Text.Json see https://aka.ms/wct/storagehelper-migration
|
||||
/// </summary>
|
||||
/// <param name="objectSerializer">The serializer to use.</param>
|
||||
public BaseObjectStorageHelper(IObjectSerializer objectSerializer = null)
|
||||
|
|
|
@ -2,14 +2,28 @@
|
|||
// 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.Text.Json;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Json;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.Helpers
|
||||
{
|
||||
internal class JsonObjectSerializer : IObjectSerializer
|
||||
{
|
||||
public string Serialize<T>(T value) => JsonSerializer.Serialize(value);
|
||||
public string Serialize<T>(T value)
|
||||
{
|
||||
using var sr = new MemoryStream();
|
||||
|
||||
public T Deserialize<T>(string value) => JsonSerializer.Deserialize<T>(value);
|
||||
new DataContractJsonSerializer(typeof(T)).WriteObject(sr, value);
|
||||
var json = sr.ToArray();
|
||||
return Encoding.UTF8.GetString(json, 0, json.Length);
|
||||
}
|
||||
|
||||
public T Deserialize<T>(string value)
|
||||
{
|
||||
using var ms = new MemoryStream(Encoding.UTF8.GetBytes(value));
|
||||
|
||||
return (T)new DataContractJsonSerializer(typeof(T)).ReadObject(ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// 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.Runtime.Serialization;
|
||||
using Windows.Storage;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.Helpers
|
||||
|
@ -14,7 +15,9 @@ namespace Microsoft.Toolkit.Uwp.Helpers
|
|||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LocalObjectStorageHelper"/> class,
|
||||
/// which can read and write data using the provided <see cref="IObjectSerializer"/>;
|
||||
/// if none is provided, a default Json serializer will be used.
|
||||
/// if none is provided, a default Json serializer will be used (based on <see cref="DataContractSerializer"/>).
|
||||
/// In 6.1 and older the default Serializer was based on Newtonsoft.Json and the new default Serializer may behave differently.
|
||||
/// To implement a <see cref="IObjectSerializer"/> based on Newtonsoft.Json or System.Text.Json see https://aka.ms/wct/storagehelper-migration
|
||||
/// </summary>
|
||||
/// <param name="objectSerializer">The serializer to use.</param>
|
||||
public LocalObjectStorageHelper(IObjectSerializer objectSerializer = null)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// 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.Runtime.Serialization;
|
||||
using Windows.Storage;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.Helpers
|
||||
|
@ -14,7 +15,9 @@ namespace Microsoft.Toolkit.Uwp.Helpers
|
|||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RoamingObjectStorageHelper"/> class,
|
||||
/// which can read and write data using the provided <see cref="IObjectSerializer"/>;
|
||||
/// if none is provided, a default Json serializer will be used.
|
||||
/// if none is provided, a default Json serializer will be used (based on <see cref="DataContractSerializer"/>).
|
||||
/// In 6.1 and older the default Serializer was based on Newtonsoft.Json and the new default Serializer may behave differently.
|
||||
/// To implement a <see cref="IObjectSerializer"/> based on Newtonsoft.Json or System.Text.Json see https://aka.ms/wct/storagehelper-migration
|
||||
/// </summary>
|
||||
/// <param name="objectSerializer">The serializer to use.</param>
|
||||
public RoamingObjectStorageHelper(IObjectSerializer objectSerializer = null)
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
<PackageReference Include="System.Text.Json" Version="4.7.2" />
|
||||
|
||||
<ProjectReference Include="..\Microsoft.Toolkit\Microsoft.Toolkit.csproj" />
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
|
||||
<Library Name="Microsoft.Toolkit.Uwp">
|
||||
<Namespace Name="System.Text.Json.Serialization.Converters" Dynamic="Required All"/>
|
||||
</Library>
|
||||
</Directives>
|
|
@ -6,6 +6,9 @@
|
|||
<!-- When writting the SmokeTests, change this to whichever Toolkit project you want to build a test to, then reload the project -->
|
||||
<CurrentProject>Microsoft.Toolkit.Uwp.UI.Controls</CurrentProject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(NuGetPackageVersion)' == ''">
|
||||
<NuGetPackageVersion>To Fill In With Local Version Number</NuGetPackageVersion>
|
||||
</PropertyGroup>
|
||||
<!-- - - - - - Don't check-in changes in between this lines. Used for development. - - - - - -->
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
|
@ -112,8 +115,8 @@
|
|||
<Version>2.4.3</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(CurrentProject)' != '' and '$(CurrentProject)' != 'UWPBaseline'">
|
||||
<PackageReference Include="$(CurrentProject)" Version="7.*-*" />
|
||||
<ItemGroup Condition="'$(CurrentProject)' != '' and '$(CurrentProject)' != 'UWPBaseline' and '$(NuGetPackageVersion)' != 'To Fill In With Local Version Number'">
|
||||
<PackageReference Include="$(CurrentProject)" Version="$(NuGetPackageVersion)" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
|
@ -125,5 +128,6 @@
|
|||
<ToolkitNuget Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(Identity)', `$(CurrentProject).([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?.nupkg`))" Include="@(ToolkitNugets)"/>
|
||||
</ItemGroup>
|
||||
<Error Condition="'@(ToolkitNuget)' == '' and $(CurrentProject) != 'UWPBaseline'" Text="NuGet $(CurrentProject).[SEMVER].nupkg doesn't exist!"/>
|
||||
<Error Condition="'$(CurrentProject)' != 'UWPBaseline' and '$(NuGetPackageVersion)' == 'To Fill In With Local Version Number'" Text="Please set NuGetPackageVersion at the top of SmokeTest.csproj with the version to smoke test locally."/>
|
||||
</Target>
|
||||
</Project>
|
|
@ -5,6 +5,13 @@ VisualStudioVersion = 16.0.30413.136
|
|||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmokeTest", "SmokeTest.csproj", "{A6E4CB52-1025-4BBA-9C65-BB871D1FB53F}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Configuration", "Configuration", "{86F3F991-6DDA-442D-A610-9309D6559522}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
nuget.config = nuget.config
|
||||
SmokeTestAnalysis.ps1 = SmokeTestAnalysis.ps1
|
||||
SmokeTests.proj = SmokeTests.proj
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|ARM = Debug|ARM
|
||||
|
|
|
@ -7,8 +7,18 @@
|
|||
<ToolkitPackages>UWPBaseline;Microsoft.Toolkit;Microsoft.Toolkit.HighPerformance;Microsoft.Toolkit.Parsers;Microsoft.Toolkit.Mvvm;Microsoft.Toolkit.Services;Microsoft.Toolkit.Uwp;Microsoft.Toolkit.Uwp.Connectivity;Microsoft.Toolkit.Uwp.DeveloperTools;Microsoft.Toolkit.Uwp.Input.GazeInteraction;Microsoft.Toolkit.Uwp.Notifications;Microsoft.Toolkit.Uwp.UI;Microsoft.Toolkit.Uwp.UI.Animations;Microsoft.Toolkit.Uwp.UI.Controls;Microsoft.Toolkit.Uwp.UI.Controls.DataGrid;Microsoft.Toolkit.Uwp.UI.Controls.Layout;Microsoft.Toolkit.Uwp.UI.Media;Microsoft.Toolkit.Uwp.UI.Controls.Markdown</ToolkitPackages>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="GetNuGetVersion">
|
||||
<Exec Command="powershell -Command "& { .\"$(ProjectDir)..\build\tools\Nerdbank.GitVersioning\tools\Get-Version.ps1\" | Select -ExpandProperty NuGetPackageVersion }""
|
||||
ConsoleToMSBuild="true"
|
||||
EchoOff="true"
|
||||
Condition="'$(NuGetPackageVersion)' == ''">
|
||||
<Output TaskParameter="ConsoleOutput" PropertyName="NuGetPackageVersion" />
|
||||
</Exec>
|
||||
<Message Text="Got GitBank Version... $(NuGetPackageVersion)" Importance="High" />
|
||||
</Target>
|
||||
|
||||
<Target Name="Build"
|
||||
DependsOnTargets="ChooseProjectsToBuild"
|
||||
DependsOnTargets="ChooseProjectsToBuild;GetNuGetVersion"
|
||||
Inputs="@(ProjectsToBuild)"
|
||||
Outputs="%(Filename)">
|
||||
|
||||
|
@ -16,7 +26,7 @@
|
|||
|
||||
<MSBuild Projects="SmokeTest.csproj"
|
||||
Targets="restore;build"
|
||||
Properties="CurrentProject=%(ProjectsToBuild.Identity);Configuration=%(ProjectsToBuild.Configuration);Platform=%(ProjectsToBuild.Platform)"/>
|
||||
Properties="CurrentProject=%(ProjectsToBuild.Identity);Configuration=%(ProjectsToBuild.Configuration);Platform=%(ProjectsToBuild.Platform);NuGetPackageVersion=$(NuGetPackageVersion)"/>
|
||||
</Target>
|
||||
|
||||
<Target Name="ChooseProjectsToBuild" DependsOnTargets="CheckNugets">
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace UnitTests.Helpers
|
|||
Assert.AreEqual(input, output);
|
||||
}
|
||||
|
||||
[Ignore]
|
||||
[TestCategory("Helpers")]
|
||||
[TestMethod]
|
||||
public void Test_StorageHelper_LegacyDateTest()
|
||||
|
@ -53,19 +54,41 @@ namespace UnitTests.Helpers
|
|||
Assert.AreEqual(input, output);
|
||||
}
|
||||
|
||||
[Ignore]
|
||||
[TestCategory("Helpers")]
|
||||
[TestMethod]
|
||||
public void Test_StorageHelper_LegacyPersonTest()
|
||||
public void Test_StorageHelper_LegacyInternalClassTest()
|
||||
{
|
||||
string key = "Contact";
|
||||
|
||||
Person input = new Person() { Name = "Joe Bloggs", Age = 42 };
|
||||
UI.Person input = new UI.Person() { Name = "Joe Bloggs", Age = 42 };
|
||||
|
||||
// simulate previous version by generating json and manually inserting it as string
|
||||
string jsonInput = JsonSerializer.Serialize(input);
|
||||
|
||||
storageHelper.Save<string>(key, jsonInput);
|
||||
|
||||
// now read it as int to valid that the change works
|
||||
UI.Person output = storageHelper.Read<UI.Person>(key, null);
|
||||
|
||||
Assert.IsNotNull(output);
|
||||
Assert.AreEqual(input.Name, output.Name);
|
||||
Assert.AreEqual(input.Age, output.Age);
|
||||
}
|
||||
|
||||
[TestCategory("Helpers")]
|
||||
[TestMethod]
|
||||
public void Test_StorageHelper_LegacyPublicClassTest()
|
||||
{
|
||||
string key = "Contact";
|
||||
|
||||
UI.Person input = new UI.Person() { Name = "Joe Bloggs", Age = 42 };
|
||||
|
||||
// simulate previous version by generating json and manually inserting it as string
|
||||
string jsonInput = JsonSerializer.Serialize(input);
|
||||
|
||||
storageHelper.Save(key, jsonInput);
|
||||
|
||||
// now read it as int to valid that the change works
|
||||
Person output = storageHelper.Read<Person>(key, null);
|
||||
|
||||
|
@ -123,5 +146,12 @@ namespace UnitTests.Helpers
|
|||
Assert.AreEqual(input.Name, output.Name);
|
||||
Assert.AreEqual(input.Age, output.Age);
|
||||
}
|
||||
|
||||
public class Person
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public int Age { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,9 +122,6 @@
|
|||
<PackageReference Include="System.Xml.XPath.XmlDocument">
|
||||
<Version>4.3.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Text.Json">
|
||||
<Version>4.7.2</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Converters\Test_AdaptiveHeightValueConverter.cs" />
|
||||
|
|
|
@ -135,7 +135,6 @@ Task("Verify")
|
|||
|
||||
Task("Version")
|
||||
.Description("Updates the version information in all Projects")
|
||||
.IsDependentOn("Verify")
|
||||
.Does(() =>
|
||||
{
|
||||
Information("\nDownloading NerdBank GitVersioning...");
|
||||
|
@ -210,6 +209,7 @@ Task("InheritDoc")
|
|||
|
||||
Task("Build")
|
||||
.Description("Build all projects runs InheritDoc")
|
||||
.IsDependentOn("Verify")
|
||||
.IsDependentOn("BuildProjects")
|
||||
.IsDependentOn("InheritDoc");
|
||||
|
||||
|
@ -289,10 +289,19 @@ Task("UITest")
|
|||
|
||||
Task("SmokeTest")
|
||||
.Description("Runs all Smoke Tests")
|
||||
.IsDependentOn("Version")
|
||||
.Does(() =>
|
||||
{
|
||||
// Need to do full NuGet restore here to grab proper UWP dependencies...
|
||||
NuGetRestore(baseDir + "/SmokeTests/SmokeTest.csproj");
|
||||
MSBuild(baseDir + "/SmokeTests/SmokeTests.proj");
|
||||
|
||||
var buildSettings = new MSBuildSettings()
|
||||
{
|
||||
Restore = true,
|
||||
}
|
||||
.WithProperty("NuGetPackageVersion", Version);
|
||||
|
||||
MSBuild(baseDir + "/SmokeTests/SmokeTests.proj", buildSettings);
|
||||
}).DeferOnError();
|
||||
|
||||
Task("MSTestUITest")
|
||||
|
|
Загрузка…
Ссылка в новой задаче