Skip to content
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
84 changes: 84 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,87 @@ dotnet_naming_rule.interface_types_must_be_prefixed_with_i.style
dotnet_naming_style.prefix_private_field_with_underscore.capitalization = camel_case
dotnet_naming_style.prefix_private_field_with_underscore.required_prefix = _

# Code files
[*.{cs,vb}]

# Migrate back from old Toolkit.ruleset
dotnet_diagnostic.CA1001.severity = warning
dotnet_diagnostic.CA1009.severity = warning
dotnet_diagnostic.CA1016.severity = warning
dotnet_diagnostic.CA1033.severity = warning
dotnet_diagnostic.CA1049.severity = warning
dotnet_diagnostic.CA1060.severity = warning
dotnet_diagnostic.CA1061.severity = warning
dotnet_diagnostic.CA1063.severity = warning
dotnet_diagnostic.CA1065.severity = warning
dotnet_diagnostic.CA1301.severity = warning
dotnet_diagnostic.CA1400.severity = warning
dotnet_diagnostic.CA1401.severity = warning
dotnet_diagnostic.CA1403.severity = warning
dotnet_diagnostic.CA1404.severity = warning
dotnet_diagnostic.CA1405.severity = warning
dotnet_diagnostic.CA1410.severity = warning
dotnet_diagnostic.CA1415.severity = warning
dotnet_diagnostic.CA1821.severity = warning
dotnet_diagnostic.CA1900.severity = warning
dotnet_diagnostic.CA1901.severity = warning
dotnet_diagnostic.CA2002.severity = warning
dotnet_diagnostic.CA2100.severity = warning
dotnet_diagnostic.CA2101.severity = warning
dotnet_diagnostic.CA2108.severity = warning
dotnet_diagnostic.CA2111.severity = warning
dotnet_diagnostic.CA2112.severity = warning
dotnet_diagnostic.CA2114.severity = warning
dotnet_diagnostic.CA2116.severity = warning
dotnet_diagnostic.CA2117.severity = warning
dotnet_diagnostic.CA2122.severity = warning
dotnet_diagnostic.CA2123.severity = warning
dotnet_diagnostic.CA2124.severity = warning
dotnet_diagnostic.CA2126.severity = warning
dotnet_diagnostic.CA2131.severity = warning
dotnet_diagnostic.CA2132.severity = warning
dotnet_diagnostic.CA2133.severity = warning
dotnet_diagnostic.CA2134.severity = warning
dotnet_diagnostic.CA2137.severity = warning
dotnet_diagnostic.CA2138.severity = warning
dotnet_diagnostic.CA2140.severity = warning
dotnet_diagnostic.CA2141.severity = warning
dotnet_diagnostic.CA2146.severity = warning
dotnet_diagnostic.CA2147.severity = warning
dotnet_diagnostic.CA2149.severity = warning
dotnet_diagnostic.CA2200.severity = warning
dotnet_diagnostic.CA2202.severity = warning
dotnet_diagnostic.CA2207.severity = warning
dotnet_diagnostic.CA2212.severity = warning
dotnet_diagnostic.CA2213.severity = warning
dotnet_diagnostic.CA2214.severity = warning
dotnet_diagnostic.CA2216.severity = warning
dotnet_diagnostic.CA2220.severity = warning
dotnet_diagnostic.CA2229.severity = warning
dotnet_diagnostic.CA2231.severity = warning
dotnet_diagnostic.CA2232.severity = warning
dotnet_diagnostic.CA2235.severity = warning
dotnet_diagnostic.CA2236.severity = warning
dotnet_diagnostic.CA2237.severity = warning
dotnet_diagnostic.CA2238.severity = warning
dotnet_diagnostic.CA2240.severity = warning
dotnet_diagnostic.CA2241.severity = warning
dotnet_diagnostic.CA2242.severity = warning
dotnet_diagnostic.SA1011.severity = none
dotnet_diagnostic.SA1101.severity = none
dotnet_diagnostic.SA1118.severity = none
dotnet_diagnostic.SA1200.severity = none
dotnet_diagnostic.SA1201.severity = none
dotnet_diagnostic.SA1202.severity = none
dotnet_diagnostic.SA1309.severity = none
dotnet_diagnostic.SA1310.severity = none
dotnet_diagnostic.SA1600.severity = none
dotnet_diagnostic.SA1602.severity = none
dotnet_diagnostic.SA1611.severity = none
dotnet_diagnostic.SA1633.severity = none
dotnet_diagnostic.SA1634.severity = none
dotnet_diagnostic.SA1652.severity = none

