Skip to content

Commit 892e488

Browse files
authored
Merge branch 'master' into dev/jackil/mtbFix
2 parents 96b39ec + 87b0d06 commit 892e488

File tree

88 files changed

+389
-515
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+389
-515
lines changed

.editorconfig

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,87 @@ dotnet_naming_rule.interface_types_must_be_prefixed_with_i.style
236236
dotnet_naming_style.prefix_private_field_with_underscore.capitalization = camel_case
237237
dotnet_naming_style.prefix_private_field_with_underscore.required_prefix = _
238238

239+
# Code files
240+
[*.{cs,vb}]
241+
242+
# Migrate back from old Toolkit.ruleset
243+
dotnet_diagnostic.CA1001.severity = warning
244+
dotnet_diagnostic.CA1009.severity = warning
245+
dotnet_diagnostic.CA1016.severity = warning
246+
dotnet_diagnostic.CA1033.severity = warning
247+
dotnet_diagnostic.CA1049.severity = warning
248+
dotnet_diagnostic.CA1060.severity = warning
249+
dotnet_diagnostic.CA1061.severity = warning
250+
dotnet_diagnostic.CA1063.severity = warning
251+
dotnet_diagnostic.CA1065.severity = warning
252+
dotnet_diagnostic.CA1301.severity = warning
253+
dotnet_diagnostic.CA1400.severity = warning
254+
dotnet_diagnostic.CA1401.severity = warning
255+
dotnet_diagnostic.CA1403.severity = warning
256+
dotnet_diagnostic.CA1404.severity = warning
257+
dotnet_diagnostic.CA1405.severity = warning
258+
dotnet_diagnostic.CA1410.severity = warning
259+
dotnet_diagnostic.CA1415.severity = warning
260+
dotnet_diagnostic.CA1821.severity = warning
261+
dotnet_diagnostic.CA1900.severity = warning
262+
dotnet_diagnostic.CA1901.severity = warning
263+
dotnet_diagnostic.CA2002.severity = warning
264+
dotnet_diagnostic.CA2100.severity = warning
265+
dotnet_diagnostic.CA2101.severity = warning
266+
dotnet_diagnostic.CA2108.severity = warning
267+
dotnet_diagnostic.CA2111.severity = warning
268+
dotnet_diagnostic.CA2112.severity = warning
269+
dotnet_diagnostic.CA2114.severity = warning
270+
dotnet_diagnostic.CA2116.severity = warning
271+
dotnet_diagnostic.CA2117.severity = warning
272+
dotnet_diagnostic.CA2122.severity = warning
273+
dotnet_diagnostic.CA2123.severity = warning
274+
dotnet_diagnostic.CA2124.severity = warning
275+
dotnet_diagnostic.CA2126.severity = warning
276+
dotnet_diagnostic.CA2131.severity = warning
277+
dotnet_diagnostic.CA2132.severity = warning
278+
dotnet_diagnostic.CA2133.severity = warning
279+
dotnet_diagnostic.CA2134.severity = warning
280+
dotnet_diagnostic.CA2137.severity = warning
281+
dotnet_diagnostic.CA2138.severity = warning
282+
dotnet_diagnostic.CA2140.severity = warning
283+
dotnet_diagnostic.CA2141.severity = warning
284+
dotnet_diagnostic.CA2146.severity = warning
285+
dotnet_diagnostic.CA2147.severity = warning
286+
dotnet_diagnostic.CA2149.severity = warning
287+
dotnet_diagnostic.CA2200.severity = warning
288+
dotnet_diagnostic.CA2202.severity = warning
289+
dotnet_diagnostic.CA2207.severity = warning
290+
dotnet_diagnostic.CA2212.severity = warning
291+
dotnet_diagnostic.CA2213.severity = warning
292+
dotnet_diagnostic.CA2214.severity = warning
293+
dotnet_diagnostic.CA2216.severity = warning
294+
dotnet_diagnostic.CA2220.severity = warning
295+
dotnet_diagnostic.CA2229.severity = warning
296+
dotnet_diagnostic.CA2231.severity = warning
297+
dotnet_diagnostic.CA2232.severity = warning
298+
dotnet_diagnostic.CA2235.severity = warning
299+
dotnet_diagnostic.CA2236.severity = warning
300+
dotnet_diagnostic.CA2237.severity = warning
301+
dotnet_diagnostic.CA2238.severity = warning
302+
dotnet_diagnostic.CA2240.severity = warning
303+
dotnet_diagnostic.CA2241.severity = warning
304+
dotnet_diagnostic.CA2242.severity = warning
305+
dotnet_diagnostic.SA1011.severity = none
306+
dotnet_diagnostic.SA1101.severity = none
307+
dotnet_diagnostic.SA1118.severity = none
308+
dotnet_diagnostic.SA1200.severity = none
309+
dotnet_diagnostic.SA1201.severity = none
310+
dotnet_diagnostic.SA1202.severity = none
311+
dotnet_diagnostic.SA1309.severity = none
312+
dotnet_diagnostic.SA1310.severity = none
313+
dotnet_diagnostic.SA1600.severity = none
314+
dotnet_diagnostic.SA1602.severity = none
315+
dotnet_diagnostic.SA1611.severity = none
316+
dotnet_diagnostic.SA1633.severity = none
317+
dotnet_diagnostic.SA1634.severity = none
318+
dotnet_diagnostic.SA1652.severity = none
319+
320+
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.
321+
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.
322+
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.

