Skip to content

Commit a89533a

Browse files
committed
Fixed issues with seemingly incompatible language features in .NET 6
1 parent d5e17f7 commit a89533a

File tree

12 files changed

+81
-13
lines changed

12 files changed

+81
-13
lines changed

ScreenCapture.NET.DX11/ScreenCapture.NET.DX11.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net7.0-windows;net6.0-windows</TargetFrameworks>
3+
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
4+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
45
<LangVersion>latest</LangVersion>
56
<Nullable>enable</Nullable>
67
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

ScreenCapture.NET.DX9/ScreenCapture.NET.DX9.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net7.0-windows;net6.0-windows</TargetFrameworks>
3+
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
4+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
45
<LangVersion>latest</LangVersion>
56
<Nullable>enable</Nullable>
67
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

ScreenCapture.NET/Model/CaptureZone.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,21 @@ public sealed class CaptureZone<TColor> : ICaptureZone
2020
/// <inheritdoc />
2121
public Display Display { get; }
2222

23+
#if NET7_0_OR_GREATER
2324
/// <inheritdoc />
2425
public ColorFormat ColorFormat
2526
{
2627
[MethodImpl(MethodImplOptions.AggressiveInlining)]
2728
get => TColor.ColorFormat;
2829
}
30+
#else
31+
/// <inheritdoc />
32+
public ColorFormat ColorFormat
33+
{
34+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
35+
get => default(TColor).Net6ColorFormat;
36+
}
37+
#endif
2938

3039
/// <inheritdoc />
3140
public int X { get; internal set; }
@@ -95,7 +104,7 @@ IImage ICaptureZone.Image
95104
/// <inheritdoc />
96105
public bool IsUpdateRequested { get; private set; }
97106

98-
#endregion
107+
#endregion
99108

100109
#region Events
101110

ScreenCapture.NET/Model/Colors/ColorABGR.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ namespace ScreenCapture.NET;
1717
/// <inheritdoc />
1818
public static ColorFormat ColorFormat => ColorFormat.ABGR;
1919

20+
#if !NET7_0_OR_GREATER
21+
/// <inheritdoc />
22+
public ColorFormat Net6ColorFormat => ColorFormat;
23+
#endif
24+
2025
private readonly byte _a;
2126
private readonly byte _b;
2227
private readonly byte _g;
@@ -39,7 +44,7 @@ namespace ScreenCapture.NET;
3944
#endregion
4045

4146
#region Constructors
42-
47+
4348
/// <summary>
4449
/// Initializes a new instance of the <see cref="ColorABGR"/> class.
4550
/// </summary>

ScreenCapture.NET/Model/Colors/ColorARGB.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ namespace ScreenCapture.NET;
1313
public readonly struct ColorARGB : IColor
1414
{
1515
#region Properties & Fields
16-
16+
1717
/// <inheritdoc />
1818
public static ColorFormat ColorFormat => ColorFormat.ARGB;
1919

20+
#if !NET7_0_OR_GREATER
21+
/// <inheritdoc />
22+
public ColorFormat Net6ColorFormat => ColorFormat;
23+
#endif
24+
2025
private readonly byte _a;
2126
private readonly byte _r;
2227
private readonly byte _g;

ScreenCapture.NET/Model/Colors/ColorBGR.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ namespace ScreenCapture.NET;
1313
public readonly struct ColorBGR : IColor
1414
{
1515
#region Properties & Fields
16-
16+
1717
/// <inheritdoc />
1818
public static ColorFormat ColorFormat => ColorFormat.BGR;
1919

20+
#if !NET7_0_OR_GREATER
21+
/// <inheritdoc />
22+
public ColorFormat Net6ColorFormat => ColorFormat;
23+
#endif
24+
2025
private readonly byte _b;
2126
private readonly byte _g;
2227
private readonly byte _r;

ScreenCapture.NET/Model/Colors/ColorBGRA.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ namespace ScreenCapture.NET;
1313
public readonly struct ColorBGRA : IColor
1414
{
1515
#region Properties & Fields
16-
16+
1717
/// <inheritdoc />
1818
public static ColorFormat ColorFormat => ColorFormat.BGRA;
1919

20+
#if !NET7_0_OR_GREATER
21+
/// <inheritdoc />
22+
public ColorFormat Net6ColorFormat => ColorFormat;
23+
#endif
24+
2025
private readonly byte _b;
2126
private readonly byte _g;
2227
private readonly byte _r;
@@ -36,7 +41,7 @@ namespace ScreenCapture.NET;
3641
public byte A => _a;
3742
// ReSharper restore ConvertToAutoPropertyWhenPossible
3843

39-
#endregion
44+
#endregion
4045

4146
#region Constructors
4247

ScreenCapture.NET/Model/Colors/ColorRGB.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ namespace ScreenCapture.NET;
1313
public readonly struct ColorRGB : IColor
1414
{
1515
#region Properties & Fields
16-
16+
1717
/// <inheritdoc />
1818
public static ColorFormat ColorFormat => ColorFormat.RGB;
1919

20+
#if !NET7_0_OR_GREATER
21+
/// <inheritdoc />
22+
public ColorFormat Net6ColorFormat => ColorFormat;
23+
#endif
24+
2025
private readonly byte _r;
2126
private readonly byte _g;
2227
private readonly byte _b;

ScreenCapture.NET/Model/Colors/ColorRGBA.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ namespace ScreenCapture.NET;
1717
/// <inheritdoc />
1818
public static ColorFormat ColorFormat => ColorFormat.RGBA;
1919

20+
#if !NET7_0_OR_GREATER
21+
/// <inheritdoc />
22+
public ColorFormat Net6ColorFormat => ColorFormat;
23+
#endif
24+
2025
private readonly byte _r;
2126
private readonly byte _g;
2227
private readonly byte _b;

ScreenCapture.NET/Model/Colors/IColor.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ public interface IColor
2727
/// </summary>
2828
byte A { get; }
2929

30+
#if NET7_0_OR_GREATER
3031
/// <summary>
3132
/// Gets the color-format of this color.
3233
/// </summary>
3334
public static virtual ColorFormat ColorFormat => throw new NotSupportedException();
35+
#else
36+
public ColorFormat Net6ColorFormat { get; }
37+
#endif
3438
}

0 commit comments

Comments
 (0)