Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
70e9c98
remove unused fields
vgromfeld Feb 28, 2020
c998f09
address comments
vgromfeld Mar 11, 2020
84a7995
fixed style cop issue
vgromfeld Mar 13, 2020
7fc6df7
Merge pull request #1 from windows-toolkit/master
vgromfeld Mar 13, 2020
b424119
Merge branch 'master' into u/vgromfeld/removeUnusedFields
vgromfeld Mar 13, 2020
0f1b9d3
Merge branch 'master' into u/vgromfeld/removeUnusedFields
vgromfeld Mar 16, 2020
8d4fb2d
Add Dependency Info (#3115)
michael-hawker Mar 17, 2020
b08f296
Merge branch 'master' into u/vgromfeld/removeUnusedFields
vgromfeld Mar 18, 2020
714b2e9
add can execute check
vgromfeld Mar 18, 2020
1c0d5cf
Merge branch 'master' into u/vgromfeld/hyperlinkCommand
vgromfeld Mar 18, 2020
abf77ed
Merge pull request #3172 from vgromfeld/u/vgromfeld/hyperlinkCommand
vgromfeld Mar 19, 2020
bd1242f
rename variable
vgromfeld Mar 19, 2020
d203d0a
revert var to int
vgromfeld Mar 19, 2020
1cbcf90
Merge remote-tracking branch 'origin/master' into u/vgromfeld/removeU…
vgromfeld Mar 19, 2020
d55bdd1
restore task return value + add discards
vgromfeld Mar 20, 2020
5e030db
Merge pull request #3155 from vgromfeld/u/vgromfeld/removeUnusedFields
vgromfeld Mar 23, 2020
469d951
Allow horizontal scrolling if the horizontal scrollbar is not disable…
skendrot Mar 24, 2020
2dd783d
Fix "Italic" checkstate bug + fix "italic" typo in InfiniteCanvas con…
BurkusCat Mar 24, 2020
49f2a95
Updated StyleCop to 1.1.118.
azchohfi Mar 24, 2020
01d7f8c
Added a few comments on the .editorconfig file.
azchohfi Mar 25, 2020
385293b
Merge branch 'master' into styleCopUpdate
azchohfi Mar 25, 2020
9fc3a62
Merge pull request #3189 from windows-toolkit/styleCopUpdate
michael-hawker Mar 25, 2020
54a2080
Let BaseObjectStorageHelper use a custom serializer
sperrat Mar 23, 2020
87b0d06
Merge pull request #3181 from simop-msft/user/simop/customSerializerS…
vgromfeld Mar 26, 2020
04eb1b4
Centralized StyleCop version in Directory.Build.props.
azchohfi Mar 26, 2020
3a9b082
Merge pull request #3199 from windows-toolkit/styleCopUpdate2
azchohfi Mar 26, 2020
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.
12 changes: 8 additions & 4 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 @@ -59,11 +58,16 @@
</Choose>

<Choose>
<When Condition="'$(IsTestProject)' != 'true' and '$(IsSampleProject)' != 'true' and '$(IsDesignProject)' != 'true'">
<When Condition="'$(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" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive"/>
</ItemGroup>
</When>
</Choose>

<Choose>
<When Condition="'$(IsTestProject)' != 'true' and '$(IsSampleProject)' != 'true' and '$(IsDesignProject)' != 'true'">
<ItemGroup>
<EmbeddedResource Include="**\*.rd.xml" />
<Page Include="**\*.xaml" Exclude="**\bin\**\*.xaml;**\obj\**\*.xaml" SubType="Designer" Generator="MSBuild:Compile" />
<Compile Update="**\*.xaml.cs" DependentUpon="%(Filename)" />
Expand Down
3 changes: 0 additions & 3 deletions Microsoft.Toolkit.Parsers/Markdown/Blocks/YamlHeaderBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Toolkit.Parsers.Markdown.Helpers;

namespace Microsoft.Toolkit.Parsers.Markdown.Blocks
Expand Down Expand Up @@ -108,8 +107,6 @@ internal static YamlHeaderBlock Parse(string markdown, int start, int end, out i
}

var result = new YamlHeaderBlock();
var keys = new List<string>();
var values = new List<string>();
result.Children = new Dictionary<string, string>();
foreach (var item in elements)
{
Expand Down
4 changes: 1 addition & 3 deletions Microsoft.Toolkit.Parsers/Markdown/Inlines/ImageInline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ internal static void AddTripChars(List<InlineTripCharHelper> tripCharHelpers)
/// <returns> A parsed markdown image, or <c>null</c> if this is not a markdown image. </returns>
internal static InlineParseResult Parse(string markdown, int start, int end)
{
int refstart = 0;

// Expect a '!' character.
if (start >= end || markdown[start] != '!')
{
Expand Down Expand Up @@ -120,7 +118,7 @@ internal static InlineParseResult Parse(string markdown, int start, int end)

if (pos < end && markdown[pos] == '[')
{
refstart = pos;
int refstart = pos;

// Find the reference ']' character
while (pos < end)
Expand Down
2 changes: 1 addition & 1 deletion Microsoft.Toolkit.Parsers/Markdown/MarkdownDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public MarkdownDocument()
/// <param name="markdownText"> The markdown text. </param>
public void Parse(string markdownText)
{
Blocks = Parse(markdownText, 0, markdownText.Length, quoteDepth: 0, actualEnd: out int actualEnd);
Blocks = Parse(markdownText, 0, markdownText.Length, quoteDepth: 0, actualEnd: out _);

// Remove any references from the list of blocks, and add them to a dictionary.
for (int i = Blocks.Count - 1; i >= 0; i--)
Expand Down
12 changes: 5 additions & 7 deletions Microsoft.Toolkit.Parsers/Rss/RssHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ public static string TimeZoneToOffset(string tz)

tz = tz.ToUpper().Trim();

if (timeZones.ContainsKey(tz))
if (TimeZones.ContainsKey(tz))
{
return timeZones[tz].First();
return TimeZones[tz].First();
}

return null;
Expand All @@ -337,8 +337,7 @@ private static IEnumerable<string> GetImagesInHTMLString(string htmlString)
if (matchHeight.Success)
{
var heightValue = matchHeight.Groups["height"].Value;
int size = 0;
if (int.TryParse(heightValue, out size) && size < 10)
if (int.TryParse(heightValue, out var heightIntValue) && heightIntValue < 10)
{
include = false;
}
Expand All @@ -348,8 +347,7 @@ private static IEnumerable<string> GetImagesInHTMLString(string htmlString)
if (matchWidth.Success)
{
var widthValue = matchWidth.Groups["width"].Value;
int size = 0;
if (int.TryParse(widthValue, out size) && size < 10)
if (int.TryParse(widthValue, out var widthIntValue) && widthIntValue < 10)
{
include = false;
}
Expand All @@ -376,7 +374,7 @@ private static IEnumerable<string> GetImagesInHTMLString(string htmlString)
/// <summary>
/// Dictionary of timezones.
/// </summary>
private static Dictionary<string, string[]> timeZones = new Dictionary<string, string[]>
private static readonly Dictionary<string, string[]> TimeZones = new Dictionary<string, string[]>
{
{ "ACDT", new[] { "-1030", "Australian Central Daylight" } },
{ "ACST", new[] { "-0930", "Australian Central Standard" } },
Expand Down
2 changes: 1 addition & 1 deletion Microsoft.Toolkit.Services/OAuth/OAuthParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public override string ToString()
/// <returns>Formatted string of key / value.</returns>
public string ToString(bool withQuotes)
{
string format = null;
string format;
if (withQuotes)
{
format = "{0}=\"{1}\"";
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 @@ -48,7 +48,7 @@ public ObservableGattDeviceService(GattDeviceService service)
Service = service;
Name = GattUuidsService.ConvertUuidToName(service.Uuid);
UUID = Service.Uuid.ToString();
var t = GetAllCharacteristics();
_ = PopulateAllCharacteristicsAsync();
}

/// <summary>
Expand Down Expand Up @@ -147,10 +147,10 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName
}

/// <summary>
/// Gets all the characteristics of this service
/// Populate the characteristics in <see cref="Characteristics"/>.
/// </summary>
/// <returns>The status of the communication with the GATT device.</returns>
private async Task<GattCommunicationStatus> GetAllCharacteristics()
private async Task<GattCommunicationStatus> PopulateAllCharacteristicsAsync()
{
var tokenSource = new CancellationTokenSource(5000);
var getCharacteristicsTask = await Task.Run(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ public static bool IsRunningAsUwp()
else
{
int length = 0;
StringBuilder sb = new StringBuilder(0);
int result = GetCurrentPackageFullName(ref length, sb);
var sb = new StringBuilder(0);
GetCurrentPackageFullName(ref length, sb);

sb = new StringBuilder(length);
result = GetCurrentPackageFullName(ref length, sb);
int error = GetCurrentPackageFullName(ref length, sb);

_isRunningAsUwp = result != APPMODEL_ERROR_NO_PACKAGE;
_isRunningAsUwp = error != APPMODEL_ERROR_NO_PACKAGE;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Microsoft.Toolkit.Uwp.Notifications
{
Expand Down Expand Up @@ -198,8 +197,8 @@ public ToastContentBuilder AddComboBox(string id, string title, string defaultSe

for (int i = 0; i < choices.Count(); i++)
{
var choice = choices.ElementAt(i);
box.Items.Add(new ToastSelectionBoxItem(choice.comboBoxItemId, choice.comboBoxItemContent));
var (comboBoxItemId, comboBoxItemContent) = choices.ElementAt(i);
box.Items.Add(new ToastSelectionBoxItem(comboBoxItemId, comboBoxItemContent));
}

return AddToastInput(box);
Expand All @@ -208,7 +207,7 @@ public ToastContentBuilder AddComboBox(string id, string title, string defaultSe
/// <summary>
/// Add an input option to the Toast.
/// </summary>
/// <param name="input">An instance of a class that impmement <see cref="IToastInput"/> that will be used on the toast.</param>
/// <param name="input">An instance of a class that implement <see cref="IToastInput"/> that will be used on the toast.</param>
/// <returns>The current instance of <see cref="ToastContentBuilder"/></returns>
public ToastContentBuilder AddToastInput(IToastInput input)
{
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
Loading