Skip to content

Commit

Permalink
Make repo build successfully and package S.D.Common
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorHofer committed Feb 14, 2023
1 parent d30eb69 commit ee24b18
Show file tree
Hide file tree
Showing 17 changed files with 106 additions and 66 deletions.
8 changes: 0 additions & 8 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,6 @@
<RuntimeFrameworkVersion Condition="!$(TargetFramework.StartsWith('$(RedistTargetFrameworkName)'))" />
</PropertyGroup>

<!-- Adds Nullable annotation attributes to C# non .NETCoreApp builds. -->
<ItemGroup Condition="'$(Nullable)' != '' and
'$(Nullable)' != 'disable' and
'$(MSBuildProjectExtension)' == '.csproj' and
'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
<Compile Include="$(RepoRoot)src\Common\src\NullableAttributes.cs" />
</ItemGroup>

<Choose>
<When Condition="'$(IncludeInternalObsoleteAttribute)' == 'true' and '$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
<ItemGroup>
Expand Down
38 changes: 38 additions & 0 deletions Winforms.sln
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BuildAssist", "BuildAssist"
EndProject
Project("{13B669BE-BB05-4DDF-9536-439F39A36129}") = "BuildAssist", "src\BuildAssist\BuildAssist.msbuildproj", "{20E7C5E8-CD56-4A1C-9CB2-B7169FD7A5B8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "src\System.Drawing.Common\src\System.Drawing.Common.csproj", "{90CC3A84-1087-48A0-8FDC-3A0F6D4D3B4D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common.Tests", "src\System.Drawing.Common\tests\System.Drawing.Common.Tests.csproj", "{7650F24E-7132-42CF-ADCE-830C8DB26EE5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -831,6 +835,38 @@ Global
{20E7C5E8-CD56-4A1C-9CB2-B7169FD7A5B8}.Release|x64.Build.0 = Release|Any CPU
{20E7C5E8-CD56-4A1C-9CB2-B7169FD7A5B8}.Release|x86.ActiveCfg = Release|Any CPU
{20E7C5E8-CD56-4A1C-9CB2-B7169FD7A5B8}.Release|x86.Build.0 = Release|Any CPU
{90CC3A84-1087-48A0-8FDC-3A0F6D4D3B4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{90CC3A84-1087-48A0-8FDC-3A0F6D4D3B4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{90CC3A84-1087-48A0-8FDC-3A0F6D4D3B4D}.Debug|arm64.ActiveCfg = Debug|Any CPU
{90CC3A84-1087-48A0-8FDC-3A0F6D4D3B4D}.Debug|arm64.Build.0 = Debug|Any CPU
{90CC3A84-1087-48A0-8FDC-3A0F6D4D3B4D}.Debug|x64.ActiveCfg = Debug|Any CPU
{90CC3A84-1087-48A0-8FDC-3A0F6D4D3B4D}.Debug|x64.Build.0 = Debug|Any CPU
{90CC3A84-1087-48A0-8FDC-3A0F6D4D3B4D}.Debug|x86.ActiveCfg = Debug|Any CPU
{90CC3A84-1087-48A0-8FDC-3A0F6D4D3B4D}.Debug|x86.Build.0 = Debug|Any CPU
{90CC3A84-1087-48A0-8FDC-3A0F6D4D3B4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{90CC3A84-1087-48A0-8FDC-3A0F6D4D3B4D}.Release|Any CPU.Build.0 = Release|Any CPU
{90CC3A84-1087-48A0-8FDC-3A0F6D4D3B4D}.Release|arm64.ActiveCfg = Release|Any CPU
{90CC3A84-1087-48A0-8FDC-3A0F6D4D3B4D}.Release|arm64.Build.0 = Release|Any CPU
{90CC3A84-1087-48A0-8FDC-3A0F6D4D3B4D}.Release|x64.ActiveCfg = Release|Any CPU
{90CC3A84-1087-48A0-8FDC-3A0F6D4D3B4D}.Release|x64.Build.0 = Release|Any CPU
{90CC3A84-1087-48A0-8FDC-3A0F6D4D3B4D}.Release|x86.ActiveCfg = Release|Any CPU
{90CC3A84-1087-48A0-8FDC-3A0F6D4D3B4D}.Release|x86.Build.0 = Release|Any CPU
{7650F24E-7132-42CF-ADCE-830C8DB26EE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7650F24E-7132-42CF-ADCE-830C8DB26EE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7650F24E-7132-42CF-ADCE-830C8DB26EE5}.Debug|arm64.ActiveCfg = Debug|Any CPU
{7650F24E-7132-42CF-ADCE-830C8DB26EE5}.Debug|arm64.Build.0 = Debug|Any CPU
{7650F24E-7132-42CF-ADCE-830C8DB26EE5}.Debug|x64.ActiveCfg = Debug|Any CPU
{7650F24E-7132-42CF-ADCE-830C8DB26EE5}.Debug|x64.Build.0 = Debug|Any CPU
{7650F24E-7132-42CF-ADCE-830C8DB26EE5}.Debug|x86.ActiveCfg = Debug|Any CPU
{7650F24E-7132-42CF-ADCE-830C8DB26EE5}.Debug|x86.Build.0 = Debug|Any CPU
{7650F24E-7132-42CF-ADCE-830C8DB26EE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7650F24E-7132-42CF-ADCE-830C8DB26EE5}.Release|Any CPU.Build.0 = Release|Any CPU
{7650F24E-7132-42CF-ADCE-830C8DB26EE5}.Release|arm64.ActiveCfg = Release|Any CPU
{7650F24E-7132-42CF-ADCE-830C8DB26EE5}.Release|arm64.Build.0 = Release|Any CPU
{7650F24E-7132-42CF-ADCE-830C8DB26EE5}.Release|x64.ActiveCfg = Release|Any CPU
{7650F24E-7132-42CF-ADCE-830C8DB26EE5}.Release|x64.Build.0 = Release|Any CPU
{7650F24E-7132-42CF-ADCE-830C8DB26EE5}.Release|x86.ActiveCfg = Release|Any CPU
{7650F24E-7132-42CF-ADCE-830C8DB26EE5}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -888,6 +924,8 @@ Global
{93651A99-C9EB-4F83-8A66-DF9D21574550} = {DF68A171-D27B-4E6A-8A7E-63A651622355}
{B3CE7FA8-21C5-4CE8-970E-8210D1D89251} = {77FEDB47-F7F6-490D-AF7C-ABB4A9E0B9D7}
{20E7C5E8-CD56-4A1C-9CB2-B7169FD7A5B8} = {B3CE7FA8-21C5-4CE8-970E-8210D1D89251}
{90CC3A84-1087-48A0-8FDC-3A0F6D4D3B4D} = {77FEDB47-F7F6-490D-AF7C-ABB4A9E0B9D7}
{7650F24E-7132-42CF-ADCE-830C8DB26EE5} = {583F1292-AE8D-4511-B8D8-A81FE4642DDC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7B1B0433-F612-4E5A-BE7E-FCF5B9F6E136}
Expand Down
21 changes: 9 additions & 12 deletions src/Common/tests/TestUtilities/DebuggerAttributes.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable

using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;

Expand Down Expand Up @@ -78,7 +75,7 @@ public static IEnumerable<PropertyInfo> GetDebuggerVisibleProperties(Type debugg
{
// The debugger doesn't evaluate non-public members of type proxies. GetGetMethod returns null if the getter is non-public.
IEnumerable<PropertyInfo> visibleProperties = debuggerAttributeType.GetProperties()
.Where(pi => pi.GetGetMethod() != null && GetDebuggerBrowsableState(pi) != DebuggerBrowsableState.Never);
.Where(pi => pi.GetGetMethod() is object && GetDebuggerBrowsableState(pi) != DebuggerBrowsableState.Never);
return visibleProperties;
}

Expand Down Expand Up @@ -176,7 +173,7 @@ internal static string ValidateDebuggerDisplayReferences(object obj)
private static string GetDebuggerMemberString(object member, bool noQuotes)
{
string memberString = "null";
if (member != null)
if (member is object)
{
memberString = member.ToString();
if (member is string)
Expand Down Expand Up @@ -205,14 +202,14 @@ obj is long || obj is ulong ||
private static bool TryEvaluateReference(object obj, string reference, out object member)
{
PropertyInfo pi = GetProperty(obj, reference);
if (pi != null)
if (pi is object)
{
member = pi.GetValue(obj);
return true;
}

FieldInfo fi = GetField(obj, reference);
if (fi != null)
if (fi is object)
{
member = fi.GetValue(obj);
return true;
Expand All @@ -224,10 +221,10 @@ private static bool TryEvaluateReference(object obj, string reference, out objec

private static FieldInfo GetField(object obj, string fieldName)
{
for (Type t = obj.GetType(); t != null; t = t.GetTypeInfo().BaseType)
for (Type t = obj.GetType(); t is object; t = t.GetTypeInfo().BaseType)
{
FieldInfo fi = t.GetTypeInfo().GetDeclaredField(fieldName);
if (fi != null)
if (fi is object)
{
return fi;
}
Expand All @@ -238,10 +235,10 @@ private static FieldInfo GetField(object obj, string fieldName)

private static PropertyInfo GetProperty(object obj, string propertyName)
{
for (Type t = obj.GetType(); t != null; t = t.GetTypeInfo().BaseType)
for (Type t = obj.GetType(); t is object; t = t.GetTypeInfo().BaseType)
{
PropertyInfo pi = t.GetTypeInfo().GetDeclaredProperty(propertyName);
if (pi != null)
if (pi is object)
{
return pi;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Common/tests/TestUtilities/ThreadCultureChange.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Globalization;
Expand All @@ -11,7 +11,7 @@ public sealed class ThreadCultureChange : IDisposable
private readonly CultureInfo _origUICulture = CultureInfo.CurrentUICulture;

public ThreadCultureChange(string? cultureName) :
this(cultureName != null ? new CultureInfo(cultureName) : null)
this(cultureName is object ? new CultureInfo(cultureName) : null)
{
}

Expand All @@ -22,13 +22,13 @@ public ThreadCultureChange(CultureInfo? newCulture) :

public ThreadCultureChange(CultureInfo? newCulture, CultureInfo? newUICulture)
{
if (newCulture != null)
if (newCulture is object)
{
_origCulture = CultureInfo.CurrentCulture;
CultureInfo.CurrentCulture = newCulture;
}

if (newUICulture != null)
if (newUICulture is object)
{
_origUICulture = CultureInfo.CurrentUICulture;
CultureInfo.CurrentUICulture = newUICulture;
Expand Down
2 changes: 2 additions & 0 deletions src/System.Drawing.Common/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<SupportedOSPlatforms>windows</SupportedOSPlatforms>
<UsingToolXliff>false</UsingToolXliff>
<EnableDefaultItems>false</EnableDefaultItems>
<!-- Code warnings that weren't enabled in dotnet/runtime but are raised in winforms.
TODO: Clean the code up and remove the NoWarns. -->
<NoWarn>$(NoWarn);CSIsNull001;CSIsNull002;SA1500;SA1513;CA1812;IDE0005;SA1129;SA1408;SA1507;SA1508;CA2229</NoWarn>
</PropertyGroup>
</Project>
21 changes: 12 additions & 9 deletions src/System.Drawing.Common/src/System.Drawing.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<ImplicitUsings>disable</ImplicitUsings>
<CLSCompliant>true</CLSCompliant>
<IsPackable>true</IsPackable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageValidationBaselineVersion>7.0.0</PackageValidationBaselineVersion>
<AddXamarinPlaceholderFilesToPackage>true</AddXamarinPlaceholderFilesToPackage>
<PackageDescription>Provides access to GDI+ graphics functionality.
Expand All @@ -26,18 +27,11 @@ Since .NET 7, non-Windows platforms are not supported, even with the runtime con
</PropertyGroup>

<!-- DesignTimeBuild requires all the TargetFramework Derived Properties to not be present in the first property group. -->
<PropertyGroup>
<IncludeInternalObsoleteAttribute Condition="$([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)')) == '.NETStandard'">true</IncludeInternalObsoleteAttribute>
<PropertyGroup Condition="$([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)')) == '.NETStandard'">
<IncludeInternalObsoleteAttribute>true</IncludeInternalObsoleteAttribute>
<EnableTrimAnalyzer>false</EnableTrimAnalyzer>
</PropertyGroup>

<ItemGroup>
<Compile Include="Forwards.cs"
Condition="'$(TargetFrameworkIdentifier)' != '.NETStandard'" />
<Compile Include="NotSupported.cs"
Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard'" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<Compile Include="SRDescriptionAttribute.cs" />

Expand Down Expand Up @@ -318,6 +312,15 @@ Since .NET 7, non-Windows platforms are not supported, even with the runtime con
Link="Common\HandleRefMarshaller.cs" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETStandard'">
<Compile Include="Forwards.cs" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard'">
<Compile Include="NotSupported.cs" />
<Compile Include="$(RepoRoot)src\Common\src\NullableAttributes.cs" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
<Compile Include="..\..\Common\src\RequiresUnreferencedCodeAttribute.cs"
Link="Common\RequiresUnreferencedCodeAttribute.cs" />
Expand Down
8 changes: 4 additions & 4 deletions src/System.Drawing.Common/tests/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,16 @@ private static Rectangle GetRectangle(RECT rect)
private static extern int GetMonitorInfo(IntPtr hMonitor, ref MONITORINFO monitorInfo);

[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr GetForegroundWindow();
internal static extern IntPtr GetForegroundWindow();

[DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
public static extern int GetGuiResources(IntPtr hProcess, uint flags);
internal static extern int GetGuiResources(IntPtr hProcess, uint flags);

[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr GetDC(IntPtr hWnd);
internal static extern IntPtr GetDC(IntPtr hWnd);

[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr GetWindowDC(IntPtr hWnd);
internal static extern IntPtr GetWindowDC(IntPtr hWnd);

public static Rectangle GetWindowDCRect(IntPtr hdc) => GetHWndRect(WindowFromDC(hdc));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

namespace System.Drawing.Printing.Tests
{

public class PageSettingsTests
{
[ConditionalFact(Helpers.AnyInstalledPrinters, Helpers.WindowsRS3OrEarlier)] // RS4 failures: https://github.com/dotnet/runtime/issues/26247
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>annotations</Nullable>
<!-- Code warnings that weren't enabled in dotnet/runtime but are raised in winforms.
TODO: Clean the code up and remove the NoWarns. -->
<NoWarn>$(NoWarn);CA1825;CA5351;CA1850</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ namespace System.ComponentModel.TypeConverterTests
[ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsIoTCore))]
public class IconConverterTest
{
private readonly Icon _icon = null;
private readonly IconConverter _icoConv = null;
private readonly IconConverter _icoConvFrmTD = null;
private readonly string _iconStr = null;
private readonly byte[] _iconBytes = null;
private readonly Icon _icon;
private readonly IconConverter _icoConv;
private readonly IconConverter _icoConvFrmTD;
private readonly string _iconStr;
private readonly byte[] _iconBytes;

public IconConverterTest()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public void ConvertFrom()
[Fact]
public void ConvertFrom_Throws()
{

MarginsConverter mc = new MarginsConverter();
CultureInfo culture = CultureInfo.InvariantCulture;

Expand Down
2 changes: 1 addition & 1 deletion src/System.Drawing.Common/tests/SystemFontsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void GetFontByName_NoSuchName_ReturnsNull(string systemFontName)
}

[DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Auto)]
public static extern int GetUserDefaultLCID();
internal static extern int GetUserDefaultLCID();

// Do not test DefaultFont and DialogFont, as we can't reliably determine from LCID
// https://github.com/dotnet/runtime/issues/28830#issuecomment-473556522
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
using System.Diagnostics;
using Xunit;

#pragma warning disable CA1050 // Declare types in namespaces
public class ClassWithNoNamespace { }
#pragma warning restore CA1050

namespace System.Drawing.Tests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

namespace MonoTests.System.Drawing.Imaging
{

public class IconCodecTest
{
[ConditionalFact(Helpers.RecentGdiplusIsAvailable)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ namespace MonoTests.System.Drawing
{
public class TestBitmap
{

[ConditionalFact(Helpers.IsDrawingSupported)]
public void TestPixels()
{
Expand Down Expand Up @@ -562,7 +561,6 @@ private byte[] HashLock(Bitmap bmp, int width, int height, PixelFormat fmt, Imag
{
for (int x = 0; x < bd.Width; x++)
{

/* Read the pixels*/
for (int bt = 0; bt < bbps / 8; bt++, index++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ namespace MonoTests.System.Drawing.Imaging
[ActiveIssue("https://github.com/dotnet/runtime/issues/34591", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
public class MetafileTest
{

public const string Bitmap = "non-inverted.bmp";
public const string WmfPlaceable = "telescope_01.wmf";
public const string Emf = "milkmateya01.emf";
Expand Down
Loading

0 comments on commit ee24b18

Please sign in to comment.