Fix CA2249, CA2251
This commit is contained in:
committed by
Matthias Mailänder
parent
285443f10f
commit
169c60883b
@@ -892,9 +892,15 @@ dotnet_diagnostic.CA2247.severity = warning
|
|||||||
# Provide correct enum argument to Enum.HasFlag.
|
# Provide correct enum argument to Enum.HasFlag.
|
||||||
dotnet_diagnostic.CA2248.severity = warning
|
dotnet_diagnostic.CA2248.severity = warning
|
||||||
|
|
||||||
|
# Consider using String.Contains instead of String.IndexOf.
|
||||||
|
dotnet_diagnostic.CA2249.severity = warning
|
||||||
|
|
||||||
# Use ThrowIfCancellationRequested.
|
# Use ThrowIfCancellationRequested.
|
||||||
dotnet_diagnostic.CA2250.severity = warning
|
dotnet_diagnostic.CA2250.severity = warning
|
||||||
|
|
||||||
|
# Use String.Equals over String.Compare.
|
||||||
|
dotnet_diagnostic.CA2251.severity = warning
|
||||||
|
|
||||||
# Ensure ThreadStatic is only used with static fields.
|
# Ensure ThreadStatic is only used with static fields.
|
||||||
dotnet_diagnostic.CA2259.severity = warning
|
dotnet_diagnostic.CA2259.severity = warning
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace OpenRA
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ActorInfo
|
public class ActorInfo
|
||||||
{
|
{
|
||||||
public const string AbstractActorPrefix = "^";
|
public const char AbstractActorPrefix = '^';
|
||||||
public const char TraitInstanceSeparator = '@';
|
public const char TraitInstanceSeparator = '@';
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
var actors = MergeOrDefault("Manifest,Rules", fs, m.Rules, null, null,
|
var actors = MergeOrDefault("Manifest,Rules", fs, m.Rules, null, null,
|
||||||
k => new ActorInfo(modData.ObjectCreator, k.Key.ToLowerInvariant(), k.Value),
|
k => new ActorInfo(modData.ObjectCreator, k.Key.ToLowerInvariant(), k.Value),
|
||||||
filterNode: n => n.Key.StartsWith(ActorInfo.AbstractActorPrefix, StringComparison.Ordinal));
|
filterNode: n => n.Key.StartsWith(ActorInfo.AbstractActorPrefix));
|
||||||
|
|
||||||
var weapons = MergeOrDefault("Manifest,Weapons", fs, m.Weapons, null, null,
|
var weapons = MergeOrDefault("Manifest,Weapons", fs, m.Weapons, null, null,
|
||||||
k => new WeaponInfo(k.Value));
|
k => new WeaponInfo(k.Value));
|
||||||
@@ -182,7 +182,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
var actors = MergeOrDefault("Rules", fileSystem, m.Rules, mapRules, dr.Actors,
|
var actors = MergeOrDefault("Rules", fileSystem, m.Rules, mapRules, dr.Actors,
|
||||||
k => new ActorInfo(modData.ObjectCreator, k.Key.ToLowerInvariant(), k.Value),
|
k => new ActorInfo(modData.ObjectCreator, k.Key.ToLowerInvariant(), k.Value),
|
||||||
filterNode: n => n.Key.StartsWith(ActorInfo.AbstractActorPrefix, StringComparison.Ordinal));
|
filterNode: n => n.Key.StartsWith(ActorInfo.AbstractActorPrefix));
|
||||||
|
|
||||||
var weapons = MergeOrDefault("Weapons", fileSystem, m.Weapons, mapWeapons, dr.Weapons,
|
var weapons = MergeOrDefault("Weapons", fileSystem, m.Weapons, mapWeapons, dr.Weapons,
|
||||||
k => new WeaponInfo(k.Value));
|
k => new WeaponInfo(k.Value));
|
||||||
|
|||||||
@@ -491,7 +491,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
public void Do()
|
public void Do()
|
||||||
{
|
{
|
||||||
actor = editorActorLayer[actorId.ToLowerInvariant()];
|
actor = editorActorLayer[actorId];
|
||||||
foreach (var editorActionHandle in handles)
|
foreach (var editorActionHandle in handles)
|
||||||
editorActionHandle.Do(actor);
|
editorActionHandle.Do(actor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (!string.IsNullOrEmpty(searchFilter))
|
if (!string.IsNullOrEmpty(searchFilter))
|
||||||
FilteredCategories.AddRange(
|
FilteredCategories.AddRange(
|
||||||
allActors.Where(t => t.SearchTerms.Any(
|
allActors.Where(t => t.SearchTerms.Any(
|
||||||
s => s.IndexOf(searchFilter, StringComparison.OrdinalIgnoreCase) >= 0))
|
s => s.Contains(searchFilter, StringComparison.CurrentCultureIgnoreCase)))
|
||||||
.SelectMany(t => t.Categories)
|
.SelectMany(t => t.Categories)
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.OrderBy(x => x));
|
.OrderBy(x => x));
|
||||||
@@ -181,7 +181,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (!SelectedCategories.Overlaps(a.Categories))
|
if (!SelectedCategories.Overlaps(a.Categories))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(searchFilter) && !a.SearchTerms.Any(s => s.IndexOf(searchFilter, StringComparison.OrdinalIgnoreCase) >= 0))
|
if (!string.IsNullOrEmpty(searchFilter) &&
|
||||||
|
!a.SearchTerms.Any(s => s.Contains(searchFilter, StringComparison.CurrentCultureIgnoreCase)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var actor = a.Actor;
|
var actor = a.Actor;
|
||||||
|
|||||||
@@ -102,7 +102,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
if (!SelectedCategories.Overlaps(t.Categories))
|
if (!SelectedCategories.Overlaps(t.Categories))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(searchFilter) && !t.SearchTerms.Any(s => s.IndexOf(searchFilter, StringComparison.OrdinalIgnoreCase) >= 0))
|
if (!string.IsNullOrEmpty(searchFilter) &&
|
||||||
|
!t.SearchTerms.Any(s => s.Contains(searchFilter, StringComparison.CurrentCultureIgnoreCase)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var tileId = t.Template.Id;
|
var tileId = t.Template.Id;
|
||||||
|
|||||||
@@ -325,8 +325,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var validMaps = tabMaps[tab]
|
var validMaps = tabMaps[tab]
|
||||||
.Where(m => category == null || m.Categories.Contains(category))
|
.Where(m => category == null || m.Categories.Contains(category))
|
||||||
.Where(m => mapFilter == null ||
|
.Where(m => mapFilter == null ||
|
||||||
(m.Title != null && m.Title.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0) ||
|
(m.Title != null && m.Title.Contains(mapFilter, StringComparison.CurrentCultureIgnoreCase)) ||
|
||||||
(m.Author != null && m.Author.IndexOf(mapFilter, StringComparison.OrdinalIgnoreCase) >= 0) ||
|
(m.Author != null && m.Author.Contains(mapFilter, StringComparison.CurrentCultureIgnoreCase)) ||
|
||||||
m.PlayerCount == playerCountFilter);
|
m.PlayerCount == playerCountFilter);
|
||||||
|
|
||||||
IOrderedEnumerable<MapPreview> maps;
|
IOrderedEnumerable<MapPreview> maps;
|
||||||
|
|||||||
@@ -322,7 +322,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
bool IsHotkeyVisibleInFilter(HotkeyDefinition hd)
|
bool IsHotkeyVisibleInFilter(HotkeyDefinition hd)
|
||||||
{
|
{
|
||||||
var filter = filterInput.Text;
|
var filter = filterInput.Text;
|
||||||
var isFilteredByName = string.IsNullOrWhiteSpace(filter) || hd.Description.Contains(filter, StringComparison.OrdinalIgnoreCase);
|
var isFilteredByName = string.IsNullOrWhiteSpace(filter) ||
|
||||||
|
hd.Description.Contains(filter, StringComparison.CurrentCultureIgnoreCase);
|
||||||
var isFilteredByContext = currentContext == "Any" || hd.Contexts.Contains(currentContext);
|
var isFilteredByContext = currentContext == "Any" || hd.Contexts.Contains(currentContext);
|
||||||
|
|
||||||
return isFilteredByName && isFilteredByContext;
|
return isFilteredByName && isFilteredByContext;
|
||||||
|
|||||||
Reference in New Issue
Block a user