Skip to content

Commit

Permalink
Fixed build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanE committed Apr 21, 2020
1 parent 8d77bda commit 62eb06d
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<NeutralLanguage>en</NeutralLanguage>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private set
string encodedValue = this.comparisonValue;
foreach (KeyValuePair<string, string> encoding in Filter.ReservedCharacterEncodingsPerRfc2396.Value)
{
encodedValue = encodedValue.Replace(encoding.Key, encoding.Value);
encodedValue = encodedValue.Replace(encoding.Key, encoding.Value, StringComparison.InvariantCulture);
}
this.comparisonValueEncoded = encodedValue;
}
Expand Down Expand Up @@ -185,7 +185,7 @@ private static IReadOnlyDictionary<string, string> InitializeReservedCharacter39
new Dictionary<string, string>(Filter.ReservedCharactersPerRfc3986.Value.Length);
foreach (char character in Filter.ReservedCharactersPerRfc3986.Value)
{
string from = character.ToString();
string from = character.ToString(CultureInfo.InvariantCulture);
string to = HttpUtility.UrlEncode(from);
result.Add(from, to);
}
Expand Down Expand Up @@ -299,7 +299,7 @@ public static string ToString(IReadOnlyCollection<IFilter> filters)
Filter clone = new Filter(filter);
clone.ComparisonValue = placeholder;
string currentFilter = clone.Serialize();
string encodedFilter = HttpUtility.UrlEncode(currentFilter).Replace(placeholder, filter.ComparisonValueEncoded);
string encodedFilter = HttpUtility.UrlEncode(currentFilter).Replace(placeholder, filter.ComparisonValueEncoded, StringComparison.InvariantCulture);
if (string.IsNullOrWhiteSpace(allFilters))
{
allFilters =
Expand Down Expand Up @@ -333,6 +333,10 @@ public static string ToString(IReadOnlyCollection<IFilter> filters)

public static bool TryParse(string filterExpression, out IReadOnlyCollection<IFilter> filters)
{
if(filterExpression == null)
{
throw new ArgumentNullException(nameof(filterExpression));
}
string expression = filterExpression.Trim().Unquote();
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ private int Group
CultureInfo.InvariantCulture,
SystemForCrossDomainIdentityManagementProtocolResources.ExceptionInvalidFilterTemplate,
this.Text);
#pragma warning disable CA1303 // Do not pass literals as localized parameters
throw new ArgumentOutOfRangeException(message, nameof(this.Group));
#pragma warning restore CA1303 // Do not pass literals as localized parameters
}
this.groupValue = value;
}
Expand All @@ -247,7 +249,9 @@ private int Level
CultureInfo.InvariantCulture,
SystemForCrossDomainIdentityManagementProtocolResources.ExceptionInvalidFilterTemplate,
this.Text);
#pragma warning disable CA1303 // Do not pass literals as localized parameters
throw new ArgumentOutOfRangeException(message, nameof(this.Level));
#pragma warning restore CA1303 // Do not pass literals as localized parameters
}
this.levelValue = value;
}
Expand Down Expand Up @@ -604,7 +608,7 @@ private void Initialize(Group left, Group @operator, Group right)
}

string nextExpression = remainder.Substring(indexNextFilter);
int indexClosingBracket = remainder.IndexOf(FilterExpression.BracketClose);
int indexClosingBracket = remainder.IndexOf(FilterExpression.BracketClose, StringComparison.InvariantCulture);
int nextExpressionLevel;
int nextExpressionGroup;
if (indexClosingBracket >= 0 && indexClosingBracket < indexLogicalOperator)
Expand Down Expand Up @@ -738,7 +742,7 @@ private static bool TryParse(string input, out string comparisonValue)
}
else
{
int index = input.IndexOf(FilterExpression.Space);
int index = input.IndexOf(FilterExpression.Space, StringComparison.InvariantCulture);
if (index >= 0)
{
// If unquoted string comparison values were to be rejected,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public static bool TryParse(string pathExpression, out IPath path)
buffer.SchemaIdentifier = schemaIdentifier;
}

int seperatorIndex = expression.IndexOf(Path.SeperatorAttributes);
int seperatorIndex = expression.IndexOf(Path.SeperatorAttributes, StringComparison.InvariantCulture);
if (seperatorIndex >= 0)
{
string valuePathExpression = expression.Substring(seperatorIndex + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1235,9 +1235,11 @@ public static async Task<string> SerializeAsync(this HttpRequestMessage request,
TextWriter textWriter = null;
try
{
#pragma warning disable IDE0068 // Use recommended dispose pattern

#pragma warning disable CA2000 // Dispose objects before losing scope
textWriter = new StringWriter(buffer);
#pragma warning restore IDE0068 // Use recommended dispose pattern
#pragma warning restore CA2000 // Dispose objects before losing scope

IHttpRequestMessageWriter requestWriter = null;
try
{
Expand Down Expand Up @@ -1277,7 +1279,7 @@ public static async Task<string> SerializeAsync(this HttpRequestMessage request)
throw new ArgumentNullException(nameof(request));
}

string result = await request.SerializeAsync(false);
string result = await request.SerializeAsync(false).ConfigureAwait(false);
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public override string ToString()
string result = parameters.ToString();
foreach (KeyValuePair<string, string> placeholder in placeHolders)
{
result = result.Replace(placeholder.Key, placeholder.Value);
result = result.Replace(placeholder.Key, placeholder.Value, StringComparison.InvariantCulture);
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public override bool Equals(object obj)

public override int GetHashCode()
{
int identifierCode = string.IsNullOrWhiteSpace(this.Identifier) ? 0 : this.Identifier.GetHashCode();
int schemaIdentifierCode = string.IsNullOrWhiteSpace(this.SchemaIdentifier) ? 0 : this.SchemaIdentifier.GetHashCode();
int identifierCode = string.IsNullOrWhiteSpace(this.Identifier) ? 0 : this.Identifier.GetHashCode(StringComparison.InvariantCulture);
int schemaIdentifierCode = string.IsNullOrWhiteSpace(this.SchemaIdentifier) ? 0 : this.SchemaIdentifier.GetHashCode(StringComparison.InvariantCulture);
int result = identifierCode ^ schemaIdentifierCode;
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,12 @@ private static bool TryCreatePatchRequest2Compliant(
{
throw;
}
#pragma warning disable CA1031 // Do not catch general exception types
catch
{
return false;
}
#pragma warning restore CA1031 // Do not catch general exception types

return true;
}
Expand Down Expand Up @@ -289,10 +291,12 @@ private bool TryCreatePatchRequest2Legacy(
{
throw;
}
#pragma warning disable CA1031 // Do not catch general exception types
catch
{
return false;
}
#pragma warning restore CA1031 // Do not catch general exception types

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Microsoft.SCIM
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1720:Identifier contains type name", Justification = "Enum of type names will contain type names")]
public enum AttributeDataType
{
String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public abstract class ConfigurationFactory<TConfiguration, TException>
{
public abstract TConfiguration Create(
Lazy<TConfiguration> defaultConfiguration,
out TException error);
out TException configurationError);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,12 @@ private async Task<object> ReadFromStream(Type type, Stream readStream, HttpCont
{
return new HttpResponseException(HttpStatusCode.BadRequest);
}
#pragma warning disable CA1031 // Do not catch general exception types
catch
{
return new HttpResponseException(HttpStatusCode.BadRequest);
}
#pragma warning restore CA1031 // Do not catch general exception types
}

public override Task<object> ReadFromStreamAsync(
Expand Down

0 comments on commit 62eb06d

Please sign in to comment.