Skip to content

Commit 9fc3a62

Browse files
Merge pull request #3189 from windows-toolkit/styleCopUpdate
Updated StyleCop to 1.1.118.
2 parents 2dd783d + 385293b commit 9fc3a62

File tree

20 files changed

+164
-172
lines changed

20 files changed

+164
-172
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.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.Notifications/Toasts/Builder/ToastContentBuilder.Visuals.cs

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -82,50 +82,50 @@ private IList<IToastBindingGenericChild> VisualChildren
8282

8383
#if WINDOWS_UWP
8484

85-
/// <summary>
86-
/// Create an instance of NotificationData that can be used to update toast that has a progress bar.
87-
/// </summary>
88-
/// <param name="toast">Instance of ToastContent that contain progress bars that need to be updated</param>
89-
/// <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>
90-
/// <param name="title">Title of the progress bar.</param>
91-
/// <param name="value">Value of the progress bar.</param>
92-
/// <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>
93-
/// <param name="status"> A status string, which is displayed underneath the progress bar on the left. Default to empty.</param>
94-
/// <param name="sequence">A sequence number to prevent out-of-order updates, or assign 0 to indicate "always update".</param>
95-
/// <returns>An instance of NotificationData that can be used to update the toast.</returns>
96-
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)
97-
{
98-
var progressBar = toast.Visual.BindingGeneric.Children.Where(c => c is AdaptiveProgressBar).ElementAt(index) as AdaptiveProgressBar;
99-
if (progressBar == null)
100-
{
101-
throw new ArgumentException(nameof(toast), "Given toast does not have any progress bar");
102-
}
103-
104-
NotificationData data = new NotificationData();
105-
data.SequenceNumber = sequence;
106-
107-
if (progressBar.Title is BindableString bindableTitle && title != default(string))
108-
{
109-
data.Values[bindableTitle.BindingName] = title;
110-
}
111-
112-
if (progressBar.Value is BindableProgressBarValue bindableProgressValue && value != null)
113-
{
114-
data.Values[bindableProgressValue.BindingName] = value.ToString();
115-
}
116-
117-
if (progressBar.ValueStringOverride is BindableString bindableValueStringOverride && valueStringOverride != default(string))
118-
{
119-
data.Values[bindableValueStringOverride.BindingName] = valueStringOverride;
120-
}
121-
122-
if (progressBar.Status is BindableString bindableStatus && status != default(string))
123-
{
124-
data.Values[bindableStatus.BindingName] = status;
125-
}
126-
127-
return data;
128-
}
85+
/// <summary>
86+
/// Create an instance of NotificationData that can be used to update toast that has a progress bar.
87+
/// </summary>
88+
/// <param name="toast">Instance of ToastContent that contain progress bars that need to be updated</param>
89+
/// <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>
90+
/// <param name="title">Title of the progress bar.</param>
91+
/// <param name="value">Value of the progress bar.</param>
92+
/// <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>
93+
/// <param name="status"> A status string, which is displayed underneath the progress bar on the left. Default to empty.</param>
94+
/// <param name="sequence">A sequence number to prevent out-of-order updates, or assign 0 to indicate "always update".</param>
95+
/// <returns>An instance of NotificationData that can be used to update the toast.</returns>
96+
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)
97+
{
98+
var progressBar = toast.Visual.BindingGeneric.Children.Where(c => c is AdaptiveProgressBar).ElementAt(index) as AdaptiveProgressBar;
99+
if (progressBar == null)
100+
{
101+
throw new ArgumentException(nameof(toast), "Given toast does not have any progress bar");
102+
}
103+
104+
NotificationData data = new NotificationData();
105+
data.SequenceNumber = sequence;
106+
107+
if (progressBar.Title is BindableString bindableTitle && title != default(string))
108+
{
109+
data.Values[bindableTitle.BindingName] = title;
110+
}
111+
112+
if (progressBar.Value is BindableProgressBarValue bindableProgressValue && value != null)
113+
{
114+
data.Values[bindableProgressValue.BindingName] = value.ToString();
115+
}
116+
117+
if (progressBar.ValueStringOverride is BindableString bindableValueStringOverride && valueStringOverride != default(string))
118+
{
119+
data.Values[bindableValueStringOverride.BindingName] = valueStringOverride;
120+
}
121+
122+
if (progressBar.Status is BindableString bindableStatus && status != default(string))
123+
{
124+
data.Values[bindableStatus.BindingName] = status;
125+
}
126+
127+
return data;
128+
}
129129

