Skip to content

Commit

Permalink
Add .NET 8.0 target (#276)
Browse files Browse the repository at this point in the history
* Run tests on .NET 8.0

* Add .NET 8 target

* Add .NET 9 target for testing

* Add missing props

* Replace Shell++ task with Bash

* Version information

* Try to fix macOS build
  • Loading branch information
slozier authored Jun 25, 2024
1 parent 872730a commit 52ec598
Show file tree
Hide file tree
Showing 40 changed files with 245 additions and 117 deletions.
9 changes: 7 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ dotnet_diagnostic.CA1305.severity = none # CA1305: Specify IFormatProvide
dotnet_diagnostic.CA1307.severity = suggestion # CA1307: Specify StringComparison for clarity
dotnet_diagnostic.CA1309.severity = suggestion # CA1309: Use ordinal string comparison
dotnet_diagnostic.CA1310.severity = warning # CA1310: Specify StringComparison for correctness
dotnet_diagnostic.CA1510.severity = none # CA1510: Use ArgumentNullException throw helper
dotnet_diagnostic.CA1512.severity = none # CA1512: Use ArgumentOutOfRangeException throw helper
dotnet_diagnostic.CA1513.severity = none # CA1513: Use ObjectDisposedException throw helper
dotnet_diagnostic.CA1707.severity = none # CA1707: Identifiers should not contain underscores
dotnet_diagnostic.CA1708.severity = none # CA1708: Identifiers should differ by more than case
dotnet_diagnostic.CA1710.severity = none # CA1710: Identifiers should have correct suffix
Expand All @@ -70,7 +73,6 @@ dotnet_diagnostic.CA1805.severity = suggestion # CA1805: Do not initialize unne
dotnet_diagnostic.CA1806.severity = none # CA1806: Do not ignore method results
dotnet_diagnostic.CA1816.severity = suggestion # CA1816: Dispose methods should call SuppressFinalize
dotnet_diagnostic.CA1822.severity = none # CA1822: Mark members as static
dotnet_diagnostic.CA1825.severity = none # CA1825: Avoid zero-length array allocations
dotnet_diagnostic.CA1830.severity = suggestion # CA1830: Prefer strongly-typed Append and Insert method overloads on StringBuilder
dotnet_diagnostic.CA1834.severity = suggestion # CA1834: Consider using 'StringBuilder.Append(char)' when applicable
dotnet_diagnostic.CA1837.severity = suggestion # CA1837: Use 'Environment.ProcessId'
Expand All @@ -79,9 +81,9 @@ dotnet_diagnostic.CA1845.severity = none # CA1845: Use span-based 'string
dotnet_diagnostic.CA1846.severity = none # CA1846: Prefer 'AsSpan' over 'Substring'
dotnet_diagnostic.CA1847.severity = none # CA1847: Use char literal for a single character lookup
dotnet_diagnostic.CA1852.severity = suggestion # CA1852: Seal internal types
dotnet_diagnostic.CA1854.severity = suggestion # CA1854: Prefer the 'IDictionary.TryGetValue(TKey, out TValue)' method
dotnet_diagnostic.CA1859.severity = suggestion # CA1859: Use concrete types when possible for improved performance
dotnet_diagnostic.CA1861.severity = suggestion # CA1861: Avoid constant arrays as arguments
dotnet_diagnostic.CA1863.severity = none # CA1863: Use 'CompositeFormat'
dotnet_diagnostic.CA2101.severity = suggestion # CA2101: Specify marshaling for P/Invoke string arguments
dotnet_diagnostic.CA2201.severity = none # CA2201: Do not raise reserved exception types
dotnet_diagnostic.CA2208.severity = suggestion # CA2208: Instantiate argument exceptions correctly
Expand All @@ -94,3 +96,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
17 changes: 16 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
os: [windows-latest, ubuntu-latest, macos-latest-large]

steps:
- uses: actions/checkout@v2
Expand All @@ -22,6 +22,15 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Setup .NET 8.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.0.x'
- name: Setup .NET 9.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: '9.0.x'
include-prerelease: true
- name: Build
run: pwsh make.ps1
- name: Package
Expand All @@ -39,3 +48,9 @@ jobs:
- name: Test (net6.0)
run: ./make.ps1 -frameworks net6.0 test-all
shell: pwsh
- name: Test (net8.0)
run: ./make.ps1 -frameworks net8.0 test-all
shell: pwsh
- name: Test (net9.0)
run: ./make.ps1 -frameworks net9.0 test-all
shell: pwsh
2 changes: 1 addition & 1 deletion Build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
Outputs="$(PackageDir)\DynamicLanguageRuntime.$(PackageVersion).zip">
<ItemGroup>
<ZipFiles Include="$(StageDir)\**\*.dll;$(StageDir)\**\*.xml;$(StageDir)\README.md;$(StageDir)\LICENSE"
Exclude="$(StageDir)\netcoreapp3.1\*;$(StageDir)\net7.0*\*;$(StageDir)\net8.0*\*" />
Exclude="$(StageDir)\netcoreapp3.1\*;$(StageDir)\net7.0*\*;$(StageDir)\net9.0*\*" />
</ItemGroup>
<Message Text="$(ZipFiles)" />
<Zip Files="@(ZipFiles)" ZipFileName="$(PackageDir)\DynamicLanguageRuntime.$(PackageVersion).zip" WorkingDirectory="$(StageDir)"/>
Expand Down
37 changes: 37 additions & 0 deletions Build/net8.0.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?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_CODEDOM</Features>
<Features>$(Features);FEATURE_COM</Features>
<Features>$(Features);FEATURE_CONFIGURATION</Features>
<Features>$(Features);FEATURE_CUSTOM_TYPE_DESCRIPTOR</Features>
<Features>$(Features);FEATURE_EXCEPTION_STATE</Features>
<Features>$(Features);FEATURE_FILESYSTEM</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_PIPES</Features>
<Features>$(Features);FEATURE_PROCESS</Features>
<Features>$(Features);FEATURE_REFEMIT</Features>
<Features>$(Features);FEATURE_REGISTRY</Features>
<Features>$(Features);FEATURE_SECURITY_RULES</Features>
<Features>$(Features);FEATURE_STACK_TRACE</Features>
<Features>$(Features);FEATURE_SYNC_SOCKETS</Features>
<Features>$(Features);FEATURE_THREAD</Features>
<Features>$(Features);FEATURE_TYPE_EQUIVALENCE</Features>
<Features>$(Features);FEATURE_TYPECONVERTER</Features>
<Features>$(Features);FEATURE_XMLDOC</Features>
</PropertyGroup>
</Project>
37 changes: 37 additions & 0 deletions Build/net9.0.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?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_CODEDOM</Features>
<Features>$(Features);FEATURE_COM</Features>
<Features>$(Features);FEATURE_CONFIGURATION</Features>
<Features>$(Features);FEATURE_CUSTOM_TYPE_DESCRIPTOR</Features>
<Features>$(Features);FEATURE_EXCEPTION_STATE</Features>
<Features>$(Features);FEATURE_FILESYSTEM</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_PIPES</Features>
<Features>$(Features);FEATURE_PROCESS</Features>
<Features>$(Features);FEATURE_REFEMIT</Features>
<Features>$(Features);FEATURE_REGISTRY</Features>
<Features>$(Features);FEATURE_SECURITY_RULES</Features>
<Features>$(Features);FEATURE_STACK_TRACE</Features>
<Features>$(Features);FEATURE_SYNC_SOCKETS</Features>
<Features>$(Features);FEATURE_THREAD</Features>
<Features>$(Features);FEATURE_TYPE_EQUIVALENCE</Features>
<Features>$(Features);FEATURE_TYPECONVERTER</Features>
<Features>$(Features);FEATURE_XMLDOC</Features>
</PropertyGroup>
</Project>
55 changes: 26 additions & 29 deletions Build/steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,30 @@ 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 8.0 SDK for build
inputs:
packageType: 'sdk'
version: '8.0.x'

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

# Set Mono version on macOS
- ${{ if eq(parameters.os, 'macOS') }}:
- task: ms-devlabs.utilitytasks.task-Shellpp.Shell++@0
- task: Bash@3
displayName: Set Mono Version
inputs:
type: InlineScript
targetType: inline
script: |
# use Mono 6.4.0 version
SYMLINK=6.4.0
Expand All @@ -47,31 +60,15 @@ steps:
echo "##vso[task.setvariable variable=PKG_CONFIG_PATH;]$MONOPREFIX/lib/pkgconfig:$MONOPREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
echo "##vso[task.setvariable variable=PATH;]$MONOPREFIX/bin:$PATH"
# Install mono when running on Linux
- ${{ if eq(parameters.os, 'Linux') }}:
- task: ms-devlabs.utilitytasks.task-Shellpp.Shell++@0
displayName: Version Information
inputs:
type: InlineScript
script: |
# Dump some info about the tools
mono --version
msbuild /version
dotnet --info
df -Th
# Dump version info on macOS
- ${{ if eq(parameters.os, 'macOS') }}:
- task: ms-devlabs.utilitytasks.task-Shellpp.Shell++@0
displayName: Version Information
inputs:
type: InlineScript
script: |
# Dump some info about the tools
mono --version
msbuild /version
dotnet --info
# Dump version info
- task: PowerShell@2
displayName: Version Information
inputs:
targetType: inline
script: |
dotnet --info
try { msbuild -version } catch { }
try { mono --version } catch { }
- powershell: ./make.ps1
displayName: Build
Expand Down
2 changes: 2 additions & 0 deletions Dlr.sln
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{60056F49
Build\After.targets = Build\After.targets
Build\net462.props = Build\net462.props
Build\net6.0.props = Build\net6.0.props
Build\net8.0.props = Build\net8.0.props
Build\net9.0.props = Build\net9.0.props
Build\netstandard2.0.props = Build\netstandard2.0.props
Build\steps.yml = Build\steps.yml
EndProjectSection
Expand Down
9 changes: 6 additions & 3 deletions Package/nuget/DynamicLanguageRuntime.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@
<group targetFramework="net6.0">
<dependency id="System.CodeDom" version="6.0.0" />
</group>
<group targetFramework="net8.0">
<dependency id="System.CodeDom" version="8.0.0" />
</group>
</dependencies>
</metadata>
<files>
<file src="**\*.dll" target="lib" exclude="netcoreapp3.1\*;net7.0*\*;net8.0*\*" />
<file src="**\*.pdb" target="lib" exclude="netcoreapp3.1\*;net7.0*\*;net8.0*\*" />
<file src="**\*.xml" target="lib" exclude="netcoreapp3.1\*;net7.0*\*;net8.0*\*" />
<file src="**\*.dll" target="lib" exclude="netcoreapp3.1\*;net7.0*\*;net9.0*\*" />
<file src="**\*.pdb" target="lib" exclude="netcoreapp3.1\*;net7.0*\*;net9.0*\*" />
<file src="**\*.xml" target="lib" exclude="netcoreapp3.1\*;net7.0*\*;net9.0*\*" />
<file src="README.md;LICENSE" />
</files>
</package>
2 changes: 1 addition & 1 deletion Src/Microsoft.Dynamic/Actions/Calls/ArgumentBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Microsoft.Scripting.Actions.Calls {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes")] // TODO
public struct ArgumentBinding {
private static readonly int[] _EmptyBinding = new int[0];
private static readonly int[] _EmptyBinding = System.Array.Empty<int>();

private readonly int _positionalArgCount;
private readonly int[] _binding; // immutable
Expand Down
2 changes: 1 addition & 1 deletion Src/Microsoft.Dynamic/Actions/MemberTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Microsoft.Scripting.Actions {
/// </summary>
public abstract class MemberTracker {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly")]
public static readonly MemberTracker[] EmptyTrackers = new MemberTracker[0];
public static readonly MemberTracker[] EmptyTrackers = Array.Empty<MemberTracker>();

private static readonly Dictionary<MemberKey, MemberTracker> _trackers = new Dictionary<MemberKey, MemberTracker>();

Expand Down
22 changes: 10 additions & 12 deletions Src/Microsoft.Dynamic/Actions/NamespaceTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ internal NamespaceTracker GetOrMakeChildPackage(string childName, Assembly assem

if (_dict.TryGetValue(childName, out MemberTracker ret)) {
// If we have a module, then we add the assembly to the InnerModule
// If it's not a module, we'll wipe it out below, eg "def System(): pass" then
// If it's not a module, we'll wipe it out below, eg "def System(): pass" then
// "import System" will result in the namespace being visible.
if (ret is NamespaceTracker package) {
if (!package._packageAssemblies.Contains(assem)) {
Expand Down Expand Up @@ -102,10 +102,11 @@ internal void AddTypeName(string typeName, Assembly assem) {
Assert.NotNull(typeName, assem);
Debug.Assert(typeName.IndexOf('.') == -1); // This is the simple name, not the full name

if (!_typeNames.ContainsKey(assem)) {
_typeNames[assem] = new TypeNames(assem, _fullName);
if (!_typeNames.TryGetValue(assem, out TypeNames typeNames)) {
typeNames = new TypeNames(assem, _fullName);
_typeNames[assem] = typeNames;
}
_typeNames[assem].AddTypeName(typeName);
typeNames.AddTypeName(typeName);

string normalizedTypeName = ReflectionUtils.GetNormalizedTypeName(typeName);
if (_dict.ContainsKey(normalizedTypeName)) {
Expand Down Expand Up @@ -194,9 +195,9 @@ private NamespaceTracker GetOrMakePackageHierarchy(Assembly assem, string fullNa
}
/// <summary>
/// As a fallback, so if the type does exist in any assembly. This would happen if a new type was added
/// that was not in the hardcoded list of types.
/// that was not in the hardcoded list of types.
/// This code is not accurate because:
/// 1. We dont deal with generic types (TypeCollision).
/// 1. We dont deal with generic types (TypeCollision).
/// 2. Previous calls to GetCustomMemberNames (eg. "from foo import *" in Python) would not have included this type.
/// 3. This does not deal with new namespaces added to the assembly
/// </summary>
Expand All @@ -215,7 +216,7 @@ private MemberTracker CheckForUnlistedType(string nameString) {
continue;
}

// We dont use TypeCollision.UpdateTypeEntity here because we do not handle generic type names
// We dont use TypeCollision.UpdateTypeEntity here because we do not handle generic type names
return TypeTracker.GetTypeTracker(type);
}

Expand Down Expand Up @@ -309,7 +310,7 @@ private IList AddKeys(IList res) {
}
}
}

return res;
}

Expand Down Expand Up @@ -405,10 +406,7 @@ internal void AddTypeName(string typeName) {
if (normalizedName == typeName) {
_simpleTypeNames.Add(typeName);
} else {
List<string> actualNames;
if (_genericTypeNames.ContainsKey(normalizedName)) {
actualNames = _genericTypeNames[normalizedName];
} else {
if (!_genericTypeNames.TryGetValue(normalizedName, out List<string> actualNames)) {
actualNames = new List<string>();
_genericTypeNames[normalizedName] = actualNames;
}
Expand Down
4 changes: 4 additions & 0 deletions Src/Microsoft.Dynamic/ComInterop/ComInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ internal interface IDispatchForReflection {
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid("00020400-0000-0000-C000-000000000046"),
]
#pragma warning disable SYSLIB1096 // Convert to 'GeneratedComInterface'
internal interface IDispatch {
#pragma warning restore SYSLIB1096 // Convert to 'GeneratedComInterface'

[PreserveSig]
int TryGetTypeInfoCount(out uint pctinfo);
Expand Down Expand Up @@ -75,7 +77,9 @@ internal enum IDispatchMethodIndices {
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid("B196B283-BAB4-101A-B69C-00AA00341D07")
]
#pragma warning disable SYSLIB1096 // Convert to 'GeneratedComInterface'
internal interface IProvideClassInfo {
#pragma warning restore SYSLIB1096 // Convert to 'GeneratedComInterface'
void GetClassInfo(out IntPtr info);
}

Expand Down
2 changes: 1 addition & 1 deletion Src/Microsoft.Dynamic/ComInterop/ComParamDesc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ internal ComParamDesc(ref ELEMDESC elemDesc, string name) {
break;
}

TYPEDESC childTypeDesc = (TYPEDESC)Marshal.PtrToStructure(typeDesc.lpValue, typeof(TYPEDESC));
TYPEDESC childTypeDesc = Marshal.PtrToStructure<TYPEDESC>(typeDesc.lpValue);
_vt = (VarEnum)childTypeDesc.vt;
typeDesc = childTypeDesc;
}
Expand Down
Loading

0 comments on commit 52ec598

Please sign in to comment.