diff --git a/Directory.Build.props b/Directory.Build.props
index 85dfd1d04..5b9f0da9d 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -7,7 +7,7 @@
true
true
$(MSBuildThisFileDirectory)\cecil.snk
- $(DefineConstants);NET_CORE
+ $(DefineConstants);NET_CORE
diff --git a/Mono.Cecil.Tests.props b/Mono.Cecil.Tests.props
index bd6df1f5e..598bd2554 100644
--- a/Mono.Cecil.Tests.props
+++ b/Mono.Cecil.Tests.props
@@ -4,13 +4,13 @@
- 3.11.0
+ 3.14.0
- 15.9.0
+ 17.9.0
- 3.12.0
+ 4.5.0
diff --git a/Mono.Cecil/BaseAssemblyResolver.cs b/Mono.Cecil/BaseAssemblyResolver.cs
index fd9e5c968..146939036 100644
--- a/Mono.Cecil/BaseAssemblyResolver.cs
+++ b/Mono.Cecil/BaseAssemblyResolver.cs
@@ -209,7 +209,7 @@ static Dictionary CreateTrustedPlatformAssemblyMap ()
protected virtual AssemblyDefinition SearchDirectory (AssemblyNameReference name, IEnumerable directories, ReaderParameters parameters)
{
- var extensions = name.IsWindowsRuntime ? new [] { ".winmd", ".dll" } : new [] { ".exe", ".dll" };
+ var extensions = name.IsWindowsRuntime ? new [] { ".winmd", ".dll" } : new [] { ".dll", ".exe" };
foreach (var directory in directories) {
foreach (var extension in extensions) {
string file = Path.Combine (directory, name.Name + extension);
diff --git a/Mono.Cecil/Import.cs b/Mono.Cecil/Import.cs
index 272e96076..e5670b601 100644
--- a/Mono.Cecil/Import.cs
+++ b/Mono.Cecil/Import.cs
@@ -159,6 +159,19 @@ enum ImportGenericKind {
{ typeof (object), ElementType.Object },
};
+ TypeReference ImportType (Type type, ImportGenericContext context, Type [] required_modifiers, Type [] optional_modifiers)
+ {
+ var import = ImportType (type, context);
+
+ foreach (var modifier in required_modifiers)
+ import = new RequiredModifierType (ImportType (modifier, context), import);
+
+ foreach (var modifier in optional_modifiers)
+ import = new OptionalModifierType (ImportType (modifier, context), import);
+
+ return import;
+ }
+
TypeReference ImportType (Type type, ImportGenericContext context)
{
return ImportType (type, context, ImportGenericKind.Open);
@@ -349,7 +362,7 @@ FieldReference ImportField (SR.FieldInfo field, ImportGenericContext context)
return new FieldReference {
Name = field.Name,
DeclaringType = declaring_type,
- FieldType = ImportType (field.FieldType, context),
+ FieldType = ImportType (field.FieldType, context, field.GetRequiredCustomModifiers (), field.GetOptionalCustomModifiers ()),
};
} finally {
context.Pop ();
@@ -393,15 +406,17 @@ MethodReference ImportMethod (SR.MethodBase method, ImportGenericContext context
try {
var method_info = method as SR.MethodInfo;
reference.ReturnType = method_info != null
- ? ImportType (method_info.ReturnType, context)
+ ? ImportType (method_info.ReturnType, context, method_info.ReturnParameter.GetRequiredCustomModifiers (), method_info.ReturnParameter.GetOptionalCustomModifiers ())
: ImportType (typeof (void), default (ImportGenericContext));
var parameters = method.GetParameters ();
var reference_parameters = reference.Parameters;
- for (int i = 0; i < parameters.Length; i++)
+ for (int i = 0; i < parameters.Length; i++) {
+ var parameter = parameters [i];
reference_parameters.Add (
- new ParameterDefinition (ImportType (parameters [i].ParameterType, context)));
+ new ParameterDefinition (ImportType (parameter.ParameterType, context, parameter.GetRequiredCustomModifiers (), parameter.GetOptionalCustomModifiers ())));
+ }
reference.DeclaringType = declaring_type;
diff --git a/Mono.Security.Cryptography/CryptoService.cs b/Mono.Security.Cryptography/CryptoService.cs
index 3877debfa..1da81b1e1 100644
--- a/Mono.Security.Cryptography/CryptoService.cs
+++ b/Mono.Security.Cryptography/CryptoService.cs
@@ -26,6 +26,8 @@ namespace Mono.Cecil {
static class CryptoService {
+ static SHA1 CreateSHA1 () => new SHA1CryptoServiceProvider ();
+
public static byte [] GetPublicKey (WriterParameters parameters)
{
using (var rsa = parameters.CreateRSA ()) {
@@ -93,7 +95,7 @@ static byte [] HashStream (Stream stream, ImageWriter writer, out int strong_nam
+ (strong_name_directory.VirtualAddress - text.VirtualAddress));
var strong_name_length = (int) strong_name_directory.Size;
- var sha1 = new SHA1Managed ();
+ var sha1 = CreateSHA1 ();
var buffer = new byte [buffer_size];
using (var crypto_stream = new CryptoStream (Stream.Null, sha1, CryptoStreamMode.Write)) {
stream.Seek (0, SeekOrigin.Begin);
@@ -131,7 +133,7 @@ public static byte [] ComputeHash (Stream stream)
{
const int buffer_size = 8192;
- var sha1 = new SHA1Managed ();
+ var sha1 = CreateSHA1 ();
var buffer = new byte [buffer_size];
using (var crypto_stream = new CryptoStream (Stream.Null, sha1, CryptoStreamMode.Write))
@@ -142,7 +144,7 @@ public static byte [] ComputeHash (Stream stream)
public static byte [] ComputeHash (params ByteBuffer [] buffers)
{
- var sha1 = new SHA1Managed ();
+ var sha1 = CreateSHA1 ();
using (var crypto_stream = new CryptoStream (Stream.Null, sha1, CryptoStreamMode.Write)) {
for (int i = 0; i < buffers.Length; i++) {
diff --git a/Test/Mono.Cecil.Tests.csproj b/Test/Mono.Cecil.Tests.csproj
index f7762e3f0..ed98595dc 100644
--- a/Test/Mono.Cecil.Tests.csproj
+++ b/Test/Mono.Cecil.Tests.csproj
@@ -1,9 +1,9 @@
- netcoreapp3.1;net40
+ net8.0;net40
-
+
2.10.0
diff --git a/rocks/Test/Mono.Cecil.Rocks.Tests.csproj b/rocks/Test/Mono.Cecil.Rocks.Tests.csproj
index a15fce183..aec50e167 100644
--- a/rocks/Test/Mono.Cecil.Rocks.Tests.csproj
+++ b/rocks/Test/Mono.Cecil.Rocks.Tests.csproj
@@ -1,7 +1,7 @@
- netcoreapp3.1;net40
+ net8.0;net40
diff --git a/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj b/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj
index 92da7f5ca..534096a5d 100644
--- a/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj
+++ b/symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj
@@ -1,7 +1,7 @@
- netcoreapp3.1;net40
+ net8.0;net40
diff --git a/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj b/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj
index 8baa446e8..1d9a45766 100644
--- a/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj
+++ b/symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj
@@ -1,7 +1,7 @@
- netcoreapp3.1;net40
+ net8.0;net40