Skip to content

Commit 9d510f0

Browse files
authored
Merge branch 'master' into optimization/dispatcher-helper
2 parents 7dcce8a + 5e030db commit 9d510f0

File tree

106 files changed

+9484
-375
lines changed

Some content is hidden

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

106 files changed

+9484
-375
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,6 @@ msbuild.binlog
225225
*.project.lock.json
226226
/build/tools/**
227227
!/build/tools/packages.config
228+
229+
# Generated file from .ttinclude
230+
**/Generated/TypeInfo.g.cs

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.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(

Microsoft.Toolkit.Uwp.Notifications/DesktopNotificationManager/DesktopNotificationManagerCompat.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,13 @@ public static bool IsRunningAsUwp()
181181
else
182182
{
183183
int length = 0;
184-
StringBuilder sb = new StringBuilder(0);
185-
int result = GetCurrentPackageFullName(ref length, sb);
184+
var sb = new StringBuilder(0);
185+
GetCurrentPackageFullName(ref length, sb);
186186

187187
sb = new StringBuilder(length);
188-
result = GetCurrentPackageFullName(ref length, sb);
188+
int error = GetCurrentPackageFullName(ref length, sb);
189189

190-
_isRunningAsUwp = result != APPMODEL_ERROR_NO_PACKAGE;
190+
_isRunningAsUwp = error != APPMODEL_ERROR_NO_PACKAGE;
191191
}
192192
}
193193

Microsoft.Toolkit.Uwp.Notifications/Toasts/Builder/ToastContentBuilder.Actions.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System;
66
using System.Collections.Generic;
77
using System.Linq;
8-
using System.Text;
98

