Merge branch 'dev/new-animations' into feature/animation-apis-revamp
# Conflicts: # Microsoft.Toolkit.Uwp.UI.Animations/CompositionAnimations/Animations/AnimationBase.cs # Microsoft.Toolkit.Uwp.UI.Animations/CompositionAnimations/KeyFrames/KeyFrame.cs # Microsoft.Toolkit.Uwp.UI.Animations/Extensions/AnimationTools.cs
This commit is contained in:
Коммит
b8e1eed561
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="MSBuild.Sdk.Extras">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>uap10.0.17763</TargetFramework>
|
||||
<TargetFrameworks>uap10.0.17763</TargetFrameworks>
|
||||
<Title>Windows Community Toolkit Devices</Title>
|
||||
<Description>This library enables easier consumption of connectivity Devices/Peripherals and handle its connection to Windows devices. It contains BluetoothLE and Network connectivity helpers.</Description>
|
||||
<PackageTags>UWP Toolkit Windows Devices Bluetooth BluetoothLE BLE Networking</PackageTags>
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Microsoft.Toolkit.Uwp.DeveloperTools
|
|||
/// <summary>
|
||||
/// AlignmentGrid is used to display a grid to help aligning controls
|
||||
/// </summary>
|
||||
public class AlignmentGrid : ContentControl
|
||||
public partial class AlignmentGrid : ContentControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="LineBrush"/> dependency property.
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Microsoft.Toolkit.Uwp.DeveloperTools
|
|||
[TemplatePart(Name = "ControlType", Type = typeof(TextBlock))]
|
||||
[TemplatePart(Name = "ControlAutomationName", Type = typeof(TextBlock))]
|
||||
[TemplatePart(Name = "ControlFirstParentWithName", Type = typeof(TextBlock))]
|
||||
public class FocusTracker : Control
|
||||
public partial class FocusTracker : Control
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the <see cref="IsActive"/> dependency property.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="MSBuild.Sdk.Extras">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>uap10.0.17763</TargetFramework>
|
||||
<TargetFrameworks>uap10.0.17763</TargetFrameworks>
|
||||
<Title>Windows Community Toolkit Developer Tools</Title>
|
||||
<Description>This library provides XAML user controls and services to help developers build their app. It is part of the Windows Community Toolkit.
|
||||
|
||||
|
|
|
@ -121,9 +121,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>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="MSBuild.Sdk.Extras">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>uap10.0.17763</TargetFramework>
|
||||
<TargetFrameworks>uap10.0.17763</TargetFrameworks>
|
||||
<Title>Windows Community Toolkit Animations</Title>
|
||||
<Description>
|
||||
This library provides helpers and extensions on top of Windows Composition and XAML storyboards. It is part of the Windows Community Toolkit.
|
||||
|
|
|
@ -168,7 +168,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Behaviors
|
|||
/// <summary>
|
||||
/// A target for the <see cref="FocusBehavior"/>.
|
||||
/// </summary>
|
||||
public sealed class FocusTarget : DependencyObject
|
||||
public sealed partial class FocusTarget : DependencyObject
|
||||
{
|
||||
/// <summary>
|
||||
/// The DP to store the <see cref="Control"/> property value.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<Project Sdk="MSBuild.Sdk.Extras">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>uap10.0.17763</TargetFramework>
|
||||
<TargetFrameworks>uap10.0.17763</TargetFrameworks>
|
||||
<Title>Windows Community Toolkit Controls DataGrid</Title>
|
||||
<Description>
|
||||
This library provides a XAML DataGrid control. It is part of the Windows Community Toolkit.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="MSBuild.Sdk.Extras">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>uap10.0.17763</TargetFramework>
|
||||
<TargetFrameworks>uap10.0.17763</TargetFrameworks>
|
||||
<TargetPlatformVersion Condition="'$(TargetPlatformVersion)' == '' ">10.0.19041.0</TargetPlatformVersion>
|
||||
<Title>Windows Community Toolkit Layout</Title>
|
||||
<Description>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<Project Sdk="MSBuild.Sdk.Extras">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>uap10.0.17763</TargetFramework>
|
||||
<TargetFrameworks>uap10.0.17763</TargetFrameworks>
|
||||
<Title>Windows Community Toolkit Controls Markdown</Title>
|
||||
<Description>
|
||||
This library provides a XAML MarkdownTextBlock control, an efficient and extensible control that can parse and render markdown. It is part of the Windows Community Toolkit.
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <summary>
|
||||
/// A modern UI Carousel control. Really flexible. Works with touch, keyboard, mouse.
|
||||
/// </summary>
|
||||
public class Carousel : ItemsControl
|
||||
public partial class Carousel : ItemsControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the selected item.
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <summary>
|
||||
/// Represents the container for an item in a Carousel control.
|
||||
/// </summary>
|
||||
public class CarouselItem : SelectorItem
|
||||
public partial class CarouselItem : SelectorItem
|
||||
{
|
||||
private const string PointerOverState = "PointerOver";
|
||||
private const string PointerOverSelectedState = "PointerOverSelected";
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <summary>
|
||||
/// The panel used in the <see cref="Carousel"/> control
|
||||
/// </summary>
|
||||
public class CarouselPanel : Panel
|
||||
public partial class CarouselPanel : Panel
|
||||
{
|
||||
// Storyboard on gesture
|
||||
private Storyboard storyboard = new Storyboard();
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// A <see cref="DropDownButton"/> which displays a color as its <c>Content</c> and it's <c>Flyout</c> is a <see cref="ColorPicker"/>.
|
||||
/// </summary>
|
||||
[TemplatePart(Name = nameof(CheckeredBackgroundBorder), Type = typeof(Border))]
|
||||
public class ColorPickerButton : DropDownButton
|
||||
public partial class ColorPickerButton : DropDownButton
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the <see cref="Controls.ColorPicker"/> instances contained by the <see cref="DropDownButton"/>.
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <summary>
|
||||
/// Provides the base implementation for all controls that contain single content and have a header.
|
||||
/// </summary>
|
||||
public class HeaderedContentControl : ContentControl
|
||||
public partial class HeaderedContentControl : ContentControl
|
||||
{
|
||||
private const string PartHeaderPresenter = "HeaderPresenter";
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <summary>
|
||||
/// Represents a control that contains multiple items and has a header.
|
||||
/// </summary>
|
||||
public class HeaderedItemsControl : ItemsControl
|
||||
public partial class HeaderedItemsControl : ItemsControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HeaderedItemsControl"/> class.
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// Allows raise an event when the value of a dependency property changes when a view model is otherwise not necessary.
|
||||
/// </summary>
|
||||
/// <typeparam name="TPropertyType">Type of the DependencyProperty</typeparam>
|
||||
internal class PropertyChangeEventSource<TPropertyType> : FrameworkElement
|
||||
internal partial class PropertyChangeEventSource<TPropertyType> : FrameworkElement
|
||||
{
|
||||
private readonly DependencyObject _source;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="MSBuild.Sdk.Extras">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>uap10.0.17763</TargetFramework>
|
||||
<TargetFrameworks>uap10.0.17763</TargetFrameworks>
|
||||
<Title>Windows Community Toolkit Controls</Title>
|
||||
<Description>
|
||||
This library provides XAML templated controls. It is part of the Windows Community Toolkit.
|
||||
|
@ -46,6 +46,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="4.7.2" />
|
||||
<PackageReference Include="Win2D.uwp" Version="1.25.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
[TemplatePart(Name = "AnchorCanvas", Type = typeof(Canvas))]
|
||||
[TemplatePart(Name = "OrbitGrid", Type = typeof(Grid))]
|
||||
[TemplatePart(Name = "CenterContent", Type = typeof(ContentPresenter))]
|
||||
public class OrbitView : ItemsControl
|
||||
public partial class OrbitView : ItemsControl
|
||||
{
|
||||
private const double AnimationDuration = 200;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <summary>
|
||||
/// A class that can be used to provide data context for <see cref="OrbitView"></see> items by providing distance and diameter values
|
||||
/// </summary>
|
||||
public class OrbitViewDataItem : DependencyObject
|
||||
public partial class OrbitViewDataItem : DependencyObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating the distance from the center.
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
[TemplateVisualState(Name = VsNormal, GroupName = CommonStateGroup)]
|
||||
[TemplateVisualState(Name = VsPressed, GroupName = CommonStateGroup)]
|
||||
[TemplateVisualState(Name = VsPointerOver, GroupName = CommonStateGroup)]
|
||||
public class OrbitViewItem : ContentControl
|
||||
public partial class OrbitViewItem : ContentControl
|
||||
{
|
||||
private const string CommonStateGroup = "CommonStates";
|
||||
private const string VsNormal = "Normal";
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
[TemplatePart(Name = OutlineArcPartName, Type = typeof(ArcSegment))]
|
||||
[TemplatePart(Name = BarFigurePartName, Type = typeof(PathFigure))]
|
||||
[TemplatePart(Name = BarArcPartName, Type = typeof(ArcSegment))]
|
||||
public class RadialProgressBar : ProgressBar
|
||||
public partial class RadialProgressBar : ProgressBar
|
||||
{
|
||||
private const string OutlineFigurePartName = "OutlineFigurePart";
|
||||
private const string OutlineArcPartName = "OutlineArcPart";
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
[TemplatePart(Name = "StatusType", Type = typeof(ComboBox))]
|
||||
[TemplatePart(Name = "AuthorizationType", Type = typeof(ComboBox))]
|
||||
[TemplatePart(Name = "AdvancedFiltersGrid", Type = typeof(Grid))]
|
||||
public sealed class RemoteDevicePicker : ContentDialog
|
||||
public sealed partial class RemoteDevicePicker : ContentDialog
|
||||
{
|
||||
private ListView _listDevices;
|
||||
private ComboBox _listDeviceTypes;
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
[TemplatePart(Name = NextPartName, Type = typeof(FrameworkElement))]
|
||||
[TemplatePart(Name = TranslatePartName, Type = typeof(TranslateTransform))]
|
||||
[TemplatePart(Name = StackPartName, Type = typeof(StackPanel))]
|
||||
public class RotatorTile : Control
|
||||
public partial class RotatorTile : Control
|
||||
{
|
||||
private const string ScrollerPartName = "Scroller";
|
||||
private const string CurrentPartName = "Current";
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <see cref="Case"/> is the value container for the <see cref="SwitchPresenter"/>.
|
||||
/// </summary>
|
||||
[ContentProperty(Name = nameof(Content))]
|
||||
public class Case : DependencyObject
|
||||
public partial class Case : DependencyObject
|
||||
{
|
||||
internal SwitchPresenter Parent { get; set; } // TODO: Can we remove Parent need here and just use events?
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// When provided a set of <see cref="Case"/>s and a <see cref="Value"/>, it will pick the matching <see cref="Case"/> with the corresponding <see cref="Case.Value"/>.
|
||||
/// </summary>
|
||||
[ContentProperty(Name = nameof(SwitchCases))]
|
||||
public sealed class SwitchPresenter : ContentPresenter
|
||||
public sealed partial class SwitchPresenter : ContentPresenter
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the current <see cref="Case"/> which is being displayed.
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.TextToolbarSymbols
|
|||
/// <summary>
|
||||
/// Creates a List Icon
|
||||
/// </summary>
|
||||
public class List : Symbol
|
||||
public partial class List : Symbol
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="List"/> class.
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.TextToolbarSymbols
|
|||
/// <summary>
|
||||
/// Creates a Numbered List Icon
|
||||
/// </summary>
|
||||
public class NumberedList : Symbol
|
||||
public partial class NumberedList : Symbol
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NumberedList"/> class.
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.TextToolbarSymbols
|
|||
/// </summary>
|
||||
[TemplateVisualState(GroupName = Common, Name = Normal)]
|
||||
[TemplateVisualState(GroupName = Common, Name = Disabled)]
|
||||
public abstract class Symbol : Control
|
||||
public abstract partial class Symbol : Control
|
||||
{
|
||||
internal const string Common = "CommonStates";
|
||||
internal const string Normal = "Normal";
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.TextToolbarButtons
|
|||
/// <summary>
|
||||
/// Specifies a DefaultButton, modifies a Button Instance
|
||||
/// </summary>
|
||||
public class DefaultButton : DependencyObject
|
||||
public partial class DefaultButton : DependencyObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="IsVisible"/> dependency property.
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.TextToolbarButtons
|
|||
/// <summary>
|
||||
/// An Interactive button in the TextToolbar, to perform a formatting task.
|
||||
/// </summary>
|
||||
public class ToolbarButton : AppBarButton, IToolbarItem, INotifyPropertyChanged
|
||||
public partial class ToolbarButton : AppBarButton, IToolbarItem, INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="ToolTip"/> dependency property.
|
||||
|
@ -164,6 +164,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.TextToolbarButtons
|
|||
set
|
||||
{
|
||||
_position = value;
|
||||
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Position)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.TextToolbarButtons
|
|||
/// <summary>
|
||||
/// Separates a collection of <see cref="IToolbarItem"/>
|
||||
/// </summary>
|
||||
public class ToolbarSeparator : AppBarSeparator, IToolbarItem
|
||||
public partial class ToolbarSeparator : AppBarSeparator, IToolbarItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ToolbarSeparator"/> class.
|
||||
|
|
|
@ -6,7 +6,10 @@ using Windows.UI.Xaml;
|
|||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
internal class PretokenStringContainer : DependencyObject, ITokenStringContainer
|
||||
/// <summary>
|
||||
/// <see cref="TokenizingTextBox"/> support class
|
||||
/// </summary>
|
||||
internal partial class PretokenStringContainer : DependencyObject, ITokenStringContainer
|
||||
{
|
||||
public string Text
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Converters
|
|||
/// This class converts a boolean value into an other object.
|
||||
/// Can be used to convert true/false to visibility, a couple of colors, couple of images, etc.
|
||||
/// </summary>
|
||||
public class BoolToObjectConverter : DependencyObject, IValueConverter
|
||||
public partial class BoolToObjectConverter : DependencyObject, IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="TrueValue"/> property.
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Converters
|
|||
/// Otherwise the logic looks for the value to be GreaterThan or LessThan the specified value.
|
||||
/// The ConverterParameter can be used to invert the logic.
|
||||
/// </summary>
|
||||
public class DoubleToObjectConverter : DependencyObject, IValueConverter
|
||||
public partial class DoubleToObjectConverter : DependencyObject, IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="TrueValue"/> property.
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Converters
|
|||
/// This class converts an object value into a an object (if the value is null returns the false value).
|
||||
/// Can be used to bind a visibility, a color or an image to the value of an object.
|
||||
/// </summary>
|
||||
public class EmptyObjectToObjectConverter : DependencyObject, IValueConverter
|
||||
public partial class EmptyObjectToObjectConverter : DependencyObject, IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="NotEmptyValue"/> property.
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Converters
|
|||
/// <summary>
|
||||
/// This class returns an object or another, depending on whether the type of the provided value matches another provided Type.
|
||||
/// </summary>
|
||||
public class TypeToObjectConverter : DependencyObject, IValueConverter
|
||||
public partial class TypeToObjectConverter : DependencyObject, IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="TrueValue"/> property.
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Helpers
|
|||
/// Can be used to change several objects' properties at a time.
|
||||
/// </summary>
|
||||
[ContentProperty(Name = nameof(Value))]
|
||||
public class BindableValueHolder : DependencyObject
|
||||
public partial class BindableValueHolder : DependencyObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="Value"/> property.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="MSBuild.Sdk.Extras">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>uap10.0.17763</TargetFramework>
|
||||
<TargetFrameworks>uap10.0.17763</TargetFrameworks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<Title>Windows Community Toolkit UI</Title>
|
||||
<Description>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="MSBuild.Sdk.Extras">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>uap10.0.17763</TargetFramework>
|
||||
<TargetFrameworks>uap10.0.17763</TargetFrameworks>
|
||||
<Title>Windows Community Toolkit</Title>
|
||||
<Description>This package includes code only helpers such as Colors conversion tool, Storage file handling, a Stream helper class, etc.</Description>
|
||||
<PackageTags>UWP Toolkit Windows</PackageTags>
|
||||
|
@ -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
|
||||
|
|
|
@ -27,8 +27,18 @@
|
|||
</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)">
|
||||
|
||||
|
@ -36,7 +46,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")
|
||||
|
|
Загрузка…
Ссылка в новой задаче