dotnet_diagnostic.SA1629.severity = none # DocumentationTextMustEndWithAPeriod: Let's enable this rule back when we shift to WinUI3 (v8.x). If we do it now, it would mean more than 400 file changes.
dotnet_diagnostic.SA1413.severity = none # UseTrailingCommasInMultiLineInitializers: This would also mean a lot of changes at the end of all multiline intializers. It's also debatable if we want this or not.
dotnet_diagnostic.SA1314.severity = none # TypeParameterNamesMustBeginWithT: We do have a few templates that don't start with T. We need to double check that changing this is not a breaking change. If not, we can re-enable this.
3 changes: 1 addition & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<PackageLicenseUrl>https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/master/license.md</PackageLicenseUrl>
<PackageReleaseNotes>v3.0 release https://github.com/windows-toolkit/WindowsCommunityToolkit/releases</PackageReleaseNotes>
<Copyright>(c) .NET Foundation and Contributors. All rights reserved.</Copyright>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)Toolkit.ruleset</CodeAnalysisRuleSet>
<DefaultLanguage>en-US</DefaultLanguage>
<IsDesignProject>$(MSBuildProjectName.Contains('.Design'))</IsDesignProject>
<IsTestProject>$(MSBuildProjectName.Contains('Test'))</IsTestProject>
Expand Down Expand Up @@ -62,7 +61,7 @@
<When Condition="'$(IsTestProject)' != 'true' and '$(IsSampleProject)' != 'true' and '$(IsDesignProject)' != 'true'">
<ItemGroup>
<!--<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="15.3.83" PrivateAssets="all" />-->
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />

<EmbeddedResource Include="**\*.rd.xml" />
<Page Include="**\*.xaml" Exclude="**\bin\**\*.xaml;**\obj\**\*.xaml" SubType="Designer" Generator="MSBuild:Compile" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public async Task LogoutAsync()
if (crendential != null)
{
_passwordManager.Remove(LinkedInConstants.STORAGEKEYACCESSTOKEN);
await _storageManager.SetAsync(LinkedInConstants.STORAGEKEYUSER, null);
await _storageManager.SetAsync(LinkedInConstants.STORAGEKEYUSER, null);
}

LoggedIn = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public async Task LogoutAsync()
if (credential != null)
{
_passwordManager.Remove(PasswordKey);
await _storageManager.SetAsync(StorageKey, null);
await _storageManager.SetAsync(StorageKey, null);
}

Uid = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,50 +82,50 @@ private IList<IToastBindingGenericChild> VisualChildren

#if WINDOWS_UWP

