Skip to content

Commit 5e030db

Browse files
authored
Merge pull request #3155 from vgromfeld/u/vgromfeld/removeUnusedFields
Remove IDE0059: Value assigned to variable is never used
2 parents abf77ed + d55bdd1 commit 5e030db

File tree

62 files changed

+135
-319
lines changed

Some content is hidden

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

62 files changed

+135
-319
lines changed

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
{

0 commit comments

Comments
 (0)