perf: Enable LINQ-related performance analyzers
This commit is contained in:
Родитель
95f45dccd6
Коммит
6ae07518c0
|
@ -238,6 +238,11 @@ dotnet_diagnostic.RS0030.severity = error
|
|||
dotnet_analyzer_diagnostic.category-Performance.severity = none #error - Uncomment when all violations are fixed.
|
||||
|
||||
dotnet_diagnostic.CA1805.severity = error
|
||||
dotnet_diagnostic.CA1826.severity = error
|
||||
dotnet_diagnostic.CA1827.severity = error
|
||||
dotnet_diagnostic.CA1828.severity = error
|
||||
dotnet_diagnostic.CA1829.severity = error
|
||||
|
||||
dotnet_diagnostic.CA1061.severity = none
|
||||
dotnet_diagnostic.CA1802.severity = none
|
||||
dotnet_diagnostic.CA1014.severity = none
|
||||
|
@ -290,7 +295,6 @@ dotnet_diagnostic.CA1508.severity = none
|
|||
dotnet_diagnostic.CA2008.severity = none
|
||||
dotnet_diagnostic.CA1810.severity = none
|
||||
dotnet_diagnostic.CA1309.severity = none
|
||||
dotnet_diagnostic.CA1829.severity = none
|
||||
dotnet_diagnostic.CA3075.severity = none
|
||||
dotnet_diagnostic.CA1815.severity = none
|
||||
dotnet_diagnostic.CA1819.severity = none
|
||||
|
@ -302,7 +306,6 @@ dotnet_diagnostic.CA2214.severity = none
|
|||
dotnet_diagnostic.CA1033.severity = none
|
||||
dotnet_diagnostic.CA2213.severity = none
|
||||
dotnet_diagnostic.CA1068.severity = none
|
||||
dotnet_diagnostic.CA1826.severity = none
|
||||
dotnet_diagnostic.CA2016.severity = none
|
||||
dotnet_diagnostic.CA1835.severity = none
|
||||
dotnet_diagnostic.CA1069.severity = none
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
[*.cs]
|
||||
dotnet_analyzer_diagnostic.category-Performance.severity = none
|
||||
dotnet_diagnostic.CA1805.severity = none
|
||||
dotnet_diagnostic.CA1805.severity = none
|
||||
dotnet_diagnostic.CA1036.severity = none
|
|
@ -329,7 +329,7 @@ namespace SampleControl.Presentation
|
|||
|
||||
if (_log.IsEnabled(LogLevel.Debug))
|
||||
{
|
||||
_log.Debug($"Generating tests for {tests.Count()} test in {folderName}");
|
||||
_log.Debug($"Generating tests for {tests.Length} test in {folderName}");
|
||||
}
|
||||
|
||||
var target = new Windows.UI.Xaml.Media.Imaging.RenderTargetBitmap();
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace SamplesApp.Windows_UI_Xaml_Controls.ListView
|
|||
return FirstItemStyle;
|
||||
}
|
||||
|
||||
var itemsCount = itemsControl.Items?.Count() ?? (itemsControl.ItemsSource as IEnumerable)?.Cast<object>().Count() ?? 0;
|
||||
var itemsCount = itemsControl.Items?.Count ?? (itemsControl.ItemsSource as IEnumerable)?.Cast<object>().Count() ?? 0;
|
||||
if (index == itemsCount - 1)
|
||||
{
|
||||
return LastItemStyle;
|
||||
|
|
|
@ -165,7 +165,7 @@ namespace MonoTests.Uno.Xaml
|
|||
public void GetXamlTypeAndAllXamlTypes ()
|
||||
{
|
||||
var ctx = new XamlSchemaContext (new Assembly [] {typeof (string).Assembly}); // build with corlib.
|
||||
Assert.AreEqual (0, ctx.GetAllXamlTypes (XamlLanguage.Xaml2006Namespace).Count (), "#0"); // premise
|
||||
Assert.AreEqual (0, ctx.GetAllXamlTypes (XamlLanguage.Xaml2006Namespace).Count, "#0"); // premise
|
||||
|
||||
var xt = ctx.GetXamlType (typeof (string));
|
||||
Assert.IsNotNull (xt, "#1");
|
||||
|
@ -176,7 +176,7 @@ namespace MonoTests.Uno.Xaml
|
|||
Assert.IsTrue (object.ReferenceEquals (ctx.GetXamlType (GetType ()), ctx.GetXamlType (GetType ())), "#4");
|
||||
|
||||
// after getting these types, it still returns 0. So it's not all about caching.
|
||||
Assert.AreEqual (0, ctx.GetAllXamlTypes (XamlLanguage.Xaml2006Namespace).Count (), "#5");
|
||||
Assert.AreEqual (0, ctx.GetAllXamlTypes (XamlLanguage.Xaml2006Namespace).Count, "#5");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -197,7 +197,7 @@ namespace MonoTests.Uno.Xaml
|
|||
// There are some special types that have non-default name: MemberDefinition, PropertyDefinition
|
||||
|
||||
var l = ctx.GetAllXamlTypes (XamlLanguage.Xaml2006Namespace);
|
||||
Assert.IsTrue (l.Count () > 40, "#1");
|
||||
Assert.IsTrue (l.Count > 40, "#1");
|
||||
Assert.IsTrue (l.Any (t => t.UnderlyingType == typeof (MemberDefinition)), "#2");
|
||||
Assert.IsTrue (l.Any (t => t.Name == "AmbientAttribute"), "#3");
|
||||
Assert.IsTrue (l.Any (t => t.Name == "XData"), "#4");
|
||||
|
|
|
@ -319,7 +319,7 @@ namespace Uno.UI.SourceGenerators.Telemetry.PersistenceChannel
|
|||
{
|
||||
string[] storageFiles = Directory.GetFiles(StorageFolder, "*.*");
|
||||
|
||||
_storageCountFiles = storageFiles.Count();
|
||||
_storageCountFiles = storageFiles.Length;
|
||||
|
||||
long storageSizeInBytes = 0;
|
||||
foreach (string file in storageFiles)
|
||||
|
|
|
@ -647,7 +647,7 @@ namespace Uno.UI.SourceGenerators.XamlGenerator
|
|||
}
|
||||
|
||||
#if DEBUG
|
||||
Console.Write(resourceKeys.Count() + " localization keys found");
|
||||
Console.Write(resourceKeys.Length + " localization keys found");
|
||||
#endif
|
||||
return resourceKeys;
|
||||
}
|
||||
|
|
|
@ -3263,7 +3263,7 @@ namespace Uno.UI.SourceGenerators.XamlGenerator
|
|||
closureName
|
||||
);
|
||||
|
||||
if (member.Objects.Count() == 1)
|
||||
if (member.Objects.Count == 1)
|
||||
{
|
||||
BuildChild(writer, member, member.Objects.First());
|
||||
}
|
||||
|
@ -6217,7 +6217,7 @@ namespace Uno.UI.SourceGenerators.XamlGenerator
|
|||
if (type != null)
|
||||
{
|
||||
var q = from m in type.Constructors
|
||||
where m.Parameters.Count() == 1
|
||||
where m.Parameters.Length == 1
|
||||
where SymbolEqualityComparer.Default.Equals(m.Parameters.First().Type, _androidContentContextSymbol)
|
||||
select m;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Uno.Extensions
|
|||
.OriginalString
|
||||
.Split(new[] { '?', '&' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(p => p.Split(new[] { '=' }))
|
||||
.Where(parts => parts.Count() > 1)
|
||||
.Where(parts => parts.Length > 1)
|
||||
.ToDictionary(parts => parts[0], parts => String.Join("=", parts.Skip(1)));
|
||||
}
|
||||
|
||||
|
|
|
@ -2556,7 +2556,7 @@ namespace Windows.UI.Xaml.Tests.Enterprise
|
|||
});
|
||||
|
||||
|
||||
for (var i = 0; i < testData.snapPoints.Count(); i++)
|
||||
for (var i = 0; i < testData.snapPoints.Length; i++)
|
||||
{
|
||||
LOG_OUTPUT("scroll down to next snap point and wait for viewchanged event.");
|
||||
TestServices.InputHelper.ScrollMouseWheel(cv, -1);
|
||||
|
|
|
@ -307,7 +307,8 @@ namespace Windows.UI.Xaml.Tests.MUXControls.ApiTests
|
|||
|
||||
await RunOnUIThread.ExecuteAsync(() =>
|
||||
{
|
||||
var flyout = VisualTreeHelper.GetOpenPopups(Window.Current).Last();
|
||||
var openPopups = VisualTreeHelper.GetOpenPopups(Window.Current);
|
||||
var flyout = openPopups[openPopups.Count - 1];
|
||||
Verify.IsNotNull(flyout, "Flyout could not be retrieved");
|
||||
var ellipsisItemsRepeater = TestUtilities.FindDescendents<ItemsRepeater>(flyout).Single();
|
||||
Verify.IsNotNull(ellipsisItemsRepeater, "The underlying flyout items repeater (1) could not be retrieved");
|
||||
|
@ -388,7 +389,8 @@ namespace Windows.UI.Xaml.Tests.MUXControls.ApiTests
|
|||
|
||||
await RunOnUIThread.ExecuteAsync(() =>
|
||||
{
|
||||
var flyout = VisualTreeHelper.GetOpenPopups(Window.Current).Last();
|
||||
var openPopups = VisualTreeHelper.GetOpenPopups(Window.Current);
|
||||
var flyout = openPopups[openPopups.Count - 1];
|
||||
Verify.IsNotNull(flyout, "Flyout could not be retrieved");
|
||||
var ellipsisItemsRepeater = TestUtilities.FindDescendents<ItemsRepeater>(flyout).Single();
|
||||
Verify.IsNotNull(ellipsisItemsRepeater, "The underlying flyout items repeater (1) could not be retrieved");
|
||||
|
|
|
@ -1375,9 +1375,9 @@ namespace Windows.UI.Xaml.Tests.MUXControls.ApiTests.RepeaterTests
|
|||
Verify.AreEqual(selectionModel.SelectedItem, GetData(selectionModel, expectedSelected[0]));
|
||||
}
|
||||
|
||||
int itemsCount = selectionModel.SelectedItems.Count();
|
||||
int itemsCount = selectionModel.SelectedItems.Count;
|
||||
Verify.AreEqual(selectionModel.Source != null ? expectedSelected.Count - selectedInnerNodes : 0, itemsCount);
|
||||
int indicesCount = selectionModel.SelectedIndices.Count();
|
||||
int indicesCount = selectionModel.SelectedIndices.Count;
|
||||
Verify.AreEqual(expectedSelected.Count - selectedInnerNodes, indicesCount);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Uno.UI.RuntimeTests.Tests.Windows_Globalization
|
|||
{
|
||||
ApplicationLanguages.PrimaryLanguageOverride = "zh-Hans-CN";
|
||||
|
||||
ApplicationLanguages.Languages.First().Should().Be("zh-Hans-CN");
|
||||
ApplicationLanguages.Languages[0].Should().Be("zh-Hans-CN");
|
||||
CultureInfo.CurrentCulture.Name.Should().BeOneOf("zh-CN", "zh-Hans-CN");
|
||||
CultureInfo.CurrentUICulture.Name.Should().BeOneOf("zh-CN", "zh-Hans-CN");
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace Uno.UI.RuntimeTests.Tests.Windows_Globalization
|
|||
{
|
||||
ApplicationLanguages.PrimaryLanguageOverride = "fr-Latn-CA";
|
||||
|
||||
ApplicationLanguages.Languages.First().Should().Be("fr-Latn-CA");
|
||||
ApplicationLanguages.Languages[0].Should().Be("fr-Latn-CA");
|
||||
CultureInfo.CurrentCulture.Name.Should().BeOneOf("fr-CA", "fr-Latn-CA");
|
||||
CultureInfo.CurrentUICulture.Name.Should().BeOneOf("fr-CA", "fr-Latn-CA");
|
||||
}
|
||||
|
|
|
@ -140,12 +140,12 @@ namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Documents
|
|||
if (expected.LineBreakLength == 2)
|
||||
{
|
||||
Assert.AreEqual(expected.Text.Length - 1, result.Glyphs.Count);
|
||||
Assert.AreEqual(start + expected.Text.Length - 2, result.Glyphs.Last().Cluster);
|
||||
Assert.AreEqual(start + expected.Text.Length - 2, result.Glyphs[result.Glyphs.Count - 1].Cluster);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.AreEqual(expected.Text.Length, result.Glyphs.Count);
|
||||
Assert.AreEqual(start + expected.Text.Length - 1, result.Glyphs.Last().Cluster);
|
||||
Assert.AreEqual(start + expected.Text.Length - 1, result.Glyphs[result.Glyphs.Count - 1].Cluster);
|
||||
}
|
||||
|
||||
Assert.AreEqual(start, result.Glyphs[0].Cluster);
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace Uno.UI.TestComparer
|
|||
|
||||
foreach (var run in validRuns.Select((v, i) => new { Index = i, Value = v }))
|
||||
{
|
||||
Console.WriteLine($"Getting run {run.Index + 1} of {validRuns.Count()} for {run.Value.Platform} at {run.Value.Date}...");
|
||||
Console.WriteLine($"Getting run {run.Index + 1} of {validRuns.Length} for {run.Value.Platform} at {run.Value.Date}...");
|
||||
|
||||
var runName = $"{run.Value.Date:yyyyMMdd-hhmmss}-{run.Value.Id}";
|
||||
var fullPath = Path.Combine(basePath, run.Value.Platform, runName);
|
||||
|
|
|
@ -32,8 +32,8 @@ namespace Uno.UI.Tests.Windows_Data_Xml.DomTests
|
|||
{
|
||||
Assert.IsInstanceOfType(childNode, typeof(XmlElement));
|
||||
}
|
||||
Assert.AreEqual("title", childNodes.First().NodeName);
|
||||
Assert.AreEqual("para", childNodes.Last().NodeName);
|
||||
Assert.AreEqual("title", childNodes[0].NodeName);
|
||||
Assert.AreEqual("para", childNodes[(int)childNodes.Length - 1].NodeName);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Uno.UI.Tests.Windows_Globalization
|
|||
{
|
||||
var sut = new DateTimeFormatter(format, new[] {language});
|
||||
|
||||
var firstPattern = sut.Patterns.First();
|
||||
var firstPattern = sut.Patterns[0];
|
||||
|
||||
using var _ = new AssertionScope();
|
||||
|
||||
|
|
|
@ -325,7 +325,7 @@ namespace Uno.UI.Controls
|
|||
if (newItem != null
|
||||
&& e.NewStartingIndex == (collection.Count - 1)
|
||||
&& (frameRequest.NavigationMode == NavigationMode.New || frameRequest.NavigationMode == NavigationMode.Forward)
|
||||
&& newItem.SourcePageType == frameRequest.BackStackPageTypes.LastOrDefault())
|
||||
&& newItem.SourcePageType == (frameRequest.BackStackPageTypes.Count == 0 ? null : frameRequest.BackStackPageTypes[frameRequest.BackStackPageTypes.Count - 1]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ namespace Windows.UI
|
|||
{
|
||||
//If only one font exists for this family name, use it. Otherwise we will need to inspect the file for the right font name
|
||||
var fontNames = UIFont.FontNamesForFamilyName(familyName);
|
||||
return fontNames.Count() == 1 ? UIFont.FromName(fontNames[0], size) : null;
|
||||
return fontNames.Length == 1 ? UIFont.FromName(fontNames[0], size) : null;
|
||||
}
|
||||
|
||||
private static UIFont GetFontFromFile(nfloat size, string file)
|
||||
|
|
|
@ -162,7 +162,7 @@ namespace DirectUI
|
|||
uint count = 0;
|
||||
pCount = 0;
|
||||
|
||||
for (uint i = 0; i < m_vector.Count(); ++i)
|
||||
for (uint i = 0; i < m_vector.Count; ++i)
|
||||
{
|
||||
if (m_areEquivalentComparer(m_vector[(int)i], value))
|
||||
{
|
||||
|
@ -177,7 +177,7 @@ namespace DirectUI
|
|||
internal void RemoveAll(DateTime value, uint? pFromHint = null)
|
||||
{
|
||||
int from = (int)(pFromHint.HasValue ? pFromHint : 0);
|
||||
int i = (int)(m_vector.Count()) - 1;
|
||||
int i = (int)(m_vector.Count) - 1;
|
||||
|
||||
for (; i >= from; --i)
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Uno.UI.Helpers
|
|||
}
|
||||
public override bool ShouldBegin(UIGestureRecognizer recognizer)
|
||||
{
|
||||
return _navigationController()?.ViewControllers?.Count() > 1;
|
||||
return _navigationController()?.ViewControllers?.Length > 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ namespace Windows.UI.Xaml.Controls
|
|||
}
|
||||
}
|
||||
|
||||
public int Count => _itemsSource == null ? _inner.Count : _itemsSource.Count();
|
||||
public int Count => _itemsSource == null ? _inner.Count : _itemsSource.Count;
|
||||
|
||||
public uint Size => (uint)Count;
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace Windows.UI.Xaml.Controls
|
|||
_adapter?.NotifyDataSetChanged();
|
||||
if (_pager != null)
|
||||
{
|
||||
_pager.OffscreenPageLimit = Items.Count();
|
||||
_pager.OffscreenPageLimit = Items.Count;
|
||||
}
|
||||
_tabStrip?.Update();
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace Windows.UI.Xaml.Controls
|
|||
|
||||
public override int Count
|
||||
{
|
||||
get { return _fragments.Count(); }
|
||||
get { return _fragments.Count; }
|
||||
}
|
||||
|
||||
public override Java.Lang.ICharSequence GetPageTitleFormatted(int position)
|
||||
|
|
|
@ -152,7 +152,7 @@ namespace Windows.UI.Xaml.Data
|
|||
|
||||
foreach (ICollectionViewGroup group in CollectionGroups)
|
||||
{
|
||||
count += group.GroupItems.Count();
|
||||
count += group.GroupItems.Count;
|
||||
}
|
||||
|
||||
return count;
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace Windows.Globalization
|
|||
Languages = languages.Distinct().ToArray();
|
||||
}
|
||||
|
||||
var primaryLanguage = Languages.FirstOrDefault();
|
||||
var primaryLanguage = Languages.Count > 0 ? Languages[0] : null;
|
||||
|
||||
if(primaryLanguage is not null)
|
||||
{
|
||||
|
|
|
@ -109,7 +109,7 @@ namespace Windows.Networking.Connectivity
|
|||
string androCanonical = interfaceAddress.Address.CanonicalHostName;
|
||||
// seems like == androCanonical
|
||||
string androHostName = interfaceAddress.Address.HostName;
|
||||
bool androIPv46 = (interfaceAddress.Address.GetAddress().Count() == 4);
|
||||
bool androIPv46 = (interfaceAddress.Address.GetAddress().Length == 4);
|
||||
|
||||
// we have all required data from Android, and we can use them
|
||||
HostName newHost = new HostName();
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace Windows.Storage.Pickers
|
|||
private async Task<StorageFile?> PickSingleFileTaskAsync(CancellationToken token)
|
||||
{
|
||||
var files = await PickFilesAsync(false, token);
|
||||
return files.FirstOrDefault();
|
||||
return files.Count == 0 ? null : files[0];
|
||||
}
|
||||
|
||||
private async Task<IReadOnlyList<StorageFile>> PickMultipleFilesTaskAsync(CancellationToken token)
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Windows.Storage.Pickers
|
|||
private async Task<StorageFile?> PickSingleFileTaskAsync(CancellationToken token)
|
||||
{
|
||||
var files = await PickFilesAsync(false, token);
|
||||
return files.FirstOrDefault();
|
||||
return files.Count == 0 ? null : files[0];
|
||||
}
|
||||
|
||||
private async Task<IReadOnlyList<StorageFile>> PickMultipleFilesTaskAsync(CancellationToken token) =>
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace Windows.Storage.Pickers
|
|||
private async Task<StorageFile?> PickSingleFileTaskAsync(CancellationToken token)
|
||||
{
|
||||
var files = await PickFilesAsync(false, token);
|
||||
return files.FirstOrDefault();
|
||||
return files.Count > 0 ? files[0] : null;
|
||||
}
|
||||
|
||||
private async Task<IReadOnlyList<StorageFile>> PickMultipleFilesTaskAsync(CancellationToken token)
|
||||
|
|
Загрузка…
Ссылка в новой задаче