Skip to content

Commit 773a0b4

Browse files
committed
Bug fixes, docs
1 parent da03a35 commit 773a0b4

12 files changed

Lines changed: 138 additions & 9 deletions

File tree

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project>
22
<PropertyGroup>
3-
<CommonPackageVersion>4.0.41-beta.4</CommonPackageVersion>
3+
<CommonPackageVersion>4.0.44-beta.4</CommonPackageVersion>
44
</PropertyGroup>
55
</Project>

Source/FunctionMonkey.Abstractions/Extensions/TypeExtensions.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,15 @@ void ExpandType(Type currentType, bool includeNamespace)
5858
}
5959
else
6060
{
61-
retType.Append(includeNamespace ? currentType.ToString() : currentType.Name);
61+
// Not sure if this is correct, its to deal with F# array types as in the ToDo example
62+
if (currentType.IsArray && currentType.ToString().Contains('+'))
63+
{
64+
retType.Append(includeNamespace ? currentType.ToString().Replace("+", ".") : currentType.Name);
65+
}
66+
else
67+
{
68+
retType.Append(includeNamespace ? currentType.ToString() : currentType.Name);
69+
}
6270
}
6371
}
6472

Source/FunctionMonkey.Compiler.Core/Compiler.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ public bool Compile()
117117
CompilerOptions = builder.Options
118118
};
119119
}
120+
121+
PostBuildPatcher.EnsureFunctionsHaveUniqueNames(functionCompilerMetadata.FunctionDefinitions);
120122

121123
IReadOnlyCollection<string> externalAssemblies =
122124
GetExternalAssemblyLocations(functionCompilerMetadata.FunctionDefinitions);
@@ -131,7 +133,7 @@ public bool Compile()
131133
externalAssemblies,
132134
_outputBinaryFolder);
133135
}
134-
136+
135137
private bool VerifyOutputBindings(IFunctionHostBuilder builder)
136138
{
137139
bool foundErrors = false;

Source/FunctionMonkey.Compiler/FunctionMonkey.Compiler.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
33
<metadata>
44
<id>FunctionMonkey.Compiler</id>
5-
<version>4.0.41-beta.4</version>
5+
<version>4.0.44-beta.4</version>
66
<authors>James Randall</authors>
77
<description>Generates Azure Functions from command registrations</description>
88
<licenseUrl>https://raw.githubusercontent.com/JamesRandall/FunctionMonkey/master/LICENSE</licenseUrl>

Source/FunctionMonkey.FSharp/FunctionCompilerMetadata.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ module internal FunctionCompilerMetadata =
408408
|> Seq.map (fun f -> f |> createTimerFunctionDefinition configuration) |> Seq.cast<AbstractFunctionDefinition>)
409409
|> Seq.append(configuration.functions.cosmosDbFunctions
410410
|> Seq.map (fun f -> f |> createCosmosDbFunctionDefinition configuration) |> Seq.cast<AbstractFunctionDefinition>)
411+
//|> Seq.mapi(fun index functionDefinition -> functionDefinition.Name <- sprintf "%s%d" functionDefinition.Name index ; functionDefinition)
411412
|> Seq.toList
412413
backlinkReferenceType = configuration.backlinkPropertyInfo.DeclaringType
413414
backlinkPropertyInfo = configuration.backlinkPropertyInfo

Source/FunctionMonkey/Infrastructure/PostBuildPatcher.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@ public PostBuildPatcher(IMediatorResultTypeExtractor resultTypeExtractor)
2929
{
3030
_resultTypeExtractor = resultTypeExtractor;
3131
}
32+
33+
public static void EnsureFunctionsHaveUniqueNames(IReadOnlyCollection<AbstractFunctionDefinition> functionDefinitions)
34+
{
35+
var groups = functionDefinitions.GroupBy(x => x.Name)
36+
.Where(x => x.Count() > 1)
37+
.Select(x => x.ToArray())
38+
.ToArray();
39+
foreach (var group in groups)
40+
{
41+
int index = 0;
42+
foreach (AbstractFunctionDefinition functionDefinition in group)
43+
{
44+
functionDefinition.Name = $"{functionDefinition.Name}{index}";
45+
index++;
46+
}
47+
}
48+
}
3249

3350
public Type CalculateCommandResultType(AbstractFunctionDefinition definition)
3451
{

Source/FunctionMonkey/Model/HttpFunctionDefinition.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ namespace FunctionMonkey.Model
1111
{
1212
public class HttpFunctionDefinition : AbstractFunctionDefinition
1313
{
14-
public HttpFunctionDefinition(Type commandType) : base("", commandType)
14+
public HttpFunctionDefinition(Type commandType) : base("Http", commandType)
1515
{
1616
}
1717

18-
public HttpFunctionDefinition(Type commandType, Type explicitCommandResultType) : base("", commandType, explicitCommandResultType)
18+
public HttpFunctionDefinition(Type commandType, Type explicitCommandResultType) : base("Http", commandType, explicitCommandResultType)
1919
{
2020
}
2121

Source/FunctionMonkey/RuntimeInstance.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ public RuntimeInstance(Assembly functionAppConfigurationAssembly,
123123
FunctionDefinitions = functionCompilerMetadata.FunctionDefinitions;
124124
compileTarget = functionCompilerMetadata.CompilerOptions.HttpTarget;
125125
}
126+
127+
PostBuildPatcher.EnsureFunctionsHaveUniqueNames(FunctionDefinitions);
126128

127129
RegisterCoreDependencies(builder?.MediatorType ?? typeof(DefaultMediatorDecorator), FunctionDefinitions, compileTarget);
128130

Tests/FunctionMonkey.FSharp.Tests.Integration.Functions/EntryPoint.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ let validateToken (bearerToken:string) =
5858
]))
5959

6060
let app = functionApp {
61-
outputSourcePath "/Users/jamesrandall/code/authoredSource"
61+
outputSourcePath "/Users/jamesrandall/Code/authoredSource"
6262
defaultAuthorizationMode Anonymous
6363
openApi "F# Integration Test Functions" "1.0.0"
6464
openApiUserInterface "/openapi"

Tests/FunctionMonkey.FSharp.Tests.Integration.Functions/HttpVerbFunctions.fs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,16 @@ let private patchRespond (command : HttpPatchCommand) : SimpleResponse =
7070

7171
let private postWithBytesRespond (command : HttpPostWithBytesCommand) =
7272
command
73+
74+
let private getWithNoParameters () : SimpleResponse =
75+
{
76+
value = 42
77+
message = "Some text"
78+
}
7379

7480
let httpVerbFunctions = functions {
7581
httpRoute "verbs" [
82+
azureFunction.http (Handler(getWithNoParameters), Get)
7683
azureFunction.http (Handler(getRespond), Get, subRoute = "/{value}")
7784
azureFunction.http (Handler(postRespond), Post)
7885
azureFunction.http (Handler(postWithBytesRespond), Post, subRoute = "/bytes")

0 commit comments

Comments
 (0)