/// <summary>
/// Create an instance of NotificationData that can be used to update toast that has a progress bar.
/// </summary>
/// <param name="toast">Instance of ToastContent that contain progress bars that need to be updated</param>
/// <param name="index">Index of the progress bar (0-based) that this notification data is updating in the case that toast has multiple progress bars. Default to 0.</param>
/// <param name="title">Title of the progress bar.</param>
/// <param name="value">Value of the progress bar.</param>
/// <param name="valueStringOverride">An optional string to be displayed instead of the default percentage string. If this isn't provided, something like "70%" will be displayed.</param>
/// <param name="status"> A status string, which is displayed underneath the progress bar on the left. Default to empty.</param>
/// <param name="sequence">A sequence number to prevent out-of-order updates, or assign 0 to indicate "always update".</param>
/// <returns>An instance of NotificationData that can be used to update the toast.</returns>
public static NotificationData CreateProgressBarData(ToastContent toast, int index = 0, string title = default(string), double? value = null, string valueStringOverride = default(string), string status = default(string), uint sequence = 0)
{
var progressBar = toast.Visual.BindingGeneric.Children.Where(c => c is AdaptiveProgressBar).ElementAt(index) as AdaptiveProgressBar;
if (progressBar == null)
{
throw new ArgumentException(nameof(toast), "Given toast does not have any progress bar");
}

NotificationData data = new NotificationData();
data.SequenceNumber = sequence;

if (progressBar.Title is BindableString bindableTitle && title != default(string))
{
data.Values[bindableTitle.BindingName] = title;
}

if (progressBar.Value is BindableProgressBarValue bindableProgressValue && value != null)
{
data.Values[bindableProgressValue.BindingName] = value.ToString();
}

if (progressBar.ValueStringOverride is BindableString bindableValueStringOverride && valueStringOverride != default(string))
{
data.Values[bindableValueStringOverride.BindingName] = valueStringOverride;
}

if (progressBar.Status is BindableString bindableStatus && status != default(string))
{
data.Values[bindableStatus.BindingName] = status;
}

return data;
}
/// <summary>
/// Create an instance of NotificationData that can be used to update toast that has a progress bar.
/// </summary>
/// <param name="toast">Instance of ToastContent that contain progress bars that need to be updated</param>
/// <param name="index">Index of the progress bar (0-based) that this notification data is updating in the case that toast has multiple progress bars. Default to 0.</param>
/// <param name="title">Title of the progress bar.</param>
/// <param name="value">Value of the progress bar.</param>
/// <param name="valueStringOverride">An optional string to be displayed instead of the default percentage string. If this isn't provided, something like "70%" will be displayed.</param>
/// <param name="status"> A status string, which is displayed underneath the progress bar on the left. Default to empty.</param>
/// <param name="sequence">A sequence number to prevent out-of-order updates, or assign 0 to indicate "always update".</param>
/// <returns>An instance of NotificationData that can be used to update the toast.</returns>
public static NotificationData CreateProgressBarData(ToastContent toast, int index = 0, string title = default(string), double? value = null, string valueStringOverride = default(string), string status = default(string), uint sequence = 0)
{
var progressBar = toast.Visual.BindingGeneric.Children.Where(c => c is AdaptiveProgressBar).ElementAt(index) as AdaptiveProgressBar;
if (progressBar == null)
{
throw new ArgumentException(nameof(toast), "Given toast does not have any progress bar");
}

NotificationData data = new NotificationData();
data.SequenceNumber = sequence;

if (progressBar.Title is BindableString bindableTitle && title != default(string))
{
data.Values[bindableTitle.BindingName] = title;
}

if (progressBar.Value is BindableProgressBarValue bindableProgressValue && value != null)
{
data.Values[bindableProgressValue.BindingName] = value.ToString();
}

if (progressBar.ValueStringOverride is BindableString bindableValueStringOverride && valueStringOverride != default(string))
{
data.Values[bindableValueStringOverride.BindingName] = valueStringOverride;
}

if (progressBar.Status is BindableString bindableStatus && status != default(string))
{
data.Values[bindableStatus.BindingName] = status;
}

return data;
}

#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ private static void OnKeyChanged(DependencyObject d, DependencyPropertyChangedEv
{
(frame.Content as Page)?.UnregisterElementForConnectedAnimation(oldKey);
}

if (e.NewValue is string newKey)
{
(frame.Content as Page)?.RegisterElementForConnectedAnimation(newKey, element);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ private void Frame_Navigated(object sender, Windows.UI.Xaml.Navigation.Navigatio
return;
}

void loadedHandler(object s, RoutedEventArgs args)
void LoadedHandler(object s, RoutedEventArgs args)
{
var page = s as Page;
page.Loaded -= loadedHandler;
page.Loaded -= LoadedHandler;

object parameter;
if (_nextParameter != null)
Expand Down Expand Up @@ -204,7 +204,7 @@ void loadedHandler(object s, RoutedEventArgs args)
_nextParameter = null;
}

navigatedPage.Loaded += loadedHandler;
navigatedPage.Loaded += LoadedHandler;
}

