Fix CA1010
This commit is contained in:
@@ -612,6 +612,10 @@ dotnet_code_quality.api_surface = all
|
|||||||
### Design Rules
|
### Design Rules
|
||||||
### https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/design-warnings
|
### https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/design-warnings
|
||||||
|
|
||||||
|
# Collections should implement generic interface.
|
||||||
|
#dotnet_code_quality.CA1010.additional_required_generic_interfaces =
|
||||||
|
dotnet_diagnostic.CA1010.severity = warning
|
||||||
|
|
||||||
# Provide ObsoleteAttribute message.
|
# Provide ObsoleteAttribute message.
|
||||||
dotnet_diagnostic.CA1041.severity = warning
|
dotnet_diagnostic.CA1041.severity = warning
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
public interface ISuppressInitExport { }
|
public interface ISuppressInitExport { }
|
||||||
|
|
||||||
public class ActorReference : IEnumerable
|
public class ActorReference : IEnumerable<object>
|
||||||
{
|
{
|
||||||
public string Type;
|
public string Type;
|
||||||
readonly Lazy<TypeDictionary> initDict;
|
readonly Lazy<TypeDictionary> initDict;
|
||||||
@@ -104,7 +104,9 @@ namespace OpenRA
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerator GetEnumerator() { return initDict.Value.GetEnumerator(); }
|
public IEnumerator<object> GetEnumerator() { return initDict.Value.GetEnumerator(); }
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
|
||||||
|
|
||||||
public ActorReference Clone()
|
public ActorReference Clone()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace OpenRA.Primitives
|
namespace OpenRA.Primitives
|
||||||
{
|
{
|
||||||
public class TypeDictionary : IEnumerable
|
public class TypeDictionary : IEnumerable<object>
|
||||||
{
|
{
|
||||||
static readonly Func<Type, List<object>> CreateList = type => new List<object>();
|
static readonly Func<Type, List<object>> CreateList = type => new List<object>();
|
||||||
readonly Dictionary<Type, List<object>> data = new();
|
readonly Dictionary<Type, List<object>> data = new();
|
||||||
@@ -105,10 +105,15 @@ namespace OpenRA.Primitives
|
|||||||
objs.TrimExcess();
|
objs.TrimExcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerator GetEnumerator()
|
public IEnumerator<object> GetEnumerator()
|
||||||
{
|
{
|
||||||
return WithInterface<object>().GetEnumerator();
|
return WithInterface<object>().GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return GetEnumerator();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TypeExts
|
public static class TypeExts
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ using System.Text;
|
|||||||
|
|
||||||
namespace OpenRA.Support
|
namespace OpenRA.Support
|
||||||
{
|
{
|
||||||
public class HttpQueryBuilder : IEnumerable
|
public class HttpQueryBuilder : IEnumerable<KeyValuePair<string, string>>
|
||||||
{
|
{
|
||||||
readonly string url;
|
readonly string url;
|
||||||
readonly List<Parameter> parameters = new();
|
readonly List<KeyValuePair<string, string>> parameters = new();
|
||||||
|
|
||||||
public HttpQueryBuilder(string url)
|
public HttpQueryBuilder(string url)
|
||||||
{
|
{
|
||||||
@@ -28,11 +28,9 @@ namespace OpenRA.Support
|
|||||||
|
|
||||||
public void Add(string name, object value)
|
public void Add(string name, object value)
|
||||||
{
|
{
|
||||||
parameters.Add(new Parameter
|
parameters.Add(KeyValuePair.Create(
|
||||||
{
|
name,
|
||||||
Name = name,
|
Uri.EscapeDataString(value.ToString())));
|
||||||
Value = Uri.EscapeDataString(value.ToString())
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
@@ -42,20 +40,19 @@ namespace OpenRA.Support
|
|||||||
builder.Append("?");
|
builder.Append("?");
|
||||||
|
|
||||||
foreach (var parameter in parameters)
|
foreach (var parameter in parameters)
|
||||||
builder.Append($"{parameter.Name}={parameter.Value}&");
|
builder.Append($"{parameter.Key}={parameter.Value}&");
|
||||||
|
|
||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
class Parameter
|
public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
return parameters.GetEnumerator();
|
||||||
public string Value { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerator GetEnumerator()
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return GetEnumerator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user