130130
#endif
131131

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ private static void OnKeyChanged(DependencyObject d, DependencyPropertyChangedEv
412412
{
413413
(frame.Content as Page)?.UnregisterElementForConnectedAnimation(oldKey);
414414
}
415+
415416
if (e.NewValue is string newKey)
416417
{
417418
(frame.Content as Page)?.RegisterElementForConnectedAnimation(newKey, element);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ private void Frame_Navigated(object sender, Windows.UI.Xaml.Navigation.Navigatio
116116
return;
117117
}
118118

119-
void loadedHandler(object s, RoutedEventArgs args)
119+
void LoadedHandler(object s, RoutedEventArgs args)
120120
{
121121
var page = s as Page;
122-
page.Loaded -= loadedHandler;
122+
page.Loaded -= LoadedHandler;
123123

124124
object parameter;
125125
if (_nextParameter != null)
@@ -204,7 +204,7 @@ void loadedHandler(object s, RoutedEventArgs args)
204204
_nextParameter = null;
205205
}
206206

207-
navigatedPage.Loaded += loadedHandler;
207+
navigatedPage.Loaded += LoadedHandler;
208208
}
209209

210210
private void UseDirectConnectedAnimationConfiguration(ConnectedAnimation animation)

Microsoft.Toolkit.Uwp.UI.Animations/Extensions/AnimationExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ private static CompositionEasingFunction GenerateCompositionEasingFunctionFromEa
184184
// Pay-per-play caching of easing functions
185185
EnsureEasingsCached();
186186

187-
if (_compositionEasingFunctions.TryGetValue((easingType.ToString(), easingMode), out(Vector2, Vector2) points))
187+
if (_compositionEasingFunctions.TryGetValue((easingType.ToString(), easingMode), out (Vector2, Vector2) points))
188188
{
189189
return compositor.CreateCubicBezierEasingFunction(points.Item1, points.Item2);
190190
}

Microsoft.Toolkit.Uwp.UI.Controls.DataGrid/CollectionViews/ListCollectionView.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ protected override void RefreshOverride()
9090
if (!UsesLocalArray)
9191
{
9292
#endif
93-
_internalList = list;
93+
#pragma warning disable SA1137 // Elements should have the same indentation
94+
_internalList = list;
95+
#pragma warning restore SA1137 // Elements should have the same indentation
9496
#if FEATURE_ICOLLECTIONVIEW_SORT_OR_FILTER
9597
}
9698
else
@@ -1979,6 +1981,7 @@ private IList PrepareLocalArray(IList list)
19791981
private void MoveCurrencyOffDeletedElement(int oldCurrentPosition)
19801982
{
19811983
int lastPosition = InternalCount - 1; // OK if last is -1
1984+
19821985
// if position falls beyond last position, move back to last position
19831986
int newPosition = (oldCurrentPosition < lastPosition) ? oldCurrentPosition : lastPosition;
19841987

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,38 +99,32 @@ protected override object GetPatternCore(PatternInterface patternInterface)
9999
switch (patternInterface)
100100
{
101101
case PatternInterface.Invoke:
102-
{
103-
// this.OwningHeader.OwningGrid.DataConnection.AllowSort property is ignored because of the DataGrid.Sorting custom sorting capability.
104-
if (this.OwningHeader.OwningGrid.CanUserSortColumns &&
105-
this.OwningHeader.OwningColumn.CanUserSort)
102+
// this.OwningHeader.OwningGrid.DataConnection.AllowSort property is ignored because of the DataGrid.Sorting custom sorting capability.
103+
if (this.OwningHeader.OwningGrid.CanUserSortColumns &&
104+
this.OwningHeader.OwningColumn.CanUserSort)
106105
{
107106
return this;
108107
}
109108

110109
break;
111-
}
112110

113111
case PatternInterface.ScrollItem:
114-
{
115112
if (this.OwningHeader.OwningGrid.HorizontalScrollBar != null &&
116113
this.OwningHeader.OwningGrid.HorizontalScrollBar.Maximum > 0)
117114
{
118115
return this;
119116
}
120117

121118
break;
122-
}
123119

124120
case PatternInterface.Transform:
125-
{
126121
if (this.OwningHeader.OwningColumn != null &&
127122
this.OwningHeader.OwningColumn.ActualCanUserResize)
128123
{
129124
return this;
130125
}
131126

132127
break;
133-
}
134128
}
135129
}
136130

0 commit comments

Comments
 (0)