Skip to content

Commit dbafcd5

Browse files
committed
replace array.getlength on single-dimension arrays with length property
1 parent a1fc788 commit dbafcd5

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Color.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private static Color FromProfile(Uri profileUri)
5757
if (c1.context != null)
5858
{
5959
c1.nativeColorValue = new float[c1.context.NumChannels];
60-
for (int i = 0; i < c1.nativeColorValue.GetLength(0); i++)
60+
for (int i = 0; i < c1.nativeColorValue.Length; i++)
6161
{
6262
c1.nativeColorValue[i] = 0.0f;
6363
}
@@ -80,12 +80,12 @@ public static Color FromAValues(float a, float[] values, Uri profileUri)
8080
throw new ArgumentException(SR.Format(SR.Color_DimensionMismatch, null));
8181
}
8282

83-
if (values.GetLength(0) != c1.nativeColorValue.GetLength(0))
83+
if (values.Length != c1.nativeColorValue.Length)
8484
{
8585
throw new ArgumentException(SR.Format(SR.Color_DimensionMismatch, null));
8686
}
8787

88-
for (int numChannels = 0; numChannels < values.GetLength(0); numChannels++)
88+
for (int numChannels = 0; numChannels < values.Length; numChannels++)
8989
{
9090
c1.nativeColorValue[numChannels] = values[numChannels];
9191
}
@@ -305,10 +305,10 @@ internal string ConvertToString(string format, IFormatProvider provider)
305305
var sb = new StringBuilder();
306306
sb.AppendFormat(provider, "{0}{1} ", Parsers.s_ContextColor, uriString);
307307
sb.AppendFormat(provider,"{1:" + format + "}{0}",separator,scRgbColor.a);
308-
for (int i= 0; i< nativeColorValue.GetLength(0); ++i )
308+
for (int i = 0; i < nativeColorValue.Length; ++i )
309309
{
310310
sb.AppendFormat(provider,"{0:" + format + "}",nativeColorValue[i]);
311-
if (i< nativeColorValue.GetLength(0)-1 )
311+
if (i < nativeColorValue.Length - 1)
312312
{
313313
sb.AppendFormat(provider,"{0}",separator);
314314
}
@@ -350,7 +350,7 @@ private bool IsClose(Color color)
350350
}
351351
else
352352
{
353-
for (int i = 0; i < color.nativeColorValue.GetLength(0); i++)
353+
for (int i = 0; i < color.nativeColorValue.Length; i++)
354354
result = result && FloatUtil.AreClose(nativeColorValue[i], color.nativeColorValue[i]);
355355
}
356356

@@ -421,9 +421,9 @@ public float[] GetNativeColorValues()
421421

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

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

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

753-
if (color1.nativeColorValue.GetLength(0) != color2.nativeColorValue.GetLength(0))
753+
if (color1.nativeColorValue.Length != color2.nativeColorValue.Length)
754754
{
755755
return false;
756756
}
757757

758-
for (int i = 0; i < color1.nativeColorValue.GetLength(0); i++)
758+
for (int i = 0; i < color1.nativeColorValue.Length; i++)
759759
{
760760
if (color1.nativeColorValue[i] != color2.nativeColorValue[i])
761761
{

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WriteableBitmap.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ private void ValidateArrayAndGetInfo(Array sourceBuffer,
10851085

10861086
if (sourceBuffer.Rank == 1)
10871087
{
1088-
if (sourceBuffer.GetLength(0) <= 0)
1088+
if (sourceBuffer.Length == 0)
10891089
{
10901090
if (backwardsCompat)
10911091
{
@@ -1104,7 +1104,7 @@ private void ValidateArrayAndGetInfo(Array sourceBuffer,
11041104
{
11051105
object exemplar = sourceBuffer.GetValue(0);
11061106
elementSize = Marshal.SizeOf(exemplar);
1107-
sourceBufferSize = sourceBuffer.GetLength(0) * elementSize;
1107+
sourceBufferSize = sourceBuffer.Length * elementSize;
11081108
elementType = exemplar.GetType();
11091109
}
11101110
}

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Parsers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static private Color ParseContextColor(string trimmedColor, IFormatProvider form
105105
string tokens = trimmedColor.Substring(s_ContextColor.Length);
106106
tokens = tokens.Trim();
107107
string[] preSplit = tokens.Split(' ');
108-
if (preSplit.GetLength(0)< 2)
108+
if (preSplit.Length < 2)
109109
{
110110
throw new FormatException(SR.Parsers_IllegalToken);
111111
}
@@ -114,7 +114,7 @@ static private Color ParseContextColor(string trimmedColor, IFormatProvider form
114114

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

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

src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/ColorTypeConverter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ Type destinationType
185185

186186
sb.AppendFormat(provider, "ContextColor {0} ", uriString);
187187
sb.AppendFormat(provider, "{1:R}{0}", separator, color.ScA);
188-
for (int i = 0; i < color.GetNativeColorValues().GetLength(0); ++i)
188+
for (int i = 0; i < color.GetNativeColorValues().Length; ++i)
189189
{
190190
sb.AppendFormat(provider, "{0:R}", color.GetNativeColorValues()[i]);
191-
if (i < color.GetNativeColorValues().GetLength(0) - 1)
191+
if (i < color.GetNativeColorValues().Length - 1)
192192
{
193193
sb.AppendFormat(provider, "{0}", separator);
194194
}
@@ -329,12 +329,12 @@ ColorContext colorContext
329329

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

332-
byte [] buffer = new byte[512];
332+
byte[] buffer = new byte[512];
333333

334334
Stream profileStream = colorContext.OpenProfileStream();
335335
int count;
336336

337-
while ( (count = profileStream.Read( buffer, 0, buffer.GetLength(0)) ) > 0 )
337+
while ( (count = profileStream.Read( buffer, 0, buffer.Length) ) > 0 )
338338
{
339339
resourceStream.Stream.Write(buffer,0,count);
340340
}

src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachSerializationCacheItems.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ out DesignerSerializationOptionsAttribute designerSerializationFlagsAttr
218218
// and that are not hidden
219219
//
220220
if (propertyInfo.CanRead &&
221-
propertyInfo.GetIndexParameters().GetLength(0) == 0)
221+
propertyInfo.GetIndexParameters().Length == 0)
222222
{
223223
MemberInfo memberInfo = (MemberInfo) propertyInfo;
224224

src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlSignatureProperties.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ private static DateTime XmlFormattedTimeToDateTime(String s, String format)
382382
/// <returns>-1 if not found</returns>
383383
private static int GetIndex(String format)
384384
{
385-
for (int i = 0; i < _dateTimePatternMap.GetLength(0); i++)
385+
for (int i = 0; i < _dateTimePatternMap.Length; i++)
386386
{
387387
if (string.Equals(_dateTimePatternMap[i].Format, format, StringComparison.Ordinal))
388388
{

0 commit comments

Comments
 (0)