Skip to content

Commit 350c80b

Browse files
committed
Fix assembly loading
1 parent a7d562b commit 350c80b

File tree

7 files changed

+60
-14
lines changed

7 files changed

+60
-14
lines changed

azure-pipelines-internal-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ extends:
148148
steps:
149149
- template: /eng/common/templates-official/steps/enable-internal-sources.yml
150150
- template: /eng/common/templates-official/steps/enable-internal-runtimes.yml
151-
- script: eng/common/build.sh --restore --build --test --pack --ci --configuration $(_BuildConfig) --prepareMachine $(_InternalRuntimeDownloadArgs)
151+
- script: ./build.sh --ci -c $(_BuildConfig) --test --pack --publish --prepareMachine $(_InternalRuntimeDownloadArgs)
152152
env:
153153
Test__Cosmos__DefaultConnection: $(_CosmosConnectionUrl)
154154
# Work-around for https://github.com/dotnet/runtime/issues/70758
@@ -166,7 +166,7 @@ extends:
166166
steps:
167167
- template: /eng/common/templates-official/steps/enable-internal-sources.yml
168168
- template: /eng/common/templates-official/steps/enable-internal-runtimes.yml
169-
- script: eng/common/build.sh --restore --build --test --pack --ci --configuration $(_BuildConfig) --prepareMachine $(_InternalRuntimeDownloadArgs)
169+
- script: ./build.sh --ci -c $(_BuildConfig) --test --pack --publish --prepareMachine $(_InternalRuntimeDownloadArgs)
170170
env:
171171
Test__Cosmos__DefaultConnection: $(_CosmosConnectionUrl)
172172
displayName: Build
@@ -197,7 +197,7 @@ extends:
197197
condition: and(eq(variables['_CosmosConnectionUrl'], 'true'), or(endsWith(variables['_runCounter'], '1'), endsWith(variables['_runCounter'], '3'), endsWith(variables['_runCounter'], '5'), endsWith(variables['_runCounter'], '7'), endsWith(variables['_runCounter'], '9')))
198198
- template: /eng/common/templates-official/steps/enable-internal-sources.yml
199199
- template: /eng/common/templates-official/steps/enable-internal-runtimes.yml
200-
- script: eng/common/build.sh --restore --build --pack --ci --configuration $(_BuildConfig) --prepareMachine $(_InternalRuntimeDownloadArgs)
200+
- script: ./build.sh --ci -c $(_BuildConfig) --pack --publish --prepareMachine $(_InternalRuntimeDownloadArgs)
201201
displayName: Build
202202
- task: AzureCLI@2
203203
displayName: Run Cosmos tests

azure-pipelines-public.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ stages:
100100
- skipComponentGovernanceDetection: true
101101
- Codeql.SkipTaskAutoInjection: true
102102
steps:
103-
- script: ./build.sh --ci -c $(_BuildConfig) --test --sign --pack --publish --prepareMachine /bl:artifacts/log/$(_BuildConfig)/Build.binlog $(_InternalRuntimeDownloadArgs)
103+
- script: ./build.sh --ci -c $(_BuildConfig) --test --pack --publish --prepareMachine /bl:artifacts/log/$(_BuildConfig)/Build.binlog $(_InternalRuntimeDownloadArgs)
104104
env:
105105
Test__Cosmos__DefaultConnection: $(_CosmosConnectionUrl)
106106
COMPlus_EnableWriteXorExecute: 0 # Work-around for https://github.com/dotnet/runtime/issues/70758
@@ -125,7 +125,7 @@ stages:
125125
- skipComponentGovernanceDetection: true
126126
- Codeql.SkipTaskAutoInjection: true
127127
steps:
128-
- script: ./build.sh --ci -c $(_BuildConfig) --test --sign --pack --publish --prepareMachine /bl:artifacts/log/$(_BuildConfig)/Build.binlog $(_InternalRuntimeDownloadArgs)
128+
- script: ./build.sh --ci -c $(_BuildConfig) --test --pack --publish --prepareMachine /bl:artifacts/log/$(_BuildConfig)/Build.binlog $(_InternalRuntimeDownloadArgs)
129129
env:
130130
Test__Cosmos__DefaultConnection: $(_CosmosConnectionUrl)
131131
Test__Cosmos__AuthToken: $(_CosmosToken)

eng/Tools/ApiChief/Format/DecompilerFactory.cs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System;
5+
using System.IO;
6+
using System.Reflection.PortableExecutable;
47
using ICSharpCode.Decompiler;
58
using ICSharpCode.Decompiler.CSharp;
9+
using ICSharpCode.Decompiler.Metadata;
610

711
namespace ApiChief.Format;
812

@@ -29,10 +33,13 @@ internal static class DecompilerFactory
2933
OptionalArguments = true,
3034
OutVariables = true,
3135
LiftNullables = true,
36+
LoadInMemory = true,
37+
ThrowOnAssemblyResolveErrors = true,
3238
CSharpFormattingOptions = Formatter.BaselineFormatting
3339
};
3440

35-
public static CSharpDecompiler Create(string path) => new(path, _decompilerSettings);
41+
public static CSharpDecompiler Create(string path)
42+
=> new(path, CreateAssemblyResolver(path, _decompilerSettings), _decompilerSettings);
3643

3744
public static CSharpDecompiler CreateWithXmlComments(string path)
3845
{
@@ -41,6 +48,29 @@ public static CSharpDecompiler CreateWithXmlComments(string path)
4148
xmlCommentsSettings.CSharpFormattingOptions = Formatter.FormattingWithXmlComments;
4249
xmlCommentsSettings.ShowXmlDocumentation = true;
4350

44-
return new(path, xmlCommentsSettings);
51+
return new(path, CreateAssemblyResolver(path, xmlCommentsSettings), xmlCommentsSettings);
52+
}
53+
54+
private static UniversalAssemblyResolver CreateAssemblyResolver(string assemblyPath, DecompilerSettings settings)
55+
{
56+
var file = new PEFile(
57+
assemblyPath,
58+
new FileStream(assemblyPath, FileMode.Open, FileAccess.Read),
59+
streamOptions: PEStreamOptions.PrefetchEntireImage);
60+
61+
var resolver = new UniversalAssemblyResolver(
62+
assemblyPath,
63+
settings.ThrowOnAssemblyResolveErrors,
64+
file.DetectTargetFrameworkId(),
65+
file.DetectRuntimePack(),
66+
PEStreamOptions.PrefetchMetadata);
67+
68+
var nugetPackages = Environment.GetEnvironmentVariable("NUGET_PACKAGES");
69+
if (!string.IsNullOrEmpty(nugetPackages) && Directory.Exists(nugetPackages))
70+
{
71+
resolver.AddSearchDirectory(nugetPackages);
72+
}
73+
74+
return resolver;
4575
}
4676
}

src/EFCore.Cosmos/EFCore.Cosmos.baseline.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@
141141
"Member": "virtual Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder.ConnectionMode(Microsoft.Azure.Cosmos.ConnectionMode connectionMode);"
142142
},
143143
{
144-
"Member": "virtual Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder.ContentResponseOnWriteEnabled(bool enabled = true);"
144+
"Member": "virtual Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder.ContentResponseOnWriteEnabled(bool enabled = true);",
145+
"Stage": "Obsolete"
145146
},
146147
{
147148
"Member": "override bool Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder.Equals(object? obj);"

src/EFCore.Relational/EFCore.Relational.baseline.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8399,6 +8399,19 @@
83998399
}
84008400
]
84018401
},
8402+
{
8403+
"Type": "class Microsoft.EntityFrameworkCore.Diagnostics.MigrationVersionEventData : Microsoft.EntityFrameworkCore.Diagnostics.DbContextTypeEventData",
8404+
"Methods": [
8405+
{
8406+
"Member": "Microsoft.EntityFrameworkCore.Diagnostics.MigrationVersionEventData.MigrationVersionEventData(Microsoft.EntityFrameworkCore.Diagnostics.EventDefinitionBase eventDefinition, System.Func<Microsoft.EntityFrameworkCore.Diagnostics.EventDefinitionBase, Microsoft.EntityFrameworkCore.Diagnostics.EventData, string> messageGenerator, System.Type contextType, string? migrationVersion);"
8407+
}
8408+
],
8409+
"Properties": [
8410+
{
8411+
"Member": "virtual string? Microsoft.EntityFrameworkCore.Diagnostics.MigrationVersionEventData.MigrationVersion { get; }"
8412+
}
8413+
]
8414+
},
84028415
{
84038416
"Type": "class Microsoft.EntityFrameworkCore.Diagnostics.MigratorConnectionEventData : Microsoft.EntityFrameworkCore.Diagnostics.MigratorEventData",
84048417
"Methods": [
@@ -12792,6 +12805,9 @@
1279212805
{
1279312806
"Member": "static readonly Microsoft.Extensions.Logging.EventId Microsoft.EntityFrameworkCore.Diagnostics.RelationalEventId.NonTransactionalMigrationOperationWarning"
1279412807
},
12808+
{
12809+
"Member": "static readonly Microsoft.Extensions.Logging.EventId Microsoft.EntityFrameworkCore.Diagnostics.RelationalEventId.OldMigrationVersionWarning"
12810+
},
1279512811
{
1279612812
"Member": "static readonly Microsoft.Extensions.Logging.EventId Microsoft.EntityFrameworkCore.Diagnostics.RelationalEventId.OptionalDependentWithAllNullPropertiesWarning"
1279712813
},
@@ -13491,6 +13507,9 @@
1349113507
{
1349213508
"Member": "static void Microsoft.EntityFrameworkCore.Diagnostics.RelationalLoggerExtensions.NonTransactionalMigrationOperationWarning(this Microsoft.EntityFrameworkCore.Diagnostics.IDiagnosticsLogger<Microsoft.EntityFrameworkCore.DbLoggerCategory.Migrations> diagnostics, Microsoft.EntityFrameworkCore.Migrations.IMigrator migrator, Microsoft.EntityFrameworkCore.Migrations.Migration migration, Microsoft.EntityFrameworkCore.Migrations.MigrationCommand command);"
1349313509
},
13510+
{
13511+
"Member": "static void Microsoft.EntityFrameworkCore.Diagnostics.RelationalLoggerExtensions.OldMigrationVersionWarning(this Microsoft.EntityFrameworkCore.Diagnostics.IDiagnosticsLogger<Microsoft.EntityFrameworkCore.DbLoggerCategory.Migrations> diagnostics, System.Type contextType, string? migrationVersion);"
13512+
},
1349413513
{
1349513514
"Member": "static void Microsoft.EntityFrameworkCore.Diagnostics.RelationalLoggerExtensions.OptionalDependentWithAllNullPropertiesWarning(this Microsoft.EntityFrameworkCore.Diagnostics.IDiagnosticsLogger<Microsoft.EntityFrameworkCore.DbLoggerCategory.Update> diagnostics, Microsoft.EntityFrameworkCore.Update.IUpdateEntry entry);"
1349613515
},

src/EFCore.SqlServer/EFCore.SqlServer.baseline.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2630,7 +2630,7 @@
26302630
"Member": "static System.Linq.IQueryable<Microsoft.EntityFrameworkCore.Query.FullTextSearchResult<TKey>> Microsoft.EntityFrameworkCore.SqlServerQueryableExtensions.FreeTextTable<T, TKey>(this Microsoft.EntityFrameworkCore.DbSet<T> source, string freeText, System.Linq.Expressions.Expression<System.Func<T, object>>? columnSelector = null, string? languageTerm = null, int? topN = null);"
26312631
},
26322632
{
2633-
"Member": "static System.Linq.IQueryable<Microsoft.EntityFrameworkCore.VectorSearchResult<T>> Microsoft.EntityFrameworkCore.SqlServerQueryableExtensions.VectorSearch<T, TVector>(this Microsoft.EntityFrameworkCore.DbSet<T> source, System.Linq.Expressions.Expression<System.Func<T, TVector>> vectorPropertySelector, TVector similarTo, string metric, int topN);",
2633+
"Member": "static System.Linq.IQueryable<Microsoft.EntityFrameworkCore.VectorSearchResult<T>> Microsoft.EntityFrameworkCore.SqlServerQueryableExtensions.VectorSearch<T, TVector>(this Microsoft.EntityFrameworkCore.DbSet<T> source, System.Linq.Expressions.Expression<System.Func<T, TVector>> vectorPropertySelector, TVector similarTo, string metric);",
26342634
"Stage": "Experimental"
26352635
}
26362636
]

src/EFCore/EFCore.baseline.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17035,7 +17035,7 @@
1703517035
"Type": "class Microsoft.EntityFrameworkCore.Storage.Json.JsonReaderData",
1703617036
"Methods": [
1703717037
{
17038-
"Member": "Microsoft.EntityFrameworkCore.Storage.Json.JsonReaderData.JsonReaderData(byte[] buffer);"
17038+
"Member": "Microsoft.EntityFrameworkCore.Storage.Json.JsonReaderData.JsonReaderData(System.ReadOnlyMemory<byte> buffer);"
1703917039
},
1704017040
{
1704117041
"Member": "Microsoft.EntityFrameworkCore.Storage.Json.JsonReaderData.JsonReaderData(System.IO.Stream stream);"
@@ -17742,10 +17742,6 @@
1774217742
{
1774317743
"Member": "override System.Linq.Expressions.Expression Microsoft.EntityFrameworkCore.Query.LiftableConstantProcessor.VisitExtension(System.Linq.Expressions.Expression node);",
1774417744
"Stage": "Experimental"
17745-
},
17746-
{
17747-
"Member": "override System.Linq.Expressions.Expression Microsoft.EntityFrameworkCore.Query.LiftableConstantProcessor.VisitMember(System.Linq.Expressions.MemberExpression memberExpression);",
17748-
"Stage": "Experimental"
1774917745
}
1775017746
],
1775117747
"Properties": [

0 commit comments

Comments
 (0)