Skip to content

Commit

Permalink
Merge in upstream changes, resolving conflicts.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zastai committed Aug 17, 2024
2 parents 6e9fe50 + 8e1ae7b commit e0ecbd9
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)\cecil.snk</AssemblyOriginatorKeyFile>
<DefineConstants Condition=" '$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'netcoreapp3.1' ">$(DefineConstants);NET_CORE</DefineConstants>
<DefineConstants Condition=" '$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'net8.0' ">$(DefineConstants);NET_CORE</DefineConstants>
<RootNamespace></RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net40' ">
Expand Down
6 changes: 3 additions & 3 deletions Mono.Cecil.Tests.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NUnit">
<Version>3.11.0</Version>
<Version>3.14.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk">
<Version>15.9.0</Version>
<Version>17.9.0</Version>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter">
<Version>3.12.0</Version>
<Version>4.5.0</Version>
</PackageReference>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Mono.Cecil/BaseAssemblyResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ static Dictionary<string, string> CreateTrustedPlatformAssemblyMap ()

protected virtual AssemblyDefinition SearchDirectory (AssemblyNameReference name, IEnumerable<string> 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);
Expand Down
23 changes: 19 additions & 4 deletions Mono.Cecil/Import.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 ();
Expand Down Expand Up @@ -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;

Expand Down
8 changes: 5 additions & 3 deletions Mono.Security.Cryptography/CryptoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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))
Expand All @@ -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++) {
Expand Down
4 changes: 2 additions & 2 deletions Test/Mono.Cecil.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current">
<Import Project="..\Mono.Cecil.Tests.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net40</TargetFrameworks>
<TargetFrameworks>net8.0;net40</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<PackageReference Include="Microsoft.CodeAnalysis.CSharp">
<Version>2.10.0</Version>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion rocks/Test/Mono.Cecil.Rocks.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current">
<Import Project="..\..\Mono.Cecil.Tests.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net40</TargetFrameworks>
<TargetFrameworks>net8.0;net40</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Mono.Cecil.csproj">
Expand Down
2 changes: 1 addition & 1 deletion symbols/mdb/Test/Mono.Cecil.Mdb.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current">
<Import Project="..\..\..\Mono.Cecil.Tests.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net40</TargetFrameworks>
<TargetFrameworks>net8.0;net40</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Mono.Cecil.csproj">
Expand Down
2 changes: 1 addition & 1 deletion symbols/pdb/Test/Mono.Cecil.Pdb.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current">
<Import Project="..\..\..\Mono.Cecil.Tests.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net40</TargetFrameworks>
<TargetFrameworks>net8.0;net40</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Mono.Cecil.csproj">
Expand Down

0 comments on commit e0ecbd9

Please sign in to comment.