Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private static Color FromProfile(Uri profileUri)
if (c1.context != null)
{
c1.nativeColorValue = new float[c1.context.NumChannels];
for (int i = 0; i < c1.nativeColorValue.GetLength(0); i++)
for (int i = 0; i < c1.nativeColorValue.Length; i++)
{
c1.nativeColorValue[i] = 0.0f;
}
Expand All @@ -80,12 +80,12 @@ public static Color FromAValues(float a, float[] values, Uri profileUri)
throw new ArgumentException(SR.Format(SR.Color_DimensionMismatch, null));
}

if (values.GetLength(0) != c1.nativeColorValue.GetLength(0))
if (values.Length != c1.nativeColorValue.Length)
{
throw new ArgumentException(SR.Format(SR.Color_DimensionMismatch, null));
}

for (int numChannels = 0; numChannels < values.GetLength(0); numChannels++)
for (int numChannels = 0; numChannels < values.Length; numChannels++)
{
c1.nativeColorValue[numChannels] = values[numChannels];
}
Expand Down Expand Up @@ -305,10 +305,10 @@ internal string ConvertToString(string format, IFormatProvider provider)
var sb = new StringBuilder();
sb.AppendFormat(provider, "{0}{1} ", Parsers.s_ContextColor, uriString);
sb.AppendFormat(provider,"{1:" + format + "}{0}",separator,scRgbColor.a);
for (int i= 0; i< nativeColorValue.GetLength(0); ++i )
for (int i = 0; i < nativeColorValue.Length; ++i )
{
sb.AppendFormat(provider,"{0:" + format + "}",nativeColorValue[i]);
if (i< nativeColorValue.GetLength(0)-1 )
if (i < nativeColorValue.Length - 1)
{
sb.AppendFormat(provider,"{0}",separator);
}
Expand Down Expand Up @@ -350,7 +350,7 @@ private bool IsClose(Color color)
}
else
{
for (int i = 0; i < color.nativeColorValue.GetLength(0); i++)
for (int i = 0; i < color.nativeColorValue.Length; i++)
result = result && FloatUtil.AreClose(nativeColorValue[i], color.nativeColorValue[i]);
}

Expand Down Expand Up @@ -421,9 +421,9 @@ public float[] GetNativeColorValues()

#pragma warning suppress 6506 // c1.context is obviously not null - both color1.context AND color2.context are not null
c1.nativeColorValue = new float[c1.context.NumChannels];
for (int i = 0; i < c1.nativeColorValue.GetLength(0); i++)
for (int i = 0; i < c1.nativeColorValue.Length; i++)
{
c1.nativeColorValue[i] = color1.nativeColorValue[i] + color2.nativeColorValue[i] ;
c1.nativeColorValue[i] = color1.nativeColorValue[i] + color2.nativeColorValue[i];
}

Color c2 = Color.FromRgb(0, 0, 0);
Expand Down Expand Up @@ -540,7 +540,7 @@ public static Color Add(Color color1, Color color2)

#pragma warning suppress 6506 // c1.context is obviously not null - both color1.context AND color2.context are not null
c1.nativeColorValue = new float[c1.context.NumChannels];
for (int i = 0; i < c1.nativeColorValue.GetLength(0); i++)
for (int i = 0; i < c1.nativeColorValue.Length; i++)
{
c1.nativeColorValue[i] = color1.nativeColorValue[i] - color2.nativeColorValue[i];
}
Expand Down Expand Up @@ -750,12 +750,12 @@ public override bool Equals(object o)
return false;
}

if (color1.nativeColorValue.GetLength(0) != color2.nativeColorValue.GetLength(0))
if (color1.nativeColorValue.Length != color2.nativeColorValue.Length)
{
return false;
}