109
namespace Microsoft.Toolkit.Uwp.Notifications
1110
{
@@ -198,8 +197,8 @@ public ToastContentBuilder AddComboBox(string id, string title, string defaultSe
198197

199198
for (int i = 0; i < choices.Count(); i++)
200199
{
201-
var choice = choices.ElementAt(i);
202-
box.Items.Add(new ToastSelectionBoxItem(choice.comboBoxItemId, choice.comboBoxItemContent));
200+
var (comboBoxItemId, comboBoxItemContent) = choices.ElementAt(i);
201+
box.Items.Add(new ToastSelectionBoxItem(comboBoxItemId, comboBoxItemContent));
203202
}
204203

205204
return AddToastInput(box);
@@ -208,7 +207,7 @@ public ToastContentBuilder AddComboBox(string id, string title, string defaultSe
208207
/// <summary>
209208
/// Add an input option to the Toast.
210209
/// </summary>
211-
/// <param name="input">An instance of a class that impmement <see cref="IToastInput"/> that will be used on the toast.</param>
210+
/// <param name="input">An instance of a class that implement <see cref="IToastInput"/> that will be used on the toast.</param>
212211
/// <returns>The current instance of <see cref="ToastContentBuilder"/></returns>
213212
public ToastContentBuilder AddToastInput(IToastInput input)
214213
{

Microsoft.Toolkit.Uwp.Notifications/Toasts/ToastPeople.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public sealed class ToastPeople
3131

3232
internal void PopulateToastElement(Element_Toast toast)
3333
{
34-
string hintPeople = null;
34+
string hintPeople;
3535

3636
if (RemoteId != null)
3737
{

Microsoft.Toolkit.Uwp.PlatformDifferencesGen/Program.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,11 @@ public static string AssemblyDirectory
191191

192192
private static Dictionary<string, List<string>> ProcessAssembly(Assembly assembly)
193193
{
194-
int pos = assembly.FullName.IndexOf(", Culture");
195-
196-
string fileName = $"{assembly.FullName.Substring(0, pos)}.json";
197-
198-
Dictionary<string, List<string>> types = new Dictionary<string, List<string>>();
194+
var types = new Dictionary<string, List<string>>();
199195

200196
foreach (var exportedType in assembly.ExportedTypes)
201197
{
202-
List<string> members = new List<string>();
198+
var members = new List<string>();
203199

204200
if (exportedType.IsEnum)
205201
{

Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/Analyzer.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,7 @@ public static HowToGuard GetGuardForSymbol(ISymbol target)
314314

315315
private static TypePresenceIndicator CheckCollectionForType(Dictionary<string, List<NewMember>> collection, string typeName, ISymbol symbol)
316316
{
317-
List<NewMember> newMembers = null;
318-
319-
if (!collection.TryGetValue(typeName, out newMembers))
317+
if (!collection.TryGetValue(typeName, out var newMembers))
320318
{
321319
return TypePresenceIndicator.NotFound;
322320
}

Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformSpecificAnalyzerCS.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,7 @@ private void AnalyzeExpression(SyntaxNodeAnalysisContext context, ConcurrentDict
202202
}
203203

204204
var line = loc.GetLineSpan().StartLinePosition.Line;
205-
206-
Diagnostic diagnostic = null;
207-
208-
if (reports.TryGetValue(line, out diagnostic) && diagnostic.Location.SourceSpan.Start <= loc.SourceSpan.Start)
205+
if (reports.TryGetValue(line, out var diagnostic) && diagnostic.Location.SourceSpan.Start <= loc.SourceSpan.Start)
209206
{
210207
return;
211208
}

Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer/PlatformSpecificAnalyzerVB.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,7 @@ private void AnalyzeExpression(SyntaxNodeAnalysisContext context, ConcurrentDict
226226
}
227227

228228
var line = loc.GetLineSpan().StartLinePosition.Line;
229-
230-
Diagnostic diagnostic = null;
231-
232-
if (reports.TryGetValue(line, out diagnostic) && diagnostic.Location.SourceSpan.Start <= loc.SourceSpan.Start)
229+
if (reports.TryGetValue(line, out var diagnostic) && diagnostic.Location.SourceSpan.Start <= loc.SourceSpan.Start)
233230
{
234231
return;
235232
}

Microsoft.Toolkit.Uwp.SampleApp/Pages/SampleController.xaml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Linq;
99
using System.Reflection;
1010
using System.Runtime.CompilerServices;
11-
using System.Threading.Tasks;
1211
using Microsoft.Toolkit.Uwp.SampleApp.Common;
1312
using Microsoft.Toolkit.Uwp.SampleApp.Controls;
1413
using Microsoft.Toolkit.Uwp.SampleApp.Models;
@@ -165,7 +164,7 @@ public void RefreshXamlRender()
165164
{
166165
if (CurrentSample != null)
167166
{
168-
var code = string.Empty;
167+
string code;
169168
if (InfoAreaPivot.SelectedItem == PropertiesPivotItem)
170169
{
171170
code = CurrentSample.BindedXamlCode;

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ImageCache/ImageCachePage.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private async Task PreCacheImages(bool loadInMemory = false)
6666
private async Task LoadDataAsync()
6767
{
6868
var source = new PhotosDataSource();
69-
_photoItems = await new PhotosDataSource().GetItemsAsync(true);
69+
_photoItems = await source.GetItemsAsync(true);
7070
}
7171

7272
private async void PreCache_Tapped(object sender, RoutedEventArgs e)

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/LinkedIn Service/LinkedInPage.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private async void ConnectButton_Click(object sender, RoutedEventArgs e)
3939
CallbackUri = CallbackUri.Text
4040
};
4141

42-
var succeeded = LinkedInService.Instance.Initialize(oAuthTokens, LinkedInPermissions.ReadBasicProfile | LinkedInPermissions.WriteShare);
42+
LinkedInService.Instance.Initialize(oAuthTokens, LinkedInPermissions.ReadBasicProfile | LinkedInPermissions.WriteShare);
4343

4444
var loggedIn = await LinkedInService.Instance.LoginAsync();
4545

@@ -66,7 +66,7 @@ private async void ShareButton_Click(object sender, RoutedEventArgs e)
6666
return;
6767
}
6868

69-
var response = await LinkedInService.Instance.ShareActivityAsync(ShareText.Text);
69+
await LinkedInService.Instance.ShareActivityAsync(ShareText.Text);
7070

7171
var message = new MessageDialog("Share sent to LinkedIn");
7272
await message.ShowAsync();

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/LiveTile/LiveTilePage.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private void Initialize()
170170
tile.VisualElements.Square150x150Logo = Constants.Square150x150Logo;
171171
tile.VisualElements.Wide310x150Logo = Constants.Wide310x150Logo;
172172
tile.VisualElements.Square310x310Logo = Constants.Square310x310Logo;
173-
var dontWait = tile.UpdateAsync(); // Commit changes (no need to await)
173+
_ = tile.UpdateAsync(); // Commit changes (no need to await)
174174

175175
tile.CreateTileUpdater().Update(new TileNotification(_tileContent.GetXml()));
176176
}

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/MarkdownTextBlock/MarkdownTextBlockPage.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private void Current_ThemeChanged(object sender, Models.ThemeChangedArgs e)
5757

5858
private async void MarkdownText_ImageClicked(object sender, LinkClickedEventArgs e)
5959
{
60-
if (!Uri.TryCreate(e.Link, UriKind.Absolute, out Uri result))
60+
if (!Uri.IsWellFormedUriString(e.Link, UriKind.Absolute))
6161
{
6262
await new MessageDialog("Masked relative Images needs to be manually handled.").ShowAsync();
6363
}
@@ -91,7 +91,7 @@ private void SetInitalText(string text)
9191

9292
private async void MarkdownText_LinkClicked(object sender, LinkClickedEventArgs e)
9393
{
94-
if (!Uri.TryCreate(e.Link, UriKind.Absolute, out Uri result))
94+
if (!Uri.IsWellFormedUriString(e.Link, UriKind.Absolute))
9595
{
9696
await new MessageDialog("Masked relative links needs to be manually handled.").ShowAsync();
9797
}

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/RadialGauge/RadialGaugeCode.bind

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
MinAngle="@[MinAngle:Slider:210:0-360]"
2727
MaxAngle="@[MaxAngle:Slider:150:0-360]"
2828
Unit="units"
29+
ValueStringFormat="@[ValueStringFormat:String:N0]"
2930
NeedleWidth="@[NeedleWidth:Slider:4:1-10]"
3031
NeedleLength="@[NeedleLength:Slider:100:20-100]"
3132
TickLength="@[TickLength:Slider:10:0-30]"

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/WeatherLiveTileAndToast/WeatherLiveTileAndToastPage.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ private void Initialize()
314314
tile.VisualElements.Square150x150Logo = Constants.Square150x150Logo;
315315
tile.VisualElements.Wide310x150Logo = Constants.Wide310x150Logo;
316316
tile.VisualElements.Square310x310Logo = Constants.Square310x310Logo;
317-
var dontWait = tile.UpdateAsync(); // Commit changes (no need to await)
317+
_ = tile.UpdateAsync(); // Commit changes (no need to await)
318318

319319
tile.CreateTileUpdater().Update(new TileNotification(_tileContent.GetXml()));
320320
}

Microsoft.Toolkit.Uwp.SampleApp/Shell.SamplePicker.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ private Sample CurrentSample
3636
set
3737
{
3838
_currentSample = value;
39-
var nop = SetNavViewSelection();
39+
_ = SetNavViewSelectionAsync();
4040
}
4141
}
4242

43-
private async Task SetNavViewSelection()
43+
private async Task SetNavViewSelectionAsync()
4444
{
4545
if (_currentSample != null)
4646
{
@@ -59,10 +59,10 @@ private async Task SetNavViewSelection()
5959

6060
private void HideSamplePicker()
6161
{
62-
SamplePickerGrid.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
62+
SamplePickerGrid.Visibility = Visibility.Collapsed;
6363
_selectedCategory = null;
6464

65-
var noop = SetNavViewSelection();
65+
_ = SetNavViewSelectionAsync();
6666
}
6767

6868
private async void ShowSamplePicker(Sample[] samples = null, bool group = false)
@@ -323,7 +323,7 @@ private void HideMoreInfo()
323323
animation.Configuration = new DirectConnectedAnimationConfiguration();
324324
}
325325

326-
var t = SamplePickerGridView.TryStartConnectedAnimationAsync(animation, MoreInfoContent.DataContext, "SampleIcon");
326+
_ = SamplePickerGridView.TryStartConnectedAnimationAsync(animation, MoreInfoContent.DataContext, "SampleIcon");
327327
}
328328

329329
MoreInfoContent.DataContext = null;

Microsoft.Toolkit.Uwp.UI.Animations/ConnectedAnimations/ConnectedAnimationHelper.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ internal void SetParameterForNextFrameNavigation(object parameter)
5050

5151
private void Frame_Navigating(object sender, Windows.UI.Xaml.Navigation.NavigatingCancelEventArgs e)
5252
{
53-
object parameter = null;
54-
53+
object parameter;
5554
if (_nextParameter != null)
5655
{
5756
parameter = _nextParameter;

Microsoft.Toolkit.Uwp.UI.Animations/Expressions/ExpressionNodes/ExpressionNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ private string GetOperationString()
473473

474474
private string ToExpressionStringInternal()
475475
{
476-
string ret = string.Empty;
476+
string ret;
477477

478478
// Do a recursive depth-first traversal of the node tree to print out the full expression string
479479
switch (GetOperationKind())

Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/DataGrid/Automation/DataGridAutomationPeer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,8 +724,7 @@ internal void PopulateItemPeers()
724724
{
725725
if (item != null)
726726
{
727-
DataGridItemAutomationPeer peer = null;
728-
727+
DataGridItemAutomationPeer peer;
729728
if (oldChildren.ContainsKey(item))
730729
{
731730
peer = oldChildren[item] as DataGridItemAutomationPeer;

0 commit comments

Comments
 (0)