Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make test run on Net8 #458

Merged
7 changes: 7 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ steps:
packageType: 'sdk'
version: '7.0.x'

# install dotnet 8 sdk so we can run tests against them
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '8.0.x'
includePreviewVersions: true

- task: NuGetToolInstaller@1
inputs:
versionSpec: 6.7.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net6.0;netstandard2.0;</TargetFrameworks>
<TargetFrameworks>net472;net6.0;netstandard2.0;net8.0;</TargetFrameworks>
Daniel-Svensson marked this conversation as resolved.
Show resolved Hide resolved
<PackageTags>WCF;RIA;Services;RIAServices;Silverlight;OpenRiaServices</PackageTags>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<NoWarn>108</NoWarn>
<TargetFrameworks>net472;net6.0-windows</TargetFrameworks>
<TargetFrameworks>net472;net6.0-windows;net8.0-windows</TargetFrameworks>
<Version>1.0.0.0</Version>
<UseWPF>true</UseWPF>
<DefineConstants>$(DefineConstants);HAS_COLLECTIONVIEW</DefineConstants>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<RootNamespace>OpenRiaServices.Hosting.AspNetCore</RootNamespace>
<Version>1.0.0.0</Version>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<NoWarn>618</NoWarn>
<DefineConstants>$(DefineConstants);SERVERFX</DefineConstants>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;net6.0;net8.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>

<!-- Enable roll forward to newer versions so that we run with latest stable dotnet release
As long as there is no unpatched install of dotnet 6
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;net6.0;net8.0</TargetFrameworks>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/OpenRiaServices.Tools/Framework/AssemblyUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ internal static Assembly LoadAssembly(string assemblyFileName, ILogger logger)
catch (Exception ex)
{
// Some common exceptions log a warning and keep running
if (ex is System.IO.FileNotFoundException ||
ex is System.IO.FileLoadException ||
ex is System.IO.PathTooLongException ||
ex is System.IO.DirectoryNotFoundException ||
if (ex is FileNotFoundException ||
ex is FileLoadException ||
ex is PathTooLongException ||
ex is DirectoryNotFoundException ||
ex is BadImageFormatException ||
ex is System.Security.SecurityException)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,11 @@ private bool GenerateClientProxiesOutOfProcess(string generatedFileName, ClientC
{
// Call the console app from here if Net 6.0 or greater
string path = Path.Combine(Path.GetDirectoryName(typeof(CreateOpenRiaClientFilesTask).Assembly.Location),
#if NET8_0
"../net8.0/OpenRiaServices.Tools.CodeGenTask.exe");
Daniel-Svensson marked this conversation as resolved.
Show resolved Hide resolved
#else
"../net6.0/OpenRiaServices.Tools.CodeGenTask.exe");
#endif

if (!File.Exists(path))
throw new FileNotFoundException(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,10 @@ private IEnumerable<Attribute> FilterTypeAttributes(AttributeCollection typeAttr
}

// Filter out attributes in filteredAttributes as well as DataContractAttribute and KnownTypeAttribute (since they are already handled)
return typeAttributes.Cast<Attribute>().Where(a => a.GetType() != typeof(DataContractAttribute) && a.GetType() != typeof(KnownTypeAttribute) &&
return typeAttributes.Cast<Attribute>().Where(a => a.GetType() != typeof(DataContractAttribute) && a.GetType() != typeof(KnownTypeAttribute) &&
#if NET8_0
a.GetType() != Type.GetType("System.Runtime.CompilerServices.NullableContextAttribute") &&
#endif
!(filteredAttributes.Contains(a)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<DefineConstants>$(DefineConstants);SERVERFX;DBCONTEXT</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)' == 'net472'">$(DefineConstants);HAS_LINQ2SQL</DefineConstants>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;net6.0;net8.0</TargetFrameworks>
<PackageId>OpenRiaServices.Client.CodeGen</PackageId>
<Title>OpenRiaServices Client Code Generator</Title>
<Description>OpenRiaServices CodeGen provides the MsBuild Tasks to generate the client proxy. </Description>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;net6.0;net8.0</TargetFrameworks>
Daniel-Svensson marked this conversation as resolved.
Show resolved Hide resolved
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<DefineConstants>$(DefineConstants);SILVERLIGHT</DefineConstants>
<DebugType>pdbonly</DebugType>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
extern alias TextTemplate;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.IO;
Expand All @@ -12,6 +11,7 @@
using OpenRiaServices.Server.Test.Utilities;
using OpenRiaServices.Tools.Test.T4Generator;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Mono.Cecil;

namespace OpenRiaServices.Tools.Test
{
Expand Down Expand Up @@ -54,7 +54,7 @@ public void ClientCodeGenerationDispatcher_Finds_Custom()
// into the MEF composition container
using (ClientCodeGenerationDispatcher dispatcher = new ClientCodeGenerationDispatcher())
{
string[] compositionAssemblies = new string[] { Assembly.GetExecutingAssembly().Location};
string[] compositionAssemblies = new string[] { Assembly.GetExecutingAssembly().Location };

IDomainServiceClientCodeGenerator generator = dispatcher.FindCodeGenerator(host, options, compositionAssemblies, MockCodeGenerator.GeneratorName);
Assert.IsNotNull(generator, "the dispatcher did not find any code generator");
Expand Down Expand Up @@ -180,11 +180,11 @@ public void ClientCodeGenerationDispatcher_Error_Missing_Custom()
IDomainServiceClientCodeGenerator generator = dispatcher.FindCodeGenerator(host, options, compositionAssemblies, "NotAGenerator");
Assert.IsNull(generator, "the dispatcher should not find any code generator");

string error = string.Format(CultureInfo.CurrentCulture,
Resource.Code_Generator_Not_Found,
"NotAGenerator",
options.Language,
options.ServerProjectPath,
string error = string.Format(CultureInfo.CurrentCulture,
Resource.Code_Generator_Not_Found,
"NotAGenerator",
options.Language,
options.ServerProjectPath,
options.ClientProjectPath,
CodeDomClientCodeGenerator.GeneratorName);
TestHelper.AssertContainsErrors(logger, error);
Expand Down Expand Up @@ -479,11 +479,11 @@ public void ClientCodeGenerationDispatcher_Error_Multiple_Generators()
string errorParam = " " + MockCodeGenerator.GeneratorName + Environment.NewLine +
" " + T4DomainServiceClientCodeGenerator.GeneratorName + Environment.NewLine;

string error = (string.Format(CultureInfo.CurrentCulture,
Resource.Multiple_Custom_Code_Generators_Using_Default,
options.Language,
errorParam,
options.ClientProjectPath,
string error = (string.Format(CultureInfo.CurrentCulture,
Resource.Multiple_Custom_Code_Generators_Using_Default,
options.Language,
errorParam,
options.ClientProjectPath,
MockCodeGenerator.GeneratorName,
CodeDomClientCodeGenerator.GeneratorName));
TestHelper.AssertContainsWarnings(logger, error);
Expand Down Expand Up @@ -518,12 +518,12 @@ public void ClientCodeGenerationDispatcher_Error_Multiple_Generators_Same_Name()
string errorParam = " " + typeof(MockFSharpCodeGenerator1).FullName + Environment.NewLine +
" " + typeof(MockFSharpCodeGenerator2).FullName + Environment.NewLine;

string error = string.Format(CultureInfo.CurrentCulture,
Resource.Multiple_Named_Code_Generators,
string error = string.Format(CultureInfo.CurrentCulture,
Resource.Multiple_Named_Code_Generators,
generatorName,
options.Language,
options.Language,
errorParam,
options.ServerProjectPath,
options.ServerProjectPath,
options.ClientProjectPath,
typeof(MockFSharpCodeGenerator1).AssemblyQualifiedName);
TestHelper.AssertContainsErrors(logger, error);
Expand Down Expand Up @@ -555,6 +555,15 @@ public void ClientCodeGenerationDispatcher_Error_TypeLoadException()

Assert.IsTrue(File.Exists(typeLoadExceptionProjectLocation), "Expected TypeLoadExceptionProject.dll to coreside with this assembly in test folder");

using (var assemblyDefinition = AssemblyDefinition.ReadAssembly(typeLoadExceptionProjectLocation, new ReaderParameters { ReadWrite = true }))
SandstromErik marked this conversation as resolved.
Show resolved Hide resolved
{
var module = assemblyDefinition.MainModule;
var class1 = module.Types.Single(t => t.Name == "Class1");
var class2 = module.Types.Single(t => t.Name == "Class2");
class2.BaseType = class1.BaseType;
assemblyDefinition.Write();
Daniel-Svensson marked this conversation as resolved.
Show resolved Hide resolved
}

// Do what MEF does to load the types so we can capture the exception
Exception expectedException = null;
try
Expand Down Expand Up @@ -657,7 +666,7 @@ public string GenerateCode(ICodeGenerationHost host, IEnumerable<DomainServiceDe
return MockCodeGenerator.FakeGeneratedCode;
}
}

// Commented out so MEF does not discover this generator.
// It is used exclusively for testing fully qualified assembly name loading of generators.
// [DomainServiceClientCodeGenerator("ThrowingCtorCodeGenerator", "C#")]
Expand Down
6 changes: 5 additions & 1 deletion src/OpenRiaServices.Tools/Test/MsBuildHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ internal static ProjectWrapper LoadProject(string projectPath)
#if NETFRAMEWORK
string framework = frameworks.First(f => f.StartsWith("net4", StringComparison.Ordinal));
#else
string framework = frameworks.First(f => !f.StartsWith("net4", StringComparison.Ordinal));
#if NET6_0
string framework = frameworks.First(f => f.StartsWith("net6", StringComparison.Ordinal));
#else
string framework = frameworks.First(f => f.StartsWith("net8", StringComparison.Ordinal));
#endif
#endif
project.SetGlobalProperty("TargetFramework", framework);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<NoWarn>618</NoWarn>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;net6.0;net8.0</TargetFrameworks>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
<DefineConstants Condition="'$(TargetFramework)' == 'net472'">$(DefineConstants);HAS_LINQ2SQL</DefineConstants>
Expand All @@ -28,6 +28,7 @@
<PackageReference Include="Microsoft.Build.Framework" Version="17.0.0" PrivateAssets="All" ExcludeAssets="Runtime" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="17.0.0" PrivateAssets="All" ExcludeAssets="Runtime" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="17.0.0" PrivateAssets="All" ExcludeAssets="Runtime" />
<PackageReference Include="Mono.Cecil" Version="0.11.5" />
<PackageReference Include="System.Reflection.MetadataLoadContext" Version="7.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;net6.0;net8.0</TargetFrameworks>
SandstromErik marked this conversation as resolved.
Show resolved Hide resolved
<!-- We compile with Release settings to test PDB reader,
though we pretend it is the Debug build just to simplify
a debug build of the solution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<DebugType>pdbonly</DebugType>

<NoWarn Condition="'$(TargetFramework)'=='net6.0'">$(NoWarn);CS0618</NoWarn>
<NoWarn Condition="'$(TargetFramework)'!='net472'">$(NoWarn);CS0618</NoWarn>
<DefineConstants Condition="'$(TargetFramework)'=='net472'">$(DefineConstants);WCF;HAS_LINQ2SQL</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)'!='net472'">$(DefineConstants);ASPNET_CORE</DefineConstants>
</PropertyGroup>
Expand Down
4 changes: 3 additions & 1 deletion src/Test/Desktop/TypeLoadExceptionProject/Class1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ namespace TypeLoadExceptionProject
// a load exception when it is loaded. It is used where
// we want to test recovery from this situation
#pragma warning disable 0824
public class Class1
public class Class1 : Class2
{
extern static Class1();
public static void Main() { return; }
}

public class Class2 { }
#pragma warning restore 0824
}
5 changes: 3 additions & 2 deletions src/global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"sdk": {
"version": "7.0.200",
"rollForward": "major"
"version": "8.0.0-rc.2",
"rollForward": "major",
"allowPrerelease": true
}
}
Loading