Skip to content

Commit dce05cf

Browse files
ViktorHofermatouskozak
authored andcommitted
Replace usage of out-of-support TFM compiler directives (dotnet#101672)
* Replace usage of out-of-support TFM compiler directives ... and directives for TFMs that we don't target anymore in main. Replaces the following directives with `NET` or `!NET`: - `#if NETCOREAPP2*` - `#if !NETCOREAPP2*` - `#if NETCOREAPP3*` - `#if !NETCOREAPP3*` - `#if NET5*` - `#if !NET5*` - `#if NET6*` - `#if !NET6*` - `#if NET7*` - `#if !NET7*` * Update EmitterTests.cs
1 parent 1fb75ba commit dce05cf

File tree

128 files changed

+253
-267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+253
-267
lines changed

src/coreclr/tools/Common/TypeSystem/Common/Utilities/LockFreeReaderHashtable.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public TValue AddOrGetExisting(TValue value)
367367

368368
private TValue AddOrGetExistingInner(TValue value, out bool addedValue)
369369
{
370-
#if NET5_0_OR_GREATER
370+
#if NET
371371
ArgumentNullException.ThrowIfNull(value);
372372
#else
373373
if (value == null)
@@ -596,7 +596,7 @@ public bool Contains(TKey key)
596596
/// <returns>Value from the hashtable if found, otherwise null.</returns>
597597
public TValue GetValueIfExists(TValue value)
598598
{
599-
#if NET5_0_OR_GREATER
599+
#if NET
600600
ArgumentNullException.ThrowIfNull(value);
601601
#else
602602
if (value == null)

src/libraries/Common/src/Interop/Interop.Ldap.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Diagnostics;
55
using System.Runtime.CompilerServices;
66
using System.Runtime.InteropServices;
7-
#if NET7_0_OR_GREATER
7+
#if NET
88
using System.Runtime.InteropServices.Marshalling;
99
#endif
1010
using System.Security.Authentication;
@@ -31,7 +31,7 @@ internal readonly struct Luid
3131
public int HighPart => _highPart;
3232
}
3333

34-
#if NET7_0_OR_GREATER
34+
#if NET
3535
[NativeMarshalling(typeof(Marshaller))]
3636
#endif
3737
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
@@ -49,7 +49,7 @@ internal struct SEC_WINNT_AUTH_IDENTITY_EX
4949
public string packageList;
5050
public int packageListLength;
5151

52-
#if NET7_0_OR_GREATER
52+
#if NET
5353
[CustomMarshaller(typeof(SEC_WINNT_AUTH_IDENTITY_EX), MarshalMode.ManagedToUnmanagedIn, typeof(Marshaller))]
5454
internal static class Marshaller
5555
{
@@ -176,7 +176,7 @@ internal struct LDAP_TIMEVAL
176176
public int tv_usec;
177177
}
178178

179-
#if NET7_0_OR_GREATER
179+
#if NET
180180
[NativeMarshalling(typeof(PinningMarshaller))]
181181
#endif
182182
[StructLayout(LayoutKind.Sequential)]
@@ -185,7 +185,7 @@ internal sealed class BerVal
185185
public int bv_len;
186186
public IntPtr bv_val = IntPtr.Zero;
187187

188-
#if NET7_0_OR_GREATER
188+
#if NET
189189
[CustomMarshaller(typeof(BerVal), MarshalMode.ManagedToUnmanagedIn, typeof(PinningMarshaller))]
190190
internal static unsafe class PinningMarshaller
191191
{
@@ -207,7 +207,7 @@ internal sealed class LdapControl
207207
public LdapControl() { }
208208
}
209209

210-
#if NET7_0_OR_GREATER
210+
#if NET
211211
[NativeMarshalling(typeof(Marshaller))]
212212
#endif
213213
[StructLayout(LayoutKind.Sequential)]
@@ -217,7 +217,7 @@ internal struct LdapReferralCallback
217217
public QUERYFORCONNECTIONInternal query;
218218
public NOTIFYOFNEWCONNECTIONInternal notify;
219219
public DEREFERENCECONNECTIONInternal dereference;
220-
#if NET7_0_OR_GREATER
220+
#if NET
221221
public static readonly unsafe int Size = sizeof(Marshaller.MarshalValue.Native);
222222

223223
[CustomMarshaller(typeof(LdapReferralCallback), MarshalMode.ManagedToUnmanagedIn, typeof(MarshalValue))]

src/libraries/Common/src/Interop/Interop.Odbc.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Data.Odbc;
66
using System.Runtime.ConstrainedExecution;
77
using System.Runtime.InteropServices;
8-
#if NET7_0_OR_GREATER
8+
#if NET
99
using System.Runtime.InteropServices.Marshalling;
1010
#endif
1111
using System.Runtime.Versioning;
@@ -38,7 +38,7 @@ internal static partial ODBC32.SQLRETURN SQLAllocHandle(
3838
/*SQLUSMALLINT*/ushort ColumnNumber,
3939
/*SQLSMALLINT*/ODBC32.SQL_C TargetType,
4040
/*SQLPOINTER*/
41-
#if NET7_0_OR_GREATER
41+
#if NET
4242
[MarshalUsing(typeof(HandleRefMarshaller))]
4343
#endif
4444
HandleRef TargetValue,
@@ -64,13 +64,13 @@ internal static partial ODBC32.SQLRETURN SQLBindCol(
6464
/*SQLULEN*/IntPtr cbColDef,
6565
/*SQLSMALLINT*/IntPtr ibScale,
6666
/*SQLPOINTER*/
67-
#if NET7_0_OR_GREATER
67+
#if NET
6868
[MarshalUsing(typeof(HandleRefMarshaller))]
6969
#endif
7070
HandleRef rgbValue,
7171
/*SQLLEN*/IntPtr BufferLength,
7272
/*SQLLEN* */
73-
#if NET7_0_OR_GREATER
73+
#if NET
7474
[MarshalUsing(typeof(HandleRefMarshaller))]
7575
#endif
7676
HandleRef StrLen_or_Ind);
@@ -326,7 +326,7 @@ internal static partial ODBC32.SQLRETURN SQLSetConnectAttrW(
326326
/*SQLSMALLINT*/short ColumnNumber,
327327
/*SQLSMALLINT*/ODBC32.SQL_DESC FieldIdentifier,
328328
/*SQLPOINTER*/
329-
#if NET7_0_OR_GREATER
329+
#if NET
330330
[MarshalUsing(typeof(HandleRefMarshaller))]
331331
#endif
332332
HandleRef CharacterAttribute,

src/libraries/Common/src/Interop/Windows/CryptUI/Interop.CryptUIDlgCertificate.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System;
55
using System.Runtime.CompilerServices;
66
using System.Runtime.InteropServices;
7-
#if NET7_0_OR_GREATER
7+
#if NET
88
using System.Runtime.InteropServices.Marshalling;
99
#endif
1010
using Microsoft.Win32.SafeHandles;
@@ -13,7 +13,7 @@ internal static partial class Interop
1313
{
1414
internal static partial class CryptUI
1515
{
16-
#if NET7_0_OR_GREATER
16+
#if NET
1717
[NativeMarshalling(typeof(Marshaller))]
1818
#else
1919
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
@@ -39,7 +39,7 @@ internal struct CRYPTUI_VIEWCERTIFICATE_STRUCTW
3939
internal IntPtr rgPropSheetPages;
4040
internal uint nStartPage;
4141

42-
#if NET7_0_OR_GREATER
42+
#if NET
4343
[CustomMarshaller(typeof(CRYPTUI_VIEWCERTIFICATE_STRUCTW), MarshalMode.Default, typeof(Marshaller))]
4444
public static class Marshaller
4545
{
@@ -127,7 +127,7 @@ public CRYPTUI_VIEWCERTIFICATE_STRUCTW ToManaged()
127127
#endif
128128
}
129129

130-
#if NET7_0_OR_GREATER
130+
#if NET
131131
[NativeMarshalling(typeof(Marshaller))]
132132
#else
133133
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
@@ -151,7 +151,7 @@ internal struct CRYPTUI_SELECTCERTIFICATE_STRUCTW
151151
internal IntPtr rgPropSheetPages;
152152
internal IntPtr hSelectedCertStore;
153153

154-
#if NET7_0_OR_GREATER
154+
#if NET
155155
[CustomMarshaller(typeof(CRYPTUI_SELECTCERTIFICATE_STRUCTW), MarshalMode.Default, typeof(Marshaller))]
156156
public static class Marshaller
157157
{

src/libraries/Common/src/Interop/Windows/Gdi32/Interop.AbortDoc.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Runtime.InteropServices;
5-
#if NET7_0_OR_GREATER
5+
#if NET
66
using System.Runtime.InteropServices.Marshalling;
77
#endif
88

@@ -12,7 +12,7 @@ internal static partial class Gdi32
1212
{
1313
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
1414
internal static partial int AbortDoc(
15-
#if NET7_0_OR_GREATER
15+
#if NET
1616
[MarshalUsing(typeof(HandleRefMarshaller))]
1717
#endif
1818
HandleRef hDC);

src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateCompatibleBitmap.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using System;
55
using System.Runtime.InteropServices;
6-
#if NET7_0_OR_GREATER
6+
#if NET
77
using System.Runtime.InteropServices.Marshalling;
88
#endif
99

@@ -13,7 +13,7 @@ internal static partial class Gdi32
1313
{
1414
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
1515
internal static partial IntPtr CreateCompatibleBitmap(
16-
#if NET7_0_OR_GREATER
16+
#if NET
1717
[MarshalUsing(typeof(HandleRefMarshaller))]
1818
#endif
1919
HandleRef hDC, int width, int height);

src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateDIBSection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using System;
55
using System.Runtime.InteropServices;
6-
#if NET7_0_OR_GREATER
6+
#if NET
77
using System.Runtime.InteropServices.Marshalling;
88
#endif
99

@@ -13,7 +13,7 @@ internal static partial class Gdi32
1313
{
1414
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
1515
internal static partial IntPtr CreateDIBSection(
16-
#if NET7_0_OR_GREATER
16+
#if NET
1717
[MarshalUsing(typeof(HandleRefMarshaller))]
1818
#endif
1919
HandleRef hdc, ref BITMAPINFO_FLAT bmi, int iUsage, ref IntPtr ppvBits, IntPtr hSection, int dwOffset);

src/libraries/Common/src/Interop/Windows/Gdi32/Interop.DEVMODE.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using System;
55
using System.Runtime.InteropServices;
6-
#if NET7_0_OR_GREATER
6+
#if NET
77
using System.Runtime.InteropServices.Marshalling;
88
#endif
99

src/libraries/Common/src/Interop/Windows/Gdi32/Interop.EndDoc.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Runtime.InteropServices;
5-
#if NET7_0_OR_GREATER
5+
#if NET
66
using System.Runtime.InteropServices.Marshalling;
77
#endif
88

@@ -12,7 +12,7 @@ internal static partial class Gdi32
1212
{
1313
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
1414
internal static partial int EndDoc(
15-
#if NET7_0_OR_GREATER
15+
#if NET
1616
[MarshalUsing(typeof(HandleRefMarshaller))]
1717
#endif
1818
HandleRef hDC);

src/libraries/Common/src/Interop/Windows/Gdi32/Interop.EndPage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Runtime.InteropServices;
5-
#if NET7_0_OR_GREATER
5+
#if NET
66
using System.Runtime.InteropServices.Marshalling;
77
#endif
88

@@ -12,7 +12,7 @@ internal static partial class Gdi32
1212
{
1313
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
1414
internal static partial int EndPage(
15-
#if NET7_0_OR_GREATER
15+
#if NET
1616
[MarshalUsing(typeof(HandleRefMarshaller))]
1717
#endif
1818
HandleRef hDC);

src/libraries/Common/src/Interop/Windows/Gdi32/Interop.ExtEscape.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Runtime.InteropServices;
5-
#if NET7_0_OR_GREATER
5+
#if NET
66
using System.Runtime.InteropServices.Marshalling;
77
#endif
88

@@ -16,14 +16,14 @@ internal static partial class Gdi32
1616

1717
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
1818
internal static partial int ExtEscape(
19-
#if NET7_0_OR_GREATER
19+
#if NET
2020
[MarshalUsing(typeof(HandleRefMarshaller))]
2121
#endif
2222
HandleRef hDC, int nEscape, int cbInput, ref int inData, int cbOutput, out int outData);
2323

2424
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
2525
internal static partial int ExtEscape(
26-
#if NET7_0_OR_GREATER
26+
#if NET
2727
[MarshalUsing(typeof(HandleRefMarshaller))]
2828
#endif
2929
HandleRef hDC, int nEscape, int cbInput, byte[] inData, int cbOutput, out int outData);

src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetDIBits.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using System;
55
using System.Runtime.InteropServices;
6-
#if NET7_0_OR_GREATER
6+
#if NET
77
using System.Runtime.InteropServices.Marshalling;
88
#endif
99

@@ -13,11 +13,11 @@ internal static partial class Gdi32
1313
{
1414
[LibraryImport(Libraries.Gdi32)]
1515
internal static partial int GetDIBits(
16-
#if NET7_0_OR_GREATER
16+
#if NET
1717
[MarshalUsing(typeof(HandleRefMarshaller))]
1818
#endif
1919
HandleRef hdc,
20-
#if NET7_0_OR_GREATER
20+
#if NET
2121
[MarshalUsing(typeof(HandleRefMarshaller))]
2222
#endif
2323
HandleRef hbm, int arg1, int arg2, IntPtr arg3, ref BITMAPINFO_FLAT bmi, int arg5);

src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetObject.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using System;
55
using System.Runtime.InteropServices;
6-
#if NET7_0_OR_GREATER
6+
#if NET
77
using System.Runtime.InteropServices.Marshalling;
88
#endif
99

@@ -13,20 +13,20 @@ internal static partial class Gdi32
1313
{
1414
[LibraryImport(Libraries.Gdi32, EntryPoint = "GetObjectW", SetLastError = true)]
1515
internal static partial int GetObject(
16-
#if NET7_0_OR_GREATER
16+
#if NET
1717
[MarshalUsing(typeof(HandleRefMarshaller))]
1818
#endif
1919
HandleRef hObject, int nSize, ref BITMAP bm);
2020

2121
[LibraryImport(Libraries.Gdi32, EntryPoint = "GetObjectW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
2222
internal static partial int GetObject(
23-
#if NET7_0_OR_GREATER
23+
#if NET
2424
[MarshalUsing(typeof(HandleRefMarshaller))]
2525
#endif
2626
HandleRef hObject, int nSize, ref Interop.User32.LOGFONT lf);
2727

2828
internal static unsafe int GetObject(
29-
#if NET7_0_OR_GREATER
29+
#if NET
3030
[MarshalUsing(typeof(HandleRefMarshaller))]
3131
#endif
3232
HandleRef hObject, ref Interop.User32.LOGFONT lp)

src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetPaletteEntries.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Runtime.InteropServices;
5-
#if NET7_0_OR_GREATER
5+
#if NET
66
using System.Runtime.InteropServices.Marshalling;
77
#endif
88

@@ -12,7 +12,7 @@ internal static partial class Gdi32
1212
{
1313
[LibraryImport(Libraries.Gdi32)]
1414
internal static partial uint GetPaletteEntries(
15-
#if NET7_0_OR_GREATER
15+
#if NET
1616
[MarshalUsing(typeof(HandleRefMarshaller))]
1717
#endif
1818
HandleRef hpal, int iStartIndex, int nEntries, byte[] lppe);

src/libraries/Common/src/Interop/Windows/Gdi32/Interop.IntersectClipRect.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using System;
55
using System.Runtime.InteropServices;
6-
#if NET7_0_OR_GREATER
6+
#if NET
77
using System.Runtime.InteropServices.Marshalling;
88
#endif
99

@@ -13,7 +13,7 @@ internal static partial class Gdi32
1313
{
1414
[LibraryImport(Libraries.Gdi32, SetLastError = true)]
1515
internal static partial int IntersectClipRect(
16-
#if NET7_0_OR_GREATER
16+
#if NET
1717
[MarshalUsing(typeof(HandleRefMarshaller))]
1818
#endif
1919
HandleRef hDC, int x1, int y1, int x2, int y2);

0 commit comments

Comments
 (0)