// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Diagnostics;
using System.Globalization;
else
{
Debug.Assert(culture != null);
- NumberFormatInfo formatInfo = (NumberFormatInfo)culture.GetFormat(typeof(NumberFormatInfo));
+ var formatInfo = (NumberFormatInfo?)culture.GetFormat(typeof(NumberFormatInfo));
return IntFromString(text, formatInfo);
}
}
return Convert.ToInt32(value, radix);
}
- private static int IntFromString(string value, NumberFormatInfo formatInfo)
+ private static int IntFromString(string value, NumberFormatInfo? formatInfo)
{
return int.Parse(value, NumberStyles.Integer, formatInfo);
}
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Collections.Generic;
using System.Reflection;
foreach (PropertyInfo prop in typeWithColors.GetProperties(BindingFlags.Public | BindingFlags.Static))
{
if (prop.PropertyType == typeof(Color))
- dictionary[prop.Name] = (Color)prop.GetValue(null, null);
+ dictionary[prop.Name] = (Color)prop.GetValue(null, null)!;
}
}
private const int OleSystemColorFlag = unchecked((int)0x80000000);
- private static Dictionary<string, Color> s_htmlSysColorTable;
+ private static Dictionary<string, Color>? s_htmlSysColorTable;
internal static uint COLORREFToARGB(uint value)
=> ((value >> COLORREF_RedShift) & 0xFF) << Color.ARGBRedShift
InitializeHtmlSysColorTable();
}
- s_htmlSysColorTable.TryGetValue(htmlColor.ToLower(CultureInfo.InvariantCulture), out c);
+ s_htmlSysColorTable!.TryGetValue(htmlColor.ToLower(CultureInfo.InvariantCulture), out c);
}
// resort to type converter which will handle named colors
public static System.Drawing.Color Yellow { get { throw null; } }
public static System.Drawing.Color YellowGreen { get { throw null; } }
public bool Equals(System.Drawing.Color other) { throw null; }
- public override bool Equals(object obj) { throw null; }
+ public override bool Equals(object? obj) { throw null; }
public static System.Drawing.Color FromArgb(int argb) { throw null; }
public static System.Drawing.Color FromArgb(int alpha, System.Drawing.Color baseColor) { throw null; }
public static System.Drawing.Color FromArgb(int red, int green, int blue) { throw null; }
public static System.Drawing.Point Add(System.Drawing.Point pt, System.Drawing.Size sz) { throw null; }
public static System.Drawing.Point Ceiling(System.Drawing.PointF value) { throw null; }
public bool Equals(System.Drawing.Point other) { throw null; }
- public override bool Equals(object obj) { throw null; }
+ public override bool Equals(object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public void Offset(System.Drawing.Point p) { }
public void Offset(int dx, int dy) { }
public static System.Drawing.PointF Add(System.Drawing.PointF pt, System.Drawing.Size sz) { throw null; }
public static System.Drawing.PointF Add(System.Drawing.PointF pt, System.Drawing.SizeF sz) { throw null; }
public bool Equals(System.Drawing.PointF other) { throw null; }
- public override bool Equals(object obj) { throw null; }
+ public override bool Equals(object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Drawing.PointF operator +(System.Drawing.PointF pt, System.Drawing.Size sz) { throw null; }
public static System.Drawing.PointF operator +(System.Drawing.PointF pt, System.Drawing.SizeF sz) { throw null; }
public bool Contains(System.Drawing.Rectangle rect) { throw null; }
public bool Contains(int x, int y) { throw null; }
public bool Equals(System.Drawing.Rectangle other) { throw null; }
- public override bool Equals(object obj) { throw null; }
+ public override bool Equals(object? obj) { throw null; }
public static System.Drawing.Rectangle FromLTRB(int left, int top, int right, int bottom) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Drawing.Rectangle Inflate(System.Drawing.Rectangle rect, int x, int y) { throw null; }
public bool Contains(System.Drawing.RectangleF rect) { throw null; }
public bool Contains(float x, float y) { throw null; }
public bool Equals(System.Drawing.RectangleF other) { throw null; }
- public override bool Equals(object obj) { throw null; }
+ public override bool Equals(object? obj) { throw null; }
public static System.Drawing.RectangleF FromLTRB(float left, float top, float right, float bottom) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Drawing.RectangleF Inflate(System.Drawing.RectangleF rect, float x, float y) { throw null; }
public static System.Drawing.Size Add(System.Drawing.Size sz1, System.Drawing.Size sz2) { throw null; }
public static System.Drawing.Size Ceiling(System.Drawing.SizeF value) { throw null; }
public bool Equals(System.Drawing.Size other) { throw null; }
- public override bool Equals(object obj) { throw null; }
+ public override bool Equals(object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Drawing.Size operator +(System.Drawing.Size sz1, System.Drawing.Size sz2) { throw null; }
public static System.Drawing.Size operator /(System.Drawing.Size left, int right) { throw null; }
public float Width { get { throw null; } set { } }
public static System.Drawing.SizeF Add(System.Drawing.SizeF sz1, System.Drawing.SizeF sz2) { throw null; }
public bool Equals(System.Drawing.SizeF other) { throw null; }
- public override bool Equals(object obj) { throw null; }
+ public override bool Equals(object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public static System.Drawing.SizeF operator +(System.Drawing.SizeF sz1, System.Drawing.SizeF sz2) { throw null; }
public static System.Drawing.SizeF operator /(System.Drawing.SizeF left, float right) { throw null; }
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>netcoreapp-Debug;netcoreapp-Release;uap-Debug;uap-Release</Configurations>
+ <Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Include="System.Drawing.Primitives.cs" />
<AssemblyName>System.Drawing.Primitives</AssemblyName>
<DefineConstants Condition="'$(TargetsWindows)' == 'true' And '$(TargetGroup)' != 'uap'">$(DefineConstants);FEATURE_WINDOWS_SYSTEM_COLORS</DefineConstants>
<Configurations>netcoreapp-Unix-Debug;netcoreapp-Unix-Release;netcoreapp-Windows_NT-Debug;netcoreapp-Windows_NT-Release;uap-Windows_NT-Debug;uap-Windows_NT-Release</Configurations>
+ <nullable>enable</nullable>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.Collections" />
// User supplied name of color. Will not be filled in if
// we map to a "knowncolor"
- private readonly string name; // Do not rename (binary serialization)
+ private readonly string? name; // Do not rename (binary serialization)
// Standard 32bit sRGB (ARGB)
private readonly long value; // Do not rename (binary serialization)
this.knownColor = unchecked((short)knownColor);
}
- private Color(long value, short state, string name, KnownColor knownColor)
+ private Color(long value, short state, string? name, KnownColor knownColor)
{
this.value = value;
this.state = state;
{
if ((state & StateNameValid) != 0)
{
+ Debug.Assert(name != null);
return name;
}
public static bool operator !=(Color left, Color right) => !(left == right);
- public override bool Equals(object obj) => obj is Color other && Equals(other);
+ public override bool Equals(object? obj) => obj is Color other && Equals(other);
public bool Equals(Color other) => this == other;
// an unnamed color with the same ARGB value.
// 3. Have an unknown name. Will differ from other unknown-named colors only by name, so we
// can usefully use the names hash code alone.
- if (name != null & !IsKnownColor)
+ if (name != null && !IsKnownColor)
return name.GetHashCode();
return HashCode.Combine(value.GetHashCode(), state.GetHashCode(), knownColor.GetHashCode());
/// Specifies whether this <see cref='System.Drawing.Point'/> contains the same coordinates as the specified
/// <see cref='object'/>.
/// </summary>
- public override bool Equals(object obj) => obj is Point && Equals((Point)obj);
+ public override bool Equals(object? obj) => obj is Point && Equals((Point)obj);
public bool Equals(Point other) => this == other;
/// </summary>
public static PointF Subtract(PointF pt, SizeF sz) => new PointF(pt.X - sz.Width, pt.Y - sz.Height);
- public override bool Equals(object obj) => obj is PointF && Equals((PointF)obj);
+ public override bool Equals(object? obj) => obj is PointF && Equals((PointF)obj);
public bool Equals(PointF other) => this == other;
/// Tests whether <paramref name="obj"/> is a <see cref='System.Drawing.Rectangle'/> with the same location
/// and size of this Rectangle.
/// </summary>
- public override bool Equals(object obj) => obj is Rectangle && Equals((Rectangle)obj);
+ public override bool Equals(object? obj) => obj is Rectangle && Equals((Rectangle)obj);
public bool Equals(Rectangle other) => this == other;
/// Tests whether <paramref name="obj"/> is a <see cref='System.Drawing.RectangleF'/> with the same location and
/// size of this <see cref='System.Drawing.RectangleF'/>.
/// </summary>
- public override bool Equals(object obj) => obj is RectangleF && Equals((RectangleF)obj);
+ public override bool Equals(object? obj) => obj is RectangleF && Equals((RectangleF)obj);
public bool Equals(RectangleF other) => this == other;
/// Tests to see whether the specified object is a <see cref='System.Drawing.Size'/> with the same dimensions
/// as this <see cref='System.Drawing.Size'/>.
/// </summary>
- public override bool Equals(object obj) => obj is Size && Equals((Size)obj);
+ public override bool Equals(object? obj) => obj is Size && Equals((Size)obj);
public bool Equals(Size other) => this == other;
/// Tests to see whether the specified object is a <see cref='System.Drawing.SizeF'/> with the same dimensions
/// as this <see cref='System.Drawing.SizeF'/>.
/// </summary>
- public override bool Equals(object obj) => obj is SizeF && Equals((SizeF)obj);
+ public override bool Equals(object? obj) => obj is SizeF && Equals((SizeF)obj);
public bool Equals(SizeF other) => this == other;