for (int i = 0; i < color1.nativeColorValue.GetLength(0); i++)
for (int i = 0; i < color1.nativeColorValue.Length; i++)
{
if (color1.nativeColorValue[i] != color2.nativeColorValue[i])
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,8 @@ private void ValidateArrayAndGetInfo(Array sourceBuffer,

if (sourceBuffer.Rank == 1)
{
if (sourceBuffer.GetLength(0) <= 0)
int firstDimLength = sourceBuffer.GetLength(0);
if (firstDimLength == 0)
{
if (backwardsCompat)
{
Expand All @@ -1095,7 +1096,7 @@ private void ValidateArrayAndGetInfo(Array sourceBuffer,
}
else
{
throw new ArgumentException(SR.Image_InsufficientBuffer, "sourceBuffer");
throw new ArgumentException(SR.Image_InsufficientBuffer, nameof(sourceBuffer));
}
}
else
Expand All @@ -1104,14 +1105,16 @@ private void ValidateArrayAndGetInfo(Array sourceBuffer,
{
object exemplar = sourceBuffer.GetValue(0);
elementSize = Marshal.SizeOf(exemplar);
sourceBufferSize = sourceBuffer.GetLength(0) * elementSize;
sourceBufferSize = firstDimLength * elementSize;
elementType = exemplar.GetType();
}
}
}
else if (sourceBuffer.Rank == 2)
{
if (sourceBuffer.GetLength(0) <= 0 || sourceBuffer.GetLength(1) <= 0)
int firstDimLength = sourceBuffer.GetLength(0);
int secondDimLength = sourceBuffer.GetLength(1);
if (firstDimLength == 0 || secondDimLength == 0)
{
if (backwardsCompat)
{
Expand All @@ -1121,16 +1124,16 @@ private void ValidateArrayAndGetInfo(Array sourceBuffer,
}
else
{
throw new ArgumentException(SR.Image_InsufficientBuffer, "sourceBuffer");
throw new ArgumentException(SR.Image_InsufficientBuffer, nameof(sourceBuffer));
}
}
else
{
checked
{
object exemplar = sourceBuffer.GetValue(0,0);
object exemplar = sourceBuffer.GetValue(0, 0);
elementSize = Marshal.SizeOf(exemplar);
sourceBufferSize = sourceBuffer.GetLength(0) * sourceBuffer.GetLength(1) * elementSize;
sourceBufferSize = (firstDimLength * secondDimLength) * elementSize;
elementType = exemplar.GetType();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static private Color ParseContextColor(string trimmedColor, IFormatProvider form
string tokens = trimmedColor.Substring(s_ContextColor.Length);
tokens = tokens.Trim();
string[] preSplit = tokens.Split(' ');
if (preSplit.GetLength(0)< 2)
if (preSplit.Length < 2)
{
throw new FormatException(SR.Parsers_IllegalToken);
}
Expand All @@ -114,7 +114,7 @@ static private Color ParseContextColor(string trimmedColor, IFormatProvider form

TokenizerHelper th = new TokenizerHelper(tokens, formatProvider);
string[] split = tokens.Split(new Char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
int numTokens = split.GetLength(0);
int numTokens = split.Length;

float alpha = Convert.ToSingle(th.NextTokenRequired(), formatProvider);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ Type destinationType

sb.AppendFormat(provider, "ContextColor {0} ", uriString);
sb.AppendFormat(provider, "{1:R}{0}", separator, color.ScA);
for (int i = 0; i < color.GetNativeColorValues().GetLength(0); ++i)
for (int i = 0; i < color.GetNativeColorValues().Length; ++i)
{
sb.AppendFormat(provider, "{0:R}", color.GetNativeColorValues()[i]);
if (i < color.GetNativeColorValues().GetLength(0) - 1)
if (i < color.GetNativeColorValues().Length - 1)
{
sb.AppendFormat(provider, "{0}", separator);
}
Expand Down Expand Up @@ -329,12 +329,12 @@ ColorContext colorContext

XpsResourceStream resourceStream = manager.AcquireResourceStream(typeof(ColorContext), colorContextMimeType.ToString());

byte [] buffer = new byte[512];
byte[] buffer = new byte[512];

Stream profileStream = colorContext.OpenProfileStream();
int count;

while ( (count = profileStream.Read( buffer, 0, buffer.GetLength(0)) ) > 0 )
while ( (count = profileStream.Read( buffer, 0, buffer.Length) ) > 0 )
{
resourceStream.Stream.Write(buffer,0,count);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ out DesignerSerializationOptionsAttribute designerSerializationFlagsAttr
// and that are not hidden
//
if (propertyInfo.CanRead &&
propertyInfo.GetIndexParameters().GetLength(0) == 0)
propertyInfo.GetIndexParameters().Length == 0)
{
MemberInfo memberInfo = (MemberInfo) propertyInfo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ private static DateTime XmlFormattedTimeToDateTime(String s, String format)
/// <returns>-1 if not found</returns>
private static int GetIndex(String format)
{
for (int i = 0; i < _dateTimePatternMap.GetLength(0); i++)
for (int i = 0; i < _dateTimePatternMap.Length; i++)
{
if (string.Equals(_dateTimePatternMap[i].Format, format, StringComparison.Ordinal))
{
Expand Down