private void UseDirectConnectedAnimationConfiguration(ConnectedAnimation animation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private static CompositionEasingFunction GenerateCompositionEasingFunctionFromEa
// Pay-per-play caching of easing functions
EnsureEasingsCached();

if (_compositionEasingFunctions.TryGetValue((easingType.ToString(), easingMode), out(Vector2, Vector2) points))
if (_compositionEasingFunctions.TryGetValue((easingType.ToString(), easingMode), out (Vector2, Vector2) points))
{
return compositor.CreateCubicBezierEasingFunction(points.Item1, points.Item2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ protected override void RefreshOverride()
if (!UsesLocalArray)
{
#endif
_internalList = list;
#pragma warning disable SA1137 // Elements should have the same indentation
_internalList = list;
#pragma warning restore SA1137 // Elements should have the same indentation
#if FEATURE_ICOLLECTIONVIEW_SORT_OR_FILTER
}
else
Expand Down Expand Up @@ -1979,6 +1981,7 @@ private IList PrepareLocalArray(IList list)
private void MoveCurrencyOffDeletedElement(int oldCurrentPosition)
{
int lastPosition = InternalCount - 1; // OK if last is -1

// if position falls beyond last position, move back to last position
int newPosition = (oldCurrentPosition < lastPosition) ? oldCurrentPosition : lastPosition;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,38 +99,32 @@ protected override object GetPatternCore(PatternInterface patternInterface)
switch (patternInterface)
{
case PatternInterface.Invoke:
{
// this.OwningHeader.OwningGrid.DataConnection.AllowSort property is ignored because of the DataGrid.Sorting custom sorting capability.
if (this.OwningHeader.OwningGrid.CanUserSortColumns &&
this.OwningHeader.OwningColumn.CanUserSort)
// this.OwningHeader.OwningGrid.DataConnection.AllowSort property is ignored because of the DataGrid.Sorting custom sorting capability.
if (this.OwningHeader.OwningGrid.CanUserSortColumns &&
this.OwningHeader.OwningColumn.CanUserSort)
{
return this;
}

break;
}

case PatternInterface.ScrollItem:
{
if (this.OwningHeader.OwningGrid.HorizontalScrollBar != null &&
this.OwningHeader.OwningGrid.HorizontalScrollBar.Maximum > 0)
{
return this;
}

break;
}

case PatternInterface.Transform:
{
if (this.OwningHeader.OwningColumn != null &&
this.OwningHeader.OwningColumn.ActualCanUserResize)
{
return this;
}

break;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,12 @@ protected override IList<AutomationPeer> GetChildrenCore()
if (_group.IsBottomLevel)
{
#endif
#pragma warning disable SA1137 // Elements should have the same indentation
foreach (object item in _group.GroupItems /*Items*/)
{
children.Add(this.OwningDataGridPeer.GetOrCreateItemPeer(item));
}
#pragma warning restore SA1137 // Elements should have the same indentation
#if FEATURE_ICOLLECTIONVIEW_GROUP
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ protected override FrameworkElement GenerateEditingElement(DataGridCell cell, ob
{
var value = dataItem.GetType().GetProperty(Binding.Path.Path).GetValue(dataItem);

var selection = !string.IsNullOrEmpty(DisplayMemberPath)
? ItemsSource?.Cast<object>().FirstOrDefault(x => x.GetType().GetProperty(Binding.Path.Path).GetValue(x).Equals(value))
: ItemsSource?.Cast<object>().FirstOrDefault(x => x.Equals(value));
var selection = !string.IsNullOrEmpty(DisplayMemberPath)
? ItemsSource?.Cast<object>().FirstOrDefault(x => x.GetType().GetProperty(Binding.Path.Path).GetValue(x).Equals(value))
: ItemsSource?.Cast<object>().FirstOrDefault(x => x.Equals(value));

comboBox.SelectedItem = selection;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ protected override void RenderStrikethroughRun(StrikethroughTextInline element,
builder.Append((char)0x0336);
builder.Append(c);
}

run.Text = builder.ToString();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public Formatter Formatter
public ButtonMap DefaultButtons
{
get { return (ButtonMap)GetValue(DefaultButtonsProperty); }
private set { SetValue(DefaultButtonsProperty, value); }
private set { SetValue(DefaultButtonsProperty, value); }
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public async void OpenLinkCreator(ToolbarButton button)
}

labelBox.Document.SetDefaultCharacterFormat(selection.CharacterFormat);
selection.GetText(Windows.UI.Text.TextGetOptions.FormatRtf, out string Labeltext);
labelBox.Document.SetText(Windows.UI.Text.TextSetOptions.FormatRtf, Labeltext);
selection.GetText(Windows.UI.Text.TextGetOptions.FormatRtf, out string labeltext);
labelBox.Document.SetText(Windows.UI.Text.TextSetOptions.FormatRtf, labeltext);

var result = await new ContentDialog
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

[assembly: InternalsVisibleTo("UnitTests")]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

namespace Microsoft.Toolkit.Uwp.UI.Controls
{
/// <summary>
Expand Down
Loading