diff --git a/Core.UnitTests/CodeGeneration/ReflectionEmit/ModuleBuilderFactoryTest.cs b/Core.UnitTests/CodeGeneration/ReflectionEmit/ModuleBuilderFactoryTest.cs index 856702ad..2616e553 100644 --- a/Core.UnitTests/CodeGeneration/ReflectionEmit/ModuleBuilderFactoryTest.cs +++ b/Core.UnitTests/CodeGeneration/ReflectionEmit/ModuleBuilderFactoryTest.cs @@ -47,13 +47,22 @@ public void SetUp () _currentDirectory = Environment.CurrentDirectory; } + + [TearDown] + public void TearDown () + { + var assemblyPath = Path.Combine (_currentDirectory, c_assemblyFileName); + if (File.Exists (assemblyPath)) + File.Delete (assemblyPath); + } + [Test] public void CreateModuleBuilder () { var result = _factory.CreateModuleBuilder (c_assemblyName, assemblyDirectoryOrNull: null, strongNamed: false, keyFilePathOrNull: null); CheckAdapterBehavior (result); -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK || NET9_0_OR_GREATER CheckSaveToDiskBehavior (result, _currentDirectory); #endif } @@ -62,7 +71,7 @@ public void CreateModuleBuilder () public void CreateModuleBuilder_AppliesTypePipeAssemblyAttribute () { var assemblyName = c_assemblyName + Guid.NewGuid(); - _factory.CreateModuleBuilder (assemblyName, assemblyDirectoryOrNull: null, strongNamed: false, keyFilePathOrNull: null); + var moduleBuilder = _factory.CreateModuleBuilder (assemblyName, assemblyDirectoryOrNull: null, strongNamed: false, keyFilePathOrNull: null); var assembly = AppDomain.CurrentDomain.GetAssemblies().SingleOrDefault(a => a.GetName().Name == assemblyName); Assert.That (assembly, Is.Not.Null); @@ -79,26 +88,18 @@ public void CreateModuleBuilder_CustomDirectory () var result = _factory.CreateModuleBuilder (c_assemblyName, tempDirectory, false, null); CheckAdapterBehavior (result); -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK || NET9_0_OR_GREATER CheckSaveToDiskBehavior (result, tempDirectory); #endif } [Test] +#if !FEATURE_STRONGNAMESIGNING + [Ignore("Platform does not support strong named assembly signing.")] +#endif public void CreateModuleBuilder_StrongNamed_FallbackKey () { - try - { - Dev.Null = FallbackKey.KeyPair.PublicKey; - } - catch (PlatformNotSupportedException) - { -#if FEATURE_ASSEMBLYBUILDER_SAVE - throw; -#else - Assert.Ignore (".NET does not support assembly persistence."); -#endif - } + Dev.Null = FallbackKey.KeyPair.PublicKey; var result1 = _factory.CreateModuleBuilder (c_assemblyName, assemblyDirectoryOrNull: null, strongNamed: true, keyFilePathOrNull: null); var result2 = _factory.CreateModuleBuilder (c_assemblyName, assemblyDirectoryOrNull: null, strongNamed: true, keyFilePathOrNull: string.Empty); @@ -113,20 +114,12 @@ public void CreateModuleBuilder_StrongNamed_FallbackKey () } [Test] +#if !FEATURE_STRONGNAMESIGNING + [Ignore("Platform does not support strong named assembly signing.")] +#endif public void CreateModuleBuilder_StrongNamed_ProvidedKey () { - try - { - Dev.Null = FallbackKey.KeyPair.PublicKey; - } - catch (PlatformNotSupportedException) - { -#if FEATURE_ASSEMBLYBUILDER_SAVE - throw; -#else - Assert.Ignore (".NET does not support assembly persistence."); -#endif - } + Dev.Null = FallbackKey.KeyPair.PublicKey; var otherKeyPath = Path.Combine (AppDomain.CurrentDomain.BaseDirectory, @"CodeGeneration\ReflectionEmit\OtherKey.snk"); var result = _factory.CreateModuleBuilder ( @@ -142,7 +135,7 @@ private void CheckAdapterBehavior (IModuleBuilder moduleBuilder, byte[] expected { Assert.That (moduleBuilder, Is.TypeOf()); var moduleBuilderAdapter = (ModuleBuilderAdapter) moduleBuilder; -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK || NET9_0_OR_GREATER Assert.That (moduleBuilderAdapter.ScopeName, Is.EqualTo (c_assemblyFileName)); #else // .NET5 as a hardcoded module name since it does not support AssemblyBuilder.Save(). @@ -152,20 +145,26 @@ private void CheckAdapterBehavior (IModuleBuilder moduleBuilder, byte[] expected var assemblyBuilderAdapter = (AssemblyBuilderAdapter) moduleBuilder.AssemblyBuilder; Assert.That (assemblyBuilderAdapter.AssemblyName, Is.EqualTo (c_assemblyName)); +#if NET9_0_OR_GREATER + Assert.That (assemblyBuilderAdapter.PublicKey, Is.EqualTo (expectedPublicKey)); +#else Assert.That (assemblyBuilderAdapter.PublicKey, Is.EqualTo (expectedPublicKey ?? new byte[0])); +#endif } private void CheckSaveToDiskBehavior (IModuleBuilder moduleBuilder, string assemblyDirectory) { var assemblyPath = Path.Combine (assemblyDirectory, c_assemblyFileName); var pdbPath = Path.Combine (assemblyDirectory, c_pdbFileName); - Assert.That (File.Exists (assemblyPath), Is.False); - Assert.That (File.Exists (pdbPath), Is.False); + Assert.That (File.Exists (assemblyPath), Is.False, assemblyPath); + Assert.That (File.Exists (pdbPath), Is.False, pdbPath); var result = moduleBuilder.AssemblyBuilder.SaveToDisk(); - Assert.That (File.Exists (assemblyPath), Is.True); - Assert.That (File.Exists (pdbPath), Is.True); + Assert.That (File.Exists (assemblyPath), Is.True, assemblyPath); +#if FEATURE_PDBEMIT + Assert.That (File.Exists (pdbPath), Is.True, pdbPath); +#endif Assert.That (result, Is.EqualTo (assemblyPath)); FileUtility.DeleteAndWaitForCompletion (Path.Combine (assemblyDirectory, c_assemblyFileName)); diff --git a/Core/CodeGeneration/ReflectionEmit/Abstractions/AssemblyBuilderAdapter.cs b/Core/CodeGeneration/ReflectionEmit/Abstractions/AssemblyBuilderAdapter.cs index 0c2f5e2a..df5b270e 100644 --- a/Core/CodeGeneration/ReflectionEmit/Abstractions/AssemblyBuilderAdapter.cs +++ b/Core/CodeGeneration/ReflectionEmit/Abstractions/AssemblyBuilderAdapter.cs @@ -15,26 +15,48 @@ // under the License. // using System; +using System.IO; using System.Reflection.Emit; using Remotion.Utilities; namespace Remotion.TypePipe.CodeGeneration.ReflectionEmit.Abstractions { +#if NET9_0_OR_GREATER + /// + /// Adapts with the interface. + /// +#else /// /// Adapts with the interface. /// +#endif public class AssemblyBuilderAdapter : BuilderAdapterBase, IAssemblyBuilder { +#if NET9_0_OR_GREATER + private readonly PersistedAssemblyBuilder _assemblyBuilder; + private readonly string _assemblyDirectory; +#else private readonly AssemblyBuilder _assemblyBuilder; +#endif private readonly ModuleBuilder _moduleBuilder; +#if NET9_0_OR_GREATER + public AssemblyBuilderAdapter (PersistedAssemblyBuilder assemblyBuilder, ModuleBuilder moduleBuilder, string assemblyDirectory) +#else public AssemblyBuilderAdapter (AssemblyBuilder assemblyBuilder, ModuleBuilder moduleBuilder) +#endif : base (ArgumentUtility.CheckNotNull ("assemblyBuilder", assemblyBuilder).SetCustomAttribute) { ArgumentUtility.CheckNotNull ("moduleBuilder", moduleBuilder); +#if NET9_0_OR_GREATER + ArgumentUtility.CheckNotNullOrEmpty ("assemblyDirectory", assemblyDirectory); +#endif _assemblyBuilder = assemblyBuilder; _moduleBuilder = moduleBuilder; +#if NET9_0_OR_GREATER + _assemblyDirectory = assemblyDirectory; +#endif } public string AssemblyName @@ -47,14 +69,30 @@ public byte[] PublicKey get { return _assemblyBuilder.GetName ().GetPublicKey (); } } +#if NET9_0_OR_GREATER + public string AssemblyDirectory + { + get { return _assemblyDirectory; } + } +#endif + public string SaveToDisk () { -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK // Scope name is the module name or file name, i.e., assembly name + '.dll'. _assemblyBuilder.Save (_moduleBuilder.ScopeName); // This is the absolute path to the module, which is also the assembly file path for single-module assemblies. return _moduleBuilder.FullyQualifiedName; +#elif NET9_0_OR_GREATER + // Scope name is the module name or file name, i.e., assembly name + '.dll'. + var modulePath = Path.Combine (_assemblyDirectory, _moduleBuilder.ScopeName); + using (var stream = new FileStream (modulePath, FileMode.Create, FileAccess.Write, FileShare.Read)) + { + _assemblyBuilder.Save (stream); + } + + return modulePath; #else throw new PlatformNotSupportedException ("Assembly persistence is not supported."); #endif diff --git a/Core/CodeGeneration/ReflectionEmit/Abstractions/ModuleBuilderAdapter.cs b/Core/CodeGeneration/ReflectionEmit/Abstractions/ModuleBuilderAdapter.cs index fd213298..cd3e539a 100644 --- a/Core/CodeGeneration/ReflectionEmit/Abstractions/ModuleBuilderAdapter.cs +++ b/Core/CodeGeneration/ReflectionEmit/Abstractions/ModuleBuilderAdapter.cs @@ -39,13 +39,26 @@ public IAssemblyBuilder AssemblyBuilder get { return _assemblyBuilder; } } +#if NET9_0_OR_GREATER + public ModuleBuilderAdapter (ModuleBuilder moduleBuilder, string assemblyDirectory) +#else public ModuleBuilderAdapter (ModuleBuilder moduleBuilder) +#endif : base (ArgumentUtility.CheckNotNull ("moduleBuilder", moduleBuilder).SetCustomAttribute) { +#if NET9_0_OR_GREATER + ArgumentUtility.CheckNotNullOrEmpty ("assemblyDirectory", assemblyDirectory); + Assertion.IsTrue (moduleBuilder.Assembly is PersistedAssemblyBuilder); +#else Assertion.IsTrue (moduleBuilder.Assembly is AssemblyBuilder); +#endif _moduleBuilder = moduleBuilder; - _assemblyBuilder = new AssemblyBuilderAdapter (((AssemblyBuilder) moduleBuilder.Assembly), moduleBuilder); +#if NET9_0_OR_GREATER + _assemblyBuilder = new AssemblyBuilderAdapter ((PersistedAssemblyBuilder) moduleBuilder.Assembly, moduleBuilder, assemblyDirectory); +#else + _assemblyBuilder = new AssemblyBuilderAdapter ((AssemblyBuilder) moduleBuilder.Assembly, moduleBuilder); +#endif } [CLSCompliant (false)] diff --git a/Core/CodeGeneration/ReflectionEmit/ModuleBuilderFactory.cs b/Core/CodeGeneration/ReflectionEmit/ModuleBuilderFactory.cs index 9dbf101a..7c6bf745 100644 --- a/Core/CodeGeneration/ReflectionEmit/ModuleBuilderFactory.cs +++ b/Core/CodeGeneration/ReflectionEmit/ModuleBuilderFactory.cs @@ -27,7 +27,7 @@ namespace Remotion.TypePipe.CodeGeneration.ReflectionEmit { -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK /// /// This class creates instances of . /// @@ -35,6 +35,14 @@ namespace Remotion.TypePipe.CodeGeneration.ReflectionEmit /// . /// /// +#elif NET9_0_OR_GREATER + /// + /// This class creates instances of . + /// + /// The module will be created with and the emitSymbolInfo flag set to + /// . + /// + /// #else /// /// This class creates instances of . @@ -70,8 +78,10 @@ public IModuleBuilder CreateModuleBuilder (string assemblyName, string assemblyD #endif } -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly (assemName, AssemblyBuilderAccess.RunAndSave, assemblyDirectoryOrNull); +#elif NET9_0_OR_GREATER + var assemblyBuilder = new PersistedAssemblyBuilder (new AssemblyName(assemblyName), typeof(object).Assembly); #else var assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly (assemName, AssemblyBuilderAccess.Run); #endif @@ -84,8 +94,12 @@ public IModuleBuilder CreateModuleBuilder (string assemblyName, string assemblyD var moduleBuilder = assemblyBuilder.DefineDynamicModule (moduleName); #endif +#if NET9_0_OR_GREATER + var assmeblyDirectory = assemblyDirectoryOrNull ?? Environment.CurrentDirectory; + var moduleBuilderAdapter = new ModuleBuilderAdapter (moduleBuilder, assmeblyDirectory); +#else var moduleBuilderAdapter = new ModuleBuilderAdapter (moduleBuilder); - +#endif var typePipeAttribute = new CustomAttributeDeclaration (s_typePipeAssemblyAttributeCtor, new object[] { _participantConfigurationID }); moduleBuilderAdapter.AssemblyBuilder.SetCustomAttribute (typePipeAttribute); diff --git a/Core/Dlr/Compiler/AssemblyGen.cs b/Core/Dlr/Compiler/AssemblyGen.cs index 1317ba3b..0da7d567 100644 --- a/Core/Dlr/Compiler/AssemblyGen.cs +++ b/Core/Dlr/Compiler/AssemblyGen.cs @@ -60,13 +60,13 @@ private AssemblyGen() { _myAssembly = AssemblyBuilder.DefineDynamicAssembly (name, AssemblyBuilderAccess.Run, attributes); -#if FEATURE_PDBEMIT +#if NETFRAMEWORK _myModule = _myAssembly.DefineDynamicModule (name.Name, false); #else _myModule = _myAssembly.DefineDynamicModule (name.Name); #endif -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK _myAssembly.DefineVersionInfoResource(); #endif diff --git a/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifier.cs b/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifier.cs index 593fcabc..e5c1eafb 100644 --- a/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifier.cs +++ b/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifier.cs @@ -14,7 +14,7 @@ // License for the specific language governing permissions and limitations // under the License. // -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK using System; using System.Diagnostics; using System.Reflection; diff --git a/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/DotNetSdk20PEVerifyPathSource.cs b/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/DotNetSdk20PEVerifyPathSource.cs index 92ed192a..ec3c945b 100644 --- a/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/DotNetSdk20PEVerifyPathSource.cs +++ b/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/DotNetSdk20PEVerifyPathSource.cs @@ -14,7 +14,7 @@ // License for the specific language governing permissions and limitations // under the License. // -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK using System; using System.IO; using Microsoft.Win32; diff --git a/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk6PEVerifyPathSource.cs b/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk6PEVerifyPathSource.cs index ce48356d..1b449288 100644 --- a/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk6PEVerifyPathSource.cs +++ b/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk6PEVerifyPathSource.cs @@ -14,7 +14,7 @@ // License for the specific language governing permissions and limitations // under the License. // -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK using System; using System.IO; using Microsoft.Win32; diff --git a/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk70aPEVerifyPathSource.cs b/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk70aPEVerifyPathSource.cs index 7d37b245..73629de8 100644 --- a/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk70aPEVerifyPathSource.cs +++ b/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk70aPEVerifyPathSource.cs @@ -14,7 +14,7 @@ // License for the specific language governing permissions and limitations // under the License. // -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK using System; using System.IO; using Microsoft.Win32; diff --git a/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk71PEVerifyPathSource.cs b/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk71PEVerifyPathSource.cs index 99deeb63..3e06fb8c 100644 --- a/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk71PEVerifyPathSource.cs +++ b/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk71PEVerifyPathSource.cs @@ -14,7 +14,7 @@ // License for the specific language governing permissions and limitations // under the License. // -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK using System; using System.IO; using Microsoft.Win32; diff --git a/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk80aPEVerifyPathSource.cs b/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk80aPEVerifyPathSource.cs index a412cbd2..69f1358e 100644 --- a/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk80aPEVerifyPathSource.cs +++ b/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk80aPEVerifyPathSource.cs @@ -14,7 +14,7 @@ // License for the specific language governing permissions and limitations // under the License. // -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK using System; using System.IO; using Microsoft.Win32; diff --git a/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk81aPEVerifyPathSource.cs b/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk81aPEVerifyPathSource.cs index ce598428..dd5e778d 100644 --- a/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk81aPEVerifyPathSource.cs +++ b/Development/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk81aPEVerifyPathSource.cs @@ -14,7 +14,7 @@ // License for the specific language governing permissions and limitations // under the License. // -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK using System; using System.IO; using Microsoft.Win32; diff --git a/Development/AssemblyTrackingCodeManager.cs b/Development/AssemblyTrackingCodeManager.cs index 6995ed4b..c7d85ac6 100644 --- a/Development/AssemblyTrackingCodeManager.cs +++ b/Development/AssemblyTrackingCodeManager.cs @@ -14,10 +14,11 @@ // License for the specific language governing permissions and limitations // under the License. // -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK || NET9_0_OR_GREATER using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Reflection; using Remotion.Development.UnitTesting; @@ -67,6 +68,7 @@ public void AddSavedAssembly (string assemblyPath) } } +#if NETFRAMEWORK public void PeVerifySavedAssemblies () { lock (_lockObject) @@ -75,6 +77,18 @@ public void PeVerifySavedAssemblies () PEVerifier.CreateDefault().VerifyPEFile (assemblyPath); } } +#elif NET9_0_OR_GREATER + public void ProcessSavedAssemblies (Action processor) + { + ArgumentUtility.CheckNotNull ("processor", processor); + + lock (_lockObject) + { + foreach (var assemblyPath in _savedAssemblies) + processor (assemblyPath); + } + } +#endif public void DeleteSavedAssemblies () { diff --git a/Development/AssemblyTrackingPipelineFactory.cs b/Development/AssemblyTrackingPipelineFactory.cs index 4527c83a..279e2dd6 100644 --- a/Development/AssemblyTrackingPipelineFactory.cs +++ b/Development/AssemblyTrackingPipelineFactory.cs @@ -14,7 +14,7 @@ // License for the specific language governing permissions and limitations // under the License. // -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK || NET9_0_OR_GREATER using System; using Remotion.TypePipe.Caching; using Remotion.TypePipe.CodeGeneration; diff --git a/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifier.cs b/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifier.cs index 593fcabc..e5c1eafb 100644 --- a/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifier.cs +++ b/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifier.cs @@ -14,7 +14,7 @@ // License for the specific language governing permissions and limitations // under the License. // -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK using System; using System.Diagnostics; using System.Reflection; diff --git a/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/DotNetSdk20PEVerifyPathSource.cs b/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/DotNetSdk20PEVerifyPathSource.cs index 92ed192a..ec3c945b 100644 --- a/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/DotNetSdk20PEVerifyPathSource.cs +++ b/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/DotNetSdk20PEVerifyPathSource.cs @@ -14,7 +14,7 @@ // License for the specific language governing permissions and limitations // under the License. // -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK using System; using System.IO; using Microsoft.Win32; diff --git a/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk6PEVerifyPathSource.cs b/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk6PEVerifyPathSource.cs index ce48356d..1b449288 100644 --- a/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk6PEVerifyPathSource.cs +++ b/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk6PEVerifyPathSource.cs @@ -14,7 +14,7 @@ // License for the specific language governing permissions and limitations // under the License. // -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK using System; using System.IO; using Microsoft.Win32; diff --git a/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk70aPEVerifyPathSource.cs b/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk70aPEVerifyPathSource.cs index 7d37b245..73629de8 100644 --- a/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk70aPEVerifyPathSource.cs +++ b/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk70aPEVerifyPathSource.cs @@ -14,7 +14,7 @@ // License for the specific language governing permissions and limitations // under the License. // -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK using System; using System.IO; using Microsoft.Win32; diff --git a/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk71PEVerifyPathSource.cs b/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk71PEVerifyPathSource.cs index 99deeb63..3e06fb8c 100644 --- a/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk71PEVerifyPathSource.cs +++ b/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk71PEVerifyPathSource.cs @@ -14,7 +14,7 @@ // License for the specific language governing permissions and limitations // under the License. // -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK using System; using System.IO; using Microsoft.Win32; diff --git a/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk80aPEVerifyPathSource.cs b/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk80aPEVerifyPathSource.cs index a412cbd2..69f1358e 100644 --- a/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk80aPEVerifyPathSource.cs +++ b/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk80aPEVerifyPathSource.cs @@ -14,7 +14,7 @@ // License for the specific language governing permissions and limitations // under the License. // -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK using System; using System.IO; using Microsoft.Win32; diff --git a/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk81aPEVerifyPathSource.cs b/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk81aPEVerifyPathSource.cs index ce598428..dd5e778d 100644 --- a/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk81aPEVerifyPathSource.cs +++ b/IntegrationTests/App_Packages/Remotion.Development.PEVerifier.Sources.1.17.10.0/PEVerifyPathSources/WindowsSdk81aPEVerifyPathSource.cs @@ -14,7 +14,7 @@ // License for the specific language governing permissions and limitations // under the License. // -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK using System; using System.IO; using Microsoft.Win32; diff --git a/IntegrationTests/IntegrationTestBase.cs b/IntegrationTests/IntegrationTestBase.cs index 9cb331de..b938ff5f 100644 --- a/IntegrationTests/IntegrationTestBase.cs +++ b/IntegrationTests/IntegrationTestBase.cs @@ -93,9 +93,7 @@ public virtual void SetUp () [TearDown] public virtual void TearDown () { -#if !FEATURE_ASSEMBLYBUILDER_SAVE SkipSavingAndPeVerification(); -#endif if (_skipSavingAndVerification) return; @@ -196,7 +194,7 @@ protected string[] Flush (CustomAttributeDeclaration[] assemblyAttributes = null private static void PeVerifyAssembly (string assemblyPath) { -#if FEATURE_ASSEMBLYBUILDER_SAVE +#if NETFRAMEWORK try { PEVerifier.CreateDefault().VerifyPEFile (assemblyPath); @@ -206,6 +204,17 @@ private static void PeVerifyAssembly (string assemblyPath) Console.WriteLine (exception); throw; } +#elif NET9_0_OR_GREATER + try + { + // RM-9285 + // new ILVerify.Verifier() + } + catch (Exception exception) + { + Console.WriteLine (exception); + throw; + } #else throw new PlatformNotSupportedException ("AssemblyBuilder.Save() is not supported in .NET 5.0"); #endif diff --git a/IntegrationTests/Pipeline/ConcurrencyTest_WithMultipleGenerationThreads.cs b/IntegrationTests/Pipeline/ConcurrencyTest_WithMultipleGenerationThreads.cs index 0b53307a..5f169b37 100644 --- a/IntegrationTests/Pipeline/ConcurrencyTest_WithMultipleGenerationThreads.cs +++ b/IntegrationTests/Pipeline/ConcurrencyTest_WithMultipleGenerationThreads.cs @@ -126,7 +126,7 @@ public void CodeGenerationIsParallelInSeparateAssemblies_WithDegreeOfParallelism } [Test] -#if !FEATURE_ASSEMBLYBUILDER_SAVE +#if NET8_0 [Ignore ("CodeManager.FlushCodeToDisk() is not supported.")] #endif public void LoadFlushedCodeInParallel_GetTypeIDForAssembledTypeBlocks () @@ -159,7 +159,7 @@ public void LoadFlushedCodeInParallel_GetTypeIDForAssembledTypeBlocks () } [Test] -#if !FEATURE_ASSEMBLYBUILDER_SAVE +#if NET8_0 [Ignore ("CodeManager.FlushCodeToDisk() is not supported.")] #endif public void CodeManagerAPIs_FlushIsBlockedUntilAllCodeGenerationIsComplete () diff --git a/IntegrationTests/Pipeline/ConcurrencyTest_WithSingleGenerationThread.cs b/IntegrationTests/Pipeline/ConcurrencyTest_WithSingleGenerationThread.cs index 2f1e5bdd..e0b75f29 100644 --- a/IntegrationTests/Pipeline/ConcurrencyTest_WithSingleGenerationThread.cs +++ b/IntegrationTests/Pipeline/ConcurrencyTest_WithSingleGenerationThread.cs @@ -92,7 +92,7 @@ public void CodeGenerationIsSerialized () } [Test] -#if !FEATURE_ASSEMBLYBUILDER_SAVE +#if NET8_0 [Ignore ("CodeManager.FlushCodeToDisk() is not supported.")] #endif public void CodeManagerAPIs_CannotRunWhileCodeIsGenerated () diff --git a/IntegrationTests/Pipeline/FlushGeneratedCodeTest.cs b/IntegrationTests/Pipeline/FlushGeneratedCodeTest.cs index cfab064d..60376fbb 100644 --- a/IntegrationTests/Pipeline/FlushGeneratedCodeTest.cs +++ b/IntegrationTests/Pipeline/FlushGeneratedCodeTest.cs @@ -28,7 +28,7 @@ namespace Remotion.TypePipe.IntegrationTests.Pipeline { [TestFixture] -#if !FEATURE_ASSEMBLYBUILDER_SAVE +#if NET8_0 [Ignore ("CodeManager.FlushCodeToDisk() is not supported.")] #endif public class FlushGeneratedCodeTest : IntegrationTestBase diff --git a/IntegrationTests/Pipeline/LoadFlushedCodeTest.cs b/IntegrationTests/Pipeline/LoadFlushedCodeTest.cs index 54a96f00..506ed325 100644 --- a/IntegrationTests/Pipeline/LoadFlushedCodeTest.cs +++ b/IntegrationTests/Pipeline/LoadFlushedCodeTest.cs @@ -27,7 +27,7 @@ namespace Remotion.TypePipe.IntegrationTests.Pipeline { [TestFixture] -#if !FEATURE_ASSEMBLYBUILDER_SAVE +#if NET8_0 [Ignore ("CodeManager.FlushCodeToDisk() is not supported.")] #endif public class LoadFlushedCodeTest : IntegrationTestBase diff --git a/IntegrationTests/Pipeline/ParticipantStateTest.cs b/IntegrationTests/Pipeline/ParticipantStateTest.cs index 452dd541..914d34b4 100644 --- a/IntegrationTests/Pipeline/ParticipantStateTest.cs +++ b/IntegrationTests/Pipeline/ParticipantStateTest.cs @@ -23,7 +23,7 @@ namespace Remotion.TypePipe.IntegrationTests.Pipeline { [TestFixture] -#if !FEATURE_ASSEMBLYBUILDER_SAVE +#if NET8_0 [Ignore ("CodeManager.FlushCodeToDisk() is not supported.")] #endif public class ParticipantStateTest : IntegrationTestBase diff --git a/Shared.build.props b/Shared.build.props index 2a3d53a9..7839aa56 100644 --- a/Shared.build.props +++ b/Shared.build.props @@ -35,7 +35,7 @@ True net8.0;net9.0;net462 $(DefineConstants);TypePipe - $(DefineConstants);FEATURE_ASSEMBLYBUILDER_SAVE;FEATURE_REMOTING;FEATURE_PDBEMIT;FEATURE_STRONGNAMESIGNING + $(DefineConstants);FEATURE_REMOTING;FEATURE_PDBEMIT;FEATURE_STRONGNAMESIGNING @@ -53,7 +53,7 @@ False net8.0;net9.0;net462 $(DefineConstants) - $(DefineConstants);FEATURE_ASSEMBLYBUILDER_SAVE;FEATURE_STRONGNAMESIGNING + $(DefineConstants);FEATURE_PDBEMIT;FEATURE_STRONGNAMESIGNING