Directory.Build.props

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<PackageLicenseUrl>https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/master/license.md</PackageLicenseUrl>
1010
<PackageReleaseNotes>v3.0 release https://github.com/windows-toolkit/WindowsCommunityToolkit/releases</PackageReleaseNotes>
1111
<Copyright>(c) .NET Foundation and Contributors. All rights reserved.</Copyright>
12-
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)Toolkit.ruleset</CodeAnalysisRuleSet>
1312
<DefaultLanguage>en-US</DefaultLanguage>
1413
<IsDesignProject>$(MSBuildProjectName.Contains('.Design'))</IsDesignProject>
1514
<IsTestProject>$(MSBuildProjectName.Contains('Test'))</IsTestProject>
@@ -62,7 +61,7 @@
6261
<When Condition="'$(IsTestProject)' != 'true' and '$(IsSampleProject)' != 'true' and '$(IsDesignProject)' != 'true'">
6362
<ItemGroup>
6463
<!--<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="15.3.83" PrivateAssets="all" />-->
65-
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2" PrivateAssets="all" />
64+
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
6665

6766
<EmbeddedResource Include="**\*.rd.xml" />
6867
<Page Include="**\*.xaml" Exclude="**\bin\**\*.xaml;**\obj\**\*.xaml" SubType="Designer" Generator="MSBuild:Compile" />

Microsoft.Toolkit.Parsers/Markdown/Blocks/YamlHeaderBlock.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
using System;
66
using System.Collections.Generic;
7-
using System.Text;
87
using Microsoft.Toolkit.Parsers.Markdown.Helpers;
98

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

110109
var result = new YamlHeaderBlock();
111-
var keys = new List<string>();
112-
var values = new List<string>();
113110
result.Children = new Dictionary<string, string>();
114111
foreach (var item in elements)
115112
{

Microsoft.Toolkit.Parsers/Markdown/Inlines/ImageInline.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ internal static void AddTripChars(List<InlineTripCharHelper> tripCharHelpers)
7373
/// <returns> A parsed markdown image, or <c>null</c> if this is not a markdown image. </returns>
7474
internal static InlineParseResult Parse(string markdown, int start, int end)
7575
{
76-
int refstart = 0;
77-
7876
// Expect a '!' character.
7977
if (start >= end || markdown[start] != '!')
8078
{
@@ -120,7 +118,7 @@ internal static InlineParseResult Parse(string markdown, int start, int end)
120118

121119
if (pos < end && markdown[pos] == '[')
122120
{
123-
refstart = pos;
121+
int refstart = pos;
124122

125123
// Find the reference ']' character
126124
while (pos < end)

Microsoft.Toolkit.Parsers/Markdown/MarkdownDocument.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public MarkdownDocument()
5555
/// <param name="markdownText"> The markdown text. </param>
5656
public void Parse(string markdownText)
5757
{
58-
Blocks = Parse(markdownText, 0, markdownText.Length, quoteDepth: 0, actualEnd: out int actualEnd);
58+
Blocks = Parse(markdownText, 0, markdownText.Length, quoteDepth: 0, actualEnd: out _);
5959

6060
// Remove any references from the list of blocks, and add them to a dictionary.
6161
for (int i = Blocks.Count - 1; i >= 0; i--)

Microsoft.Toolkit.Parsers/Rss/RssHelper.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,9 @@ public static string TimeZoneToOffset(string tz)
311311

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

314-
if (timeZones.ContainsKey(tz))
314+
if (TimeZones.ContainsKey(tz))
315315
{
316-
return timeZones[tz].First();
316+
return TimeZones[tz].First();
317317
}
318318

319319
return null;
@@ -337,8 +337,7 @@ private static IEnumerable<string> GetImagesInHTMLString(string htmlString)
337337
if (matchHeight.Success)
338338
{
339339
var heightValue = matchHeight.Groups["height"].Value;
340-
int size = 0;
341-
if (int.TryParse(heightValue, out size) && size < 10)
340+
if (int.TryParse(heightValue, out var heightIntValue) && heightIntValue < 10)
342341
{
343342
include = false;
344343
}
@@ -348,8 +347,7 @@ private static IEnumerable<string> GetImagesInHTMLString(string htmlString)
348347
if (matchWidth.Success)
349348
{
350349
var widthValue = matchWidth.Groups["width"].Value;
351-
int size = 0;
352-
if (int.TryParse(widthValue, out size) && size < 10)
350+
if (int.TryParse(widthValue, out var widthIntValue) && widthIntValue < 10)
353351
{
354352
include = false;
355353
}
@@ -376,7 +374,7 @@ private static IEnumerable<string> GetImagesInHTMLString(string htmlString)
376374
/// <summary>
377375
/// Dictionary of timezones.
378376
/// </summary>
379-
private static Dictionary<string, string[]> timeZones = new Dictionary<string, string[]>
377+
private static readonly Dictionary<string, string[]> TimeZones = new Dictionary<string, string[]>
380378
{
381379
{ "ACDT", new[] { "-1030", "Australian Central Daylight" } },
382380
{ "ACST", new[] { "-0930", "Australian Central Standard" } },

Microsoft.Toolkit.Services/OAuth/OAuthParameter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public override string ToString()
4949
/// <returns>Formatted string of key / value.</returns>
5050
public string ToString(bool withQuotes)
5151
{
52-
string format = null;
52+
string format;
5353
if (withQuotes)
5454
{
5555
format = "{0}=\"{1}\"";

Microsoft.Toolkit.Services/Services/LinkedIn/LinkedInDataProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public async Task LogoutAsync()
176176
if (crendential != null)
177177
{
178178
_passwordManager.Remove(LinkedInConstants.STORAGEKEYACCESSTOKEN);
179-
await _storageManager.SetAsync(LinkedInConstants.STORAGEKEYUSER, null);
179+
await _storageManager.SetAsync(LinkedInConstants.STORAGEKEYUSER, null);
180180
}
181181

182182
LoggedIn = false;

Microsoft.Toolkit.Services/Services/Weibo/WeiboDataProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public async Task LogoutAsync()
185185
if (credential != null)
186186
{
187187
_passwordManager.Remove(PasswordKey);
188-
await _storageManager.SetAsync(StorageKey, null);
188+
await _storageManager.SetAsync(StorageKey, null);
189189
}
190190

191191
Uid = null;

Microsoft.Toolkit.Uwp.Connectivity/BluetoothLEHelper/ObservableGattDeviceService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public ObservableGattDeviceService(GattDeviceService service)
4848
Service = service;
4949
Name = GattUuidsService.ConvertUuidToName(service.Uuid);
5050
UUID = Service.Uuid.ToString();
51-
var t = GetAllCharacteristics();
51+
_ = PopulateAllCharacteristicsAsync();
5252
}
5353

5454
/// <summary>
@@ -147,10 +147,10 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName
147147
}
148148

149149
/// <summary>
150-
/// Gets all the characteristics of this service
150+
/// Populate the characteristics in <see cref="Characteristics"/>.
151151
/// </summary>
152152
/// <returns>The status of the communication with the GATT device.</returns>
153-
private async Task<GattCommunicationStatus> GetAllCharacteristics()
153+
private async Task<GattCommunicationStatus> PopulateAllCharacteristicsAsync()
154154
{
155155
var tokenSource = new CancellationTokenSource(5000);
156156
var getCharacteristicsTask = await Task.Run(

0 commit comments

Comments
 (0)