Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,29 +95,50 @@ private IEnumerable<IMethodSymbol> GetDependentAssemblyFunctions(GeneratorExecut
{
foreach (var assembly in context.Compilation.SourceModule.ReferencedAssemblySymbols)
{
var namespaceSymbols = assembly.GlobalNamespace.GetMembers();
foreach (var methodSymbol in GetMethodsFromNamespace(context.Compilation, assembly.GlobalNamespace))
{
yield return methodSymbol;
}
}
}

foreach (var namespaceSymbol in namespaceSymbols)
private IEnumerable<IMethodSymbol> GetMethodsFromNamespace(Compilation compilation, INamespaceSymbol namespaceSymbol)
{
foreach (var member in namespaceSymbol.GetMembers())
{
if (member is INamespaceSymbol nestedNamespace)
{
// Recursive call for nested namespaces
foreach (var methodSymbol in GetMethodsFromNamespace(compilation, nestedNamespace))
{
yield return methodSymbol;
}
}
else if (member is INamedTypeSymbol typeSymbol)
{
var namespaceMembers = namespaceSymbol.GetMembers();
// Recursive call for nested types
foreach (var methodSymbol in GetMethodsFromType(compilation, typeSymbol))
{
yield return methodSymbol;
}
}
}
}

foreach (var m in namespaceMembers)
private IEnumerable<IMethodSymbol> GetMethodsFromType(Compilation compilation, INamedTypeSymbol typeSymbol)
{
foreach (var member in typeSymbol.GetMembers())
{
if (member is IMethodSymbol methodSymbol && FunctionsUtil.IsFunctionSymbol(methodSymbol, compilation))
{
yield return methodSymbol;
}
else if (member is INamedTypeSymbol nestedType)
{
// Recursive call for nested types
foreach (var nestedMethodSymbol in GetMethodsFromType(compilation, nestedType))
{
if (m is INamedTypeSymbol namedType)
{
var typeMembers = namedType.GetMembers();

foreach (var typeMember in typeMembers)
{
if (typeMember is IMethodSymbol method)
{
if (FunctionsUtil.IsFunctionSymbol(method, context.Compilation))
{
yield return method;
}
}
}
}
yield return nestedMethodSymbol;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/Sdk.Generators/Sdk.Generators.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<IncludeBuildOutput>false</IncludeBuildOutput>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<MinorProductVersion>1</MinorProductVersion>
<PatchProductVersion>3</PatchProductVersion>
<PatchProductVersion>4</PatchProductVersion>
<VersionSuffix></VersionSuffix>
<IsRoslynComponent>true</IsRoslynComponent>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion sdk/Sdk/Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<MinorProductVersion>16</MinorProductVersion>
<PatchProductVersion>1</PatchProductVersion>
<PatchProductVersion>2</PatchProductVersion>
<TargetFrameworks>netstandard2.0;net472</TargetFrameworks>
<PackageId>Microsoft.Azure.Functions.Worker.Sdk</PackageId>
<Description>This package provides development time support for the Azure Functions .NET Worker.</Description>
Expand Down
13 changes: 4 additions & 9 deletions sdk/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@
- My change description (#PR/#issue)
-->

### Microsoft.Azure.Functions.Worker.Sdk 1.16.1 (meta package)
### Microsoft.Azure.Functions.Worker.Sdk 1.16.2 (meta package)

- Update Microsoft.Azure.Functions.Worker.Sdk.Generators dependency to 1.1.3
- Update Microsoft.Azure.Functions.Worker.Sdk.Generators dependency to 1.1.4

### Microsoft.Azure.Functions.Worker.Sdk.Generators 1.1.3
### Microsoft.Azure.Functions.Worker.Sdk.Generators 1.1.4

- Fixed casing bug in source-generation. Binding types were changed from pascal case to camel case to match legacy generation (#2022)
- Reverted: Default to optimized function executor (#2012)
- Updated source generated versions of IFunctionExecutor to use `global::` namespace prefix to avoid build errors for function class with the same name as its containing namespace. (#1993)
- Updated source generated versions of IFunctionExecutor to include XML documentation for all public types and members
- Updated source generated versions of IFunctionMedatadaProvider to include XML documentation for all public types and members
- Updated source generated versions of IFunctionExecutor to use case-sensitive comparison to fix incorrect invocation of functions with method names only differ in casing. (#2003)
- Adding support for locating functions within nested types and nested namespaces from referenced assemblies (#2054)
6 changes: 3 additions & 3 deletions test/DependentAssemblyWithFunctions/DependencyFunction.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

using System.Net;
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.;

using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;

namespace DependentAssemblyWithFunctions
{
Expand Down
17 changes: 17 additions & 0 deletions test/DependentAssemblyWithFunctions/NestedNamespaceFunction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.;

using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;

namespace MyCompany.MyProduct.MyApp
{
public class HttpFunctions
{
[Function("NestedNamespaceFunc1")]
public HttpResponseData Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req)
{
throw new NotImplementedException();
}
}
}
20 changes: 20 additions & 0 deletions test/DependentAssemblyWithFunctions/NestedTypesFunction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.;

using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;

namespace MyCompany.MyProduct.MyApp
{
public sealed class Foo
{
public sealed class Bar
{
[Function("NestedTypeFunc")]
public HttpResponseData Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req)
{
throw new NotImplementedException();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,32 @@ public Task<ImmutableArray<IFunctionMetadata>> GetFunctionMetadataAsync(string d
ScriptFile = "DependentAssemblyWithFunctions.dll"
};
metadataList.Add(Function3);
var Function4RawBindings = new List<string>();
Function4RawBindings.Add(@"{""name"":""req"",""type"":""httpTrigger"",""direction"":""In"",""authLevel"":""Anonymous"",""methods"":[""get"",""post""]}");
Function4RawBindings.Add(@"{""name"":""$return"",""type"":""http"",""direction"":""Out""}");

var Function4 = new DefaultFunctionMetadata
{
Language = "dotnet-isolated",
Name = "NestedNamespaceFunc1",
EntryPoint = "MyCompany.MyProduct.MyApp.HttpFunctions.Run",
RawBindings = Function4RawBindings,
ScriptFile = "DependentAssemblyWithFunctions.dll"
};
metadataList.Add(Function4);
var Function5RawBindings = new List<string>();
Function5RawBindings.Add(@"{""name"":""req"",""type"":""httpTrigger"",""direction"":""In"",""authLevel"":""Anonymous"",""methods"":[""get"",""post""]}");
Function5RawBindings.Add(@"{""name"":""$return"",""type"":""http"",""direction"":""Out""}");

var Function5 = new DefaultFunctionMetadata
{
Language = "dotnet-isolated",
Name = "NestedTypeFunc",
EntryPoint = "MyCompany.MyProduct.MyApp.Foo.Bar.Run",
RawBindings = Function5RawBindings,
ScriptFile = "DependentAssemblyWithFunctions.dll"
};
metadataList.Add(Function5);

return Task.FromResult(metadataList.ToImmutableArray());
}
Expand Down