[go: nahoru, domu]

Skip to content

Commit

Permalink
.NET 7.0 (#1358)
Browse files Browse the repository at this point in the history
* .NET 7.0

* Get test_int passing

* Get test_methodbinder1 passing

* Get test_cliclass passing

* Disable SYSLIB warnings

* Add IsolationLevel=PROCESS to test_re_stdlib

* Update to .NET 7.0 release

* Add checked for CA2020

* Don't include preview releases
  • Loading branch information
slozier committed Apr 6, 2024
1 parent b821600 commit 3c5c5b5
Show file tree
Hide file tree
Showing 21 changed files with 108 additions and 30 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,6 @@ dotnet_diagnostic.CA5350.severity = suggestion # CA5350: Do Not Use Weak Crypto
dotnet_diagnostic.CA5351.severity = suggestion # CA5351: Do Not Use Broken Cryptographic Algorithms
dotnet_diagnostic.CA5359.severity = suggestion # CA5359: Do Not Disable Certificate Validation
dotnet_diagnostic.CA5372.severity = suggestion # CA5372: Use XmlReader For XPathDocument

dotnet_diagnostic.SYSLIB1045.severity = suggestion # SYSLIB1045: Use 'RegexGeneratorAttribute' to generate the regular expression implementation at compile-time
dotnet_diagnostic.SYSLIB1054.severity = suggestion # SYSLIB1054: Use 'LibraryImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time
7 changes: 7 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Setup .NET 7.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.0.x'
- name: Version Information
run: |
dotnet --info
Expand All @@ -50,3 +54,6 @@ jobs:
- name: Test (net6.0)
run: ./make.ps1 -frameworks net6.0 test-all
shell: pwsh
- name: Test (net7.0)
run: ./make.ps1 -frameworks net7.0 test-all
shell: pwsh
9 changes: 9 additions & 0 deletions Build/net7.0-windows.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>
<PropertyGroup>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<IntermediateOutputPath Condition=" '$(TargetFramework)' == 'net7.0-windows' ">$(BaseIntermediateOutputPath)$(Configuration)\net7.0</IntermediateOutputPath>
<OutputPath Condition=" '$(TargetFramework)' == 'net7.0-windows' ">$(BaseOutputPath)\net7.0</OutputPath>
</PropertyGroup>

<Import Project="net7.0.props" />
</Project>
41 changes: 41 additions & 0 deletions Build/net7.0.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IsFullFramework>false</IsFullFramework>
</PropertyGroup>

<PropertyGroup>
<Features>$(Features);FEATURE_APARTMENTSTATE</Features>
<Features>$(Features);FEATURE_ASSEMBLY_GETFORWARDEDTYPES</Features>
<Features>$(Features);FEATURE_ASSEMBLY_RESOLVE</Features>
<Features>$(Features);FEATURE_ASSEMBLYBUILDER_DEFINEDYNAMICASSEMBLY</Features>
<Features>$(Features);FEATURE_BASIC_CONSOLE</Features>
<Features>$(Features);FEATURE_CODEDOM</Features>
<Features>$(Features);FEATURE_COM</Features>
<Features>$(Features);FEATURE_CONFIGURATION</Features>
<Features>$(Features);FEATURE_CTYPES</Features>
<Features>$(Features);FEATURE_CUSTOM_TYPE_DESCRIPTOR</Features>
<Features>$(Features);FEATURE_EXCEPTION_STATE</Features>
<Features>$(Features);FEATURE_FILESYSTEM</Features>
<Features>$(Features);FEATURE_FULL_CONSOLE</Features>
<Features>$(Features);FEATURE_FULL_CRYPTO</Features>
<Features>$(Features);FEATURE_FULL_NET</Features>
<Features>$(Features);FEATURE_LCG</Features>
<Features>$(Features);FEATURE_LOADWITHPARTIALNAME</Features>
<Features>$(Features);FEATURE_METADATA_READER</Features>
<Features>$(Features);FEATURE_MMAP</Features>
<Features>$(Features);FEATURE_NATIVE</Features>
<Features>$(Features);FEATURE_OSPLATFORMATTRIBUTE</Features>
<Features>$(Features);FEATURE_PIPES</Features>
<Features>$(Features);FEATURE_PROCESS</Features>
<Features>$(Features);FEATURE_REFEMIT</Features>
<Features>$(Features);FEATURE_REGISTRY</Features>
<Features>$(Features);FEATURE_RUNTIMEINFORMATION</Features>
<Features>$(Features);FEATURE_SECURITY_RULES</Features>
<Features>$(Features);FEATURE_SERIALIZATION</Features>
<Features>$(Features);FEATURE_STACK_TRACE</Features>
<Features>$(Features);FEATURE_SYNC_SOCKETS</Features>
<Features>$(Features);FEATURE_THREAD</Features>
<Features>$(Features);FEATURE_XMLDOC</Features>
</PropertyGroup>
</Project>
10 changes: 8 additions & 2 deletions Build/steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,17 @@ steps:
version: '3.1.x'

- task: UseDotNet@2
displayName: Install .NET 6.0 SDK for build
displayName: Install .NET 6.0 runtime for testing
inputs:
packageType: 'sdk'
packageType: 'runtime'
version: '6.0.x'

- task: UseDotNet@2
displayName: Install .NET 7.0 SDK for build
inputs:
packageType: 'sdk'
version: '7.0.x'

# Set Mono version on macOS
- ${{ if eq(parameters.os, 'macOS') }}:
- task: Bash@3
Expand Down
3 changes: 3 additions & 0 deletions IronPython.sln
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{17737ACB
Build\net462.props = Build\net462.props
Build\net6.0-windows.props = Build\net6.0-windows.props
Build\net6.0.props = Build\net6.0.props
Build\net7.0-windows.props = Build\net7.0-windows.props
Build\net7.0.props = Build\net7.0.props
Build\netcoreapp3.1.props = Build\netcoreapp3.1.props
Build\netstandard2.0.props = Build\netstandard2.0.props
Build\steps.yml = Build\steps.yml
Build\Tasks.Targets = Build\Tasks.Targets
Expand Down
2 changes: 1 addition & 1 deletion Src/IronPython.Modules/IronPython.Modules.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net462;netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>net462;netstandard2.0;net6.0;net7.0</TargetFrameworks>
<BaseAddress>885063680</BaseAddress>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down
2 changes: 1 addition & 1 deletion Src/IronPython.Modules/_overlapped.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static class PythonOverlapped {
private static extern IntPtr _CreateIoCompletionPort(IntPtr FileHandle, IntPtr ExistingCompletionPort, UIntPtr CompletionKey, uint NumberOfConcurrentThreads);

public static BigInteger CreateIoCompletionPort(BigInteger handle, BigInteger port, BigInteger key, int concurrency) {
var res = _CreateIoCompletionPort((IntPtr)(long)handle, (IntPtr)(long)port, (UIntPtr)(ulong)key, (uint)concurrency);
var res = _CreateIoCompletionPort(checked((IntPtr)(long)handle), checked((IntPtr)(long)port), checked((UIntPtr)(ulong)key), (uint)concurrency);
if (res == IntPtr.Zero) {
throw PythonNT.GetLastWin32Error();
}
Expand Down
2 changes: 1 addition & 1 deletion Src/IronPython.Modules/_socket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ public int sendto([NotNone] IBufferProtocol data, [NotNone] PythonTuple address)
/// </summary>
internal static Socket? HandleToSocket(Int64 handle) {
lock (_handleToSocket) {
if (_handleToSocket.TryGetValue((IntPtr)handle, out WeakReference? weakref)) {
if (_handleToSocket.TryGetValue(checked((IntPtr)handle), out WeakReference? weakref)) {
return weakref.Target as Socket;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Src/IronPython.Modules/_winapi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static class PythonWinApi {
throw new NotImplementedException();
}
else {
var result = ConnectNamedPipe((IntPtr)(long)handle, IntPtr.Zero);
var result = ConnectNamedPipe(checked((IntPtr)(long)handle), IntPtr.Zero);

if (!result) throw PythonNT.GetLastWin32Error();

Expand Down
2 changes: 1 addition & 1 deletion Src/IronPython.SQLite/IronPython.SQLite.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net462;netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>net462;netstandard2.0;net6.0;net7.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<SQLiteCommon>SQLITE_DEBUG;TRUE;WIN32;_MSC_VER;SQLITE_ASCII;SQLITE_MEM_POOL;SQLITE_ENABLE_COLUMN_METADATA;SQLITE_OS_WIN;SQLITE_SYSTEM_MALLOC;VDBE_PROFILE_OFF</SQLiteCommon>
<SQLiteCommonOmit>SQLITE_OMIT_AUTHORIZATION;SQLITE_OMIT_DEPRECATED;SQLITE_OMIT_GET_TABLE;SQLITE_OMIT_INCRBLOB;SQLITE_OMIT_LOOKASIDE;SQLITE_OMIT_SHARED_CACHE;SQLITE_OMIT_UTF16;SQLITE_OMIT_WAL</SQLiteCommonOmit>
Expand Down
2 changes: 1 addition & 1 deletion Src/IronPython.Wpf/IronPython.Wpf.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

<PropertyGroup>
<TargetFrameworks>net462;net6.0-windows</TargetFrameworks>
<TargetFrameworks>net462;net6.0-windows;net7.0-windows</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<StoreInDLLs>true</StoreInDLLs>
<UseWPF>true</UseWPF>
Expand Down
2 changes: 1 addition & 1 deletion Src/IronPython/IronPython.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net462;netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>net462;netstandard2.0;net6.0;net7.0</TargetFrameworks>
<BaseAddress>879755264</BaseAddress>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down
2 changes: 1 addition & 1 deletion Src/IronPython/Runtime/Operations/PythonOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4024,7 +4024,7 @@ internal static void PrintWithDestNoNewline(CodeContext/*!*/ context, object des
}

public static Exception InvalidType(object o, RuntimeTypeHandle handle) {
return PythonOps.TypeErrorForTypeMismatch(DynamicHelpers.GetPythonTypeFromType(Type.GetTypeFromHandle(handle)).Name, o);
return PythonOps.TypeErrorForTypeMismatch(DynamicHelpers.GetPythonTypeFromType(Type.GetTypeFromHandle(handle)!).Name, o);
}

public static Exception ZeroDivisionError() {
Expand Down
2 changes: 1 addition & 1 deletion Src/IronPythonConsole/IronPythonConsole.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net462;netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.1;net6.0;net7.0</TargetFrameworks>
<!-- EOL netcoreapp3.1 is used to test netstandard2.0 assemblies -->
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<OutputType>Exe</OutputType>
Expand Down
3 changes: 3 additions & 0 deletions Src/IronPythonTest/Cases/IronPythonCasesManifest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ Reason=Needs to be redone as two tests
Ignore=true
Reason=StackOverflowException - https://github.com/IronLanguages/ironpython2/issues/182

[IronPython.test_re_stdlib]
IsolationLevel=PROCESS # workaround for StackOverflowException on macOS on .NET 7

[IronPython.test_regressions]
IsolationLevel=PROCESS # https://github.com/IronLanguages/ironpython3/issues/489
RetryCount=2
Expand Down
2 changes: 1 addition & 1 deletion Src/IronPythonTest/IronPythonTest.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net462;netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp3.1;net6.0;net7.0</TargetFrameworks>
<!-- EOL netcoreapp3.1 is used to test netstandard2.0 assemblies -->
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<PreventStaging>true</PreventStaging>
Expand Down
3 changes: 2 additions & 1 deletion Tests/test_cliclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import sys
import unittest
from iptest import IronPythonTestCase, is_cli, is_debug, is_mono, is_netcoreapp, is_netcoreapp21, is_posix, big, run_test, skipUnlessIronPython
from iptest import IronPythonTestCase, is_cli, is_debug, is_mono, is_net70, is_netcoreapp, is_netcoreapp21, is_posix, big, run_test, skipUnlessIronPython

if is_cli:
import clr
Expand Down Expand Up @@ -1421,6 +1421,7 @@ def test_clr_dir(self):
self.assertTrue('IndexOf' not in clr.Dir('abc'))
self.assertTrue('IndexOf' in clr.DirClr('abc'))

@unittest.skipIf(is_net70, "TODO") # TODO: https://github.com/IronLanguages/ironpython3/issues/1485
def test_int32_bigint_equivalence(self):
import math

Expand Down
23 changes: 14 additions & 9 deletions Tests/test_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import sys

from iptest import IronPythonTestCase, is_cli, is_netstandard, is_mono, big, myint, skipUnlessIronPython, run_test
from iptest import IronPythonTestCase, is_cli, is_net70, is_netstandard, is_mono, big, myint, skipUnlessIronPython, run_test

class IntNoClrTest(IronPythonTestCase):
"""Must be run before IntTest because it depends on CLR API not being visible."""
Expand All @@ -27,14 +27,19 @@ def test_instance_set(self):
self.assertSetEqual(set(dir(j)) - set(dir(i)), {'GetByteCount', 'TryWriteBytes'})
self.assertSetEqual(set(dir(int)) - set(dir(Int32)), {'GetByteCount', 'TryWriteBytes'})

# these two assertions fail on IronPython compiled for .NET Standard
if not is_netstandard:
self.assertSetEqual(set(dir(i)) - set(dir(j)), {'MaxValue', 'MinValue'})
self.assertSetEqual(set(dir(Int32)) - set(dir(int)), {'MaxValue', 'MinValue'})

# weaker assertions that should always hold
self.assertTrue((set(dir(i)) - set(dir(j))).issubset({'MaxValue', 'MinValue', 'GetByteCount', 'TryWriteBytes', 'GetBitLength'}))
self.assertTrue((set(dir(Int32)) - set(dir(int))).issubset({'MaxValue', 'MinValue', 'GetByteCount', 'TryWriteBytes', 'GetBitLength'}))
if is_net70: # https://github.com/IronLanguages/ironpython3/issues/1485
diff = {'TryConvertToChecked', 'MinValue', 'TryConvertFromChecked', 'MaxValue', 'TryConvertFromTruncating', 'WriteBigEndian', 'GetShortestBitLength', 'TryWriteLittleEndian', 'WriteLittleEndian', 'TryConvertToSaturating', 'TryConvertFromSaturating', 'TryWriteBigEndian', 'TryConvertToTruncating'}
self.assertSetEqual(set(dir(i)) - set(dir(j)), diff)
self.assertSetEqual(set(dir(Int32)) - set(dir(int)), diff)
else:
# these two assertions fail on IronPython compiled for .NET Standard
if not is_netstandard:
self.assertSetEqual(set(dir(i)) - set(dir(j)), {'MaxValue', 'MinValue'})
self.assertSetEqual(set(dir(Int32)) - set(dir(int)), {'MaxValue', 'MinValue'})

# weaker assertions that should always hold
self.assertTrue((set(dir(i)) - set(dir(j))).issubset({'MaxValue', 'MinValue', 'GetByteCount', 'TryWriteBytes', 'GetBitLength'}))
self.assertTrue((set(dir(Int32)) - set(dir(int))).issubset({'MaxValue', 'MinValue', 'GetByteCount', 'TryWriteBytes', 'GetBitLength'}))

def test_from_bytes(self):
self.assertEqual(type(int.from_bytes(b"abc", "big")), int)
Expand Down
14 changes: 7 additions & 7 deletions Tests/test_methodbinder1.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import unittest

from iptest import IronPythonTestCase, is_cli, is_mono, is_netcoreapp, run_test, skipUnlessIronPython
from iptest import IronPythonTestCase, is_mono, is_net70, is_netcoreapp, run_test, skipUnlessIronPython
from iptest.type_util import *

from System import Int32
Expand Down Expand Up @@ -102,7 +102,7 @@ def test_this_matrix(self):


funcnames = "M201 M680 M202 M203 M681 M204 M205 M301 M302 M303 M304 M310 M311 M312 M313 M320 M321 M400".split()
matrix = (
matrix = [
#### M201 M680 M202 M203 M681 M204 M205 M301 M302 M303 M304 M310 M311 M312 M313 M320 M321 M400
#### int int? double bigint bigint? bool str sbyte i16 i64 single byte ui16 ui32 ui64 char decm obj
( "SByteMax", True, True, True, True, True, True, TypeE, True, True, True, True, True, True, True, True, TypeE, True, True, ),
Expand Down Expand Up @@ -172,16 +172,17 @@ def test_this_matrix(self):
( (3+0j), TypeE, TypeE, TypeE, TypeE, TypeE, True, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, True, ),
( (3+1j), TypeE, TypeE, TypeE, TypeE, TypeE, True, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, True, ),
( mycomplex1, TypeE, TypeE, TypeE, TypeE, TypeE, True, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, True, )
)
]


InvariantCulture = System.Globalization.CultureInfo.InvariantCulture
matrix = list(matrix)

ch2bi = True if is_net70 else TypeE # .NET 7 adds an implicit cast from Char to BigInteger
################################################## pass in char #########################################################
#### M201 M680 M202 M203 M681 M204 M205 M301 M302 M303 M304 M310 M311 M312 M313 M320 M321 M400
#### int int? double bigint bigint? bool str sbyte i16 i64 single byte ui16 ui32 ui64 char decm obj
matrix.append((System.Char.Parse('A'), TypeE, TypeE, TypeE, TypeE, TypeE, True, True, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, True, True, True, ))
matrix.append((System.Char.Parse('A'), TypeE, TypeE, TypeE, ch2bi, ch2bi, True, True, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, TypeE, True, True, True, ))

InvariantCulture = System.Globalization.CultureInfo.InvariantCulture
################################################## pass in float #########################################################
#### single/double becomes Int32/BigInteger, but this does not apply to other primitive types
#### M201 M680 M202 M203 M681 M204 M205 M301 M302 M303 M304 M310 M311 M312 M313 M320 M321 M400
Expand All @@ -190,7 +191,6 @@ def test_this_matrix(self):
matrix.append((System.Double.Parse("10.2", InvariantCulture), TypeE, TypeE, True, TypeE, TypeE, True, TypeE, TypeE, TypeE, TypeE, True, TypeE, TypeE, TypeE, TypeE, TypeE, True, True, ))
matrix.append((System.Single.Parse("-8.1", InvariantCulture), TypeE, TypeE, True, TypeE, TypeE, True, TypeE, TypeE, TypeE, TypeE, True, TypeE, TypeE, TypeE, TypeE, TypeE, True, True, ))
matrix.append((System.Double.Parse("-1.8", InvariantCulture), TypeE, TypeE, True, TypeE, TypeE, True, TypeE, TypeE, TypeE, TypeE, True, TypeE, TypeE, TypeE, TypeE, TypeE, True, True, ))
matrix = tuple(matrix)

for scenario in matrix:
if isinstance(scenario[0], str):
Expand Down
2 changes: 1 addition & 1 deletion make.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Param(
[Parameter(Position=1)]
[String] $target = "build",
[String] $configuration = "Release",
[String[]] $frameworks=@('net462','netcoreapp3.1','net6.0'),
[String[]] $frameworks=@('net462','netcoreapp3.1','net6.0','net7.0'),
[String] $platform = "x64",
[switch] $runIgnored,
[int] $jobs = [System.Environment]::ProcessorCount
Expand Down

0 comments on commit 3c5c5b5

Please sign in to comment.