@@ -39,38 +39,51 @@ public sealed class ScriptFunctionMetadataResolver : MetadataReferenceResolver,
39
39
private MetadataReferenceResolver _scriptResolver ;
40
40
41
41
private static readonly string [ ] DefaultAssemblyReferences =
42
- {
43
- typeof ( ILoggerFactory ) . Assembly . Location , /*Microsoft.Extensions.Logging.Abstractions*/
44
- typeof ( IAsyncCollector < > ) . Assembly . Location , /*Microsoft.Azure.WebJobs*/
45
- typeof ( JobHost ) . Assembly . Location , /*Microsoft.Azure.WebJobs.Host*/
46
- typeof ( WebJobs . Extensions . ExtensionsWebJobsStartup ) . Assembly . Location , /*Microsoft.Azure.WebJobs.Extensions*/
47
- typeof ( AspNetCore . Http . HttpRequest ) . Assembly . Location , /*Microsoft.AspNetCore.Http.Abstractions*/
48
- typeof ( AspNetCore . Mvc . IActionResult ) . Assembly . Location , /*Microsoft.AspNetCore.Mvc.Abstractions*/
49
- typeof ( AspNetCore . Mvc . RedirectResult ) . Assembly . Location , /*Microsoft.AspNetCore.Mvc.Core*/
50
- typeof ( AspNetCore . Http . IQueryCollection ) . Assembly . Location , /*Microsoft.AspNetCore.Http.Features*/
51
- typeof ( Microsoft . Extensions . Primitives . StringValues ) . Assembly . Location , /*Microsoft.Extensions.Primitives*/
52
- typeof ( System . Net . Http . HttpClientExtensions ) . Assembly . Location /*System.Net.Http.Formatting*/
53
- } ;
42
+ {
43
+ typeof ( ILoggerFactory ) . Assembly . Location , /*Microsoft.Extensions.Logging.Abstractions*/
44
+ typeof ( IAsyncCollector < > ) . Assembly . Location , /*Microsoft.Azure.WebJobs*/
45
+ typeof ( JobHost ) . Assembly . Location , /*Microsoft.Azure.WebJobs.Host*/
46
+ typeof ( WebJobs . Extensions . ExtensionsWebJobsStartup ) . Assembly . Location , /*Microsoft.Azure.WebJobs.Extensions*/
47
+ typeof ( AspNetCore . Http . HttpRequest ) . Assembly . Location , /*Microsoft.AspNetCore.Http.Abstractions*/
48
+ typeof ( AspNetCore . Mvc . IActionResult ) . Assembly . Location , /*Microsoft.AspNetCore.Mvc.Abstractions*/
49
+ typeof ( AspNetCore . Mvc . RedirectResult ) . Assembly . Location , /*Microsoft.AspNetCore.Mvc.Core*/
50
+ typeof ( AspNetCore . Http . IQueryCollection ) . Assembly . Location , /*Microsoft.AspNetCore.Http.Features*/
51
+ typeof ( Microsoft . Extensions . Primitives . StringValues ) . Assembly . Location , /*Microsoft.Extensions.Primitives*/
52
+ typeof ( System . Net . Http . HttpClientExtensions ) . Assembly . Location /*System.Net.Http.Formatting*/
53
+ } ;
54
54
55
55
private static readonly List < ISharedAssemblyProvider > SharedAssemblyProviders = new List < ISharedAssemblyProvider >
56
- {
57
- new DirectSharedAssemblyProvider ( typeof ( Newtonsoft . Json . JsonConvert ) . Assembly ) , /* Newtonsoft.Json */
58
- new DirectSharedAssemblyProvider ( typeof ( Microsoft . WindowsAzure . Storage . StorageUri ) . Assembly ) , /* Microsoft.WindowsAzure.Storage */
59
- } ;
56
+ {
57
+ new DirectSharedAssemblyProvider ( typeof ( Newtonsoft . Json . JsonConvert ) . Assembly ) , /* Newtonsoft.Json */
58
+ new DirectSharedAssemblyProvider ( typeof ( Microsoft . WindowsAzure . Storage . StorageUri ) . Assembly ) , /* Microsoft.WindowsAzure.Storage */
59
+ } ;
60
60
61
61
private static readonly string [ ] DefaultNamespaceImports =
62
- {
63
- "System" ,
64
- "System.Collections.Generic" ,
65
- "System.IO" ,
66
- "System.Linq" ,
67
- "System.Net.Http" ,
68
- "System.Threading.Tasks" ,
69
- "Microsoft.Azure.WebJobs" ,
70
- "Microsoft.Azure.WebJobs.Host" ,
71
- "Microsoft.Extensions.Logging" ,
72
- "Microsoft.AspNetCore.Http"
73
- } ;
62
+ {
63
+ "System" ,
64
+ "System.Collections.Generic" ,
65
+ "System.IO" ,
66
+ "System.Linq" ,
67
+ "System.Net.Http" ,
68
+ "System.Threading.Tasks" ,
69
+ "Microsoft.Azure.WebJobs" ,
70
+ "Microsoft.Azure.WebJobs.Host" ,
71
+ "Microsoft.Extensions.Logging" ,
72
+ "Microsoft.AspNetCore.Http"
73
+ } ;
74
+
75
+ private static readonly string [ ] PrivateHostAssemblies =
76
+ {
77
+ "Azure.Core" ,
78
+ "Azure.Identity" ,
79
+ "Azure.Storage.Blobs" ,
80
+ "Azure.Storage.Common" ,
81
+ "Microsoft.Azure.WebJobs.StorageProvider.Blobs" ,
82
+ "Microsoft.Bcl.AsyncInterfaces" ,
83
+ "Microsoft.Extensions.Azure" ,
84
+ "Microsoft.Identity.Client" ,
85
+ "Microsoft.Identity.Client.Extensions.Msal"
86
+ } ;
74
87
75
88
public ScriptFunctionMetadataResolver ( string scriptFilePath , ICollection < IScriptBindingProvider > bindingProviders , ILogger logger )
76
89
{
@@ -157,8 +170,13 @@ public override ImmutableArray<PortableExecutableReference> ResolveReference(str
157
170
158
171
if ( ! HasValidAssemblyFileExtension ( reference ) )
159
172
{
160
- // Try to resolve using the default resolver (framework assemblies, e.g. System.Core, System.Xml, etc.)
161
- ImmutableArray < PortableExecutableReference > result = _scriptResolver . ResolveReference ( reference , baseFilePath , properties ) ;
173
+ ImmutableArray < PortableExecutableReference > result = ImmutableArray < PortableExecutableReference > . Empty ;
174
+
175
+ if ( ! PrivateHostAssemblies . Contains ( reference ) )
176
+ {
177
+ // Try to resolve using the default resolver (framework assemblies, e.g. System.Core, System.Xml, etc.)
178
+ result = _scriptResolver . ResolveReference ( reference , baseFilePath , properties ) ;
179
+ }
162
180
163
181
// If the default script resolver can't resolve the assembly
164
182
// check if this is one of host's shared assemblies
0 commit comments