From 6f846081fd2d19c351efada3562094ea385a351f Mon Sep 17 00:00:00 2001 From: Sarah Vu Date: Mon, 28 Nov 2022 12:40:27 -0800 Subject: [PATCH 01/10] initial wip --- .../FunctionMetadataProviderGenerator.cs | 20 +++++++++++++------ .../Properties/launchSettings.json | 4 ++++ sdk/Sdk.Generators/Sdk.Generators.csproj | 4 ++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/sdk/Sdk.Generators/FunctionMetadataProviderGenerator.cs b/sdk/Sdk.Generators/FunctionMetadataProviderGenerator.cs index 1bf803c49..efe7aab83 100644 --- a/sdk/Sdk.Generators/FunctionMetadataProviderGenerator.cs +++ b/sdk/Sdk.Generators/FunctionMetadataProviderGenerator.cs @@ -26,15 +26,23 @@ public void Execute(GeneratorExecutionContext context) // attempt to parse user compilation var p = new Parser(context); - IReadOnlyList functionMetadataInfo = p.GetFunctionMetadataInfo(receiver.CandidateMethods); - // Proceed to generate the file if function metadata info was successfully returned - if (functionMetadataInfo.Count > 0) + context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.FunctionsDisableFuncMetadataSourceGen", out var sourceGenSwitch); + + bool.TryParse(sourceGenSwitch, out bool disableSourceGen); + + if (!disableSourceGen) { - var e = new Emitter(); - string result = e.Emit(functionMetadataInfo, context.CancellationToken); + IReadOnlyList functionMetadataInfo = p.GetFunctionMetadataInfo(receiver.CandidateMethods); - context.AddSource($"GeneratedFunctionMetadataProvider.g.cs", SourceText.From(result, Encoding.UTF8)); + // Proceed to generate the file if function metadata info was successfully returned + if (functionMetadataInfo.Count > 0) + { + var e = new Emitter(); + string result = e.Emit(functionMetadataInfo, context.CancellationToken); + + context.AddSource($"GeneratedFunctionMetadataProvider.g.cs", SourceText.From(result, Encoding.UTF8)); + } } } diff --git a/sdk/Sdk.Generators/Properties/launchSettings.json b/sdk/Sdk.Generators/Properties/launchSettings.json index a90ca0b10..38de405ef 100644 --- a/sdk/Sdk.Generators/Properties/launchSettings.json +++ b/sdk/Sdk.Generators/Properties/launchSettings.json @@ -1,6 +1,10 @@ { "profiles": { +<<<<<<< HEAD "SourceGenDebug": { +======= + "Source Generator": { +>>>>>>> 3c1c792 (initial wip) "commandName": "DebugRoslynComponent", "targetProject": "..\\..\\samples\\FunctionApp\\FunctionApp.csproj" } diff --git a/sdk/Sdk.Generators/Sdk.Generators.csproj b/sdk/Sdk.Generators/Sdk.Generators.csproj index 9e8211cc8..67665a4d2 100644 --- a/sdk/Sdk.Generators/Sdk.Generators.csproj +++ b/sdk/Sdk.Generators/Sdk.Generators.csproj @@ -35,4 +35,8 @@ + + + + \ No newline at end of file From a89d460fe703a5c7968439eedd1e376f87766c7a Mon Sep 17 00:00:00 2001 From: Sarah Vu Date: Mon, 28 Nov 2022 12:44:51 -0800 Subject: [PATCH 02/10] sdk target and props changes --- sdk/Sdk.Generators/Sdk.Generators.csproj | 5 ----- sdk/Sdk/Targets/Microsoft.Azure.Functions.Worker.Sdk.props | 3 +++ sdk/Sdk/Targets/Microsoft.Azure.Functions.Worker.Sdk.targets | 1 + 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/sdk/Sdk.Generators/Sdk.Generators.csproj b/sdk/Sdk.Generators/Sdk.Generators.csproj index 67665a4d2..08c08cc40 100644 --- a/sdk/Sdk.Generators/Sdk.Generators.csproj +++ b/sdk/Sdk.Generators/Sdk.Generators.csproj @@ -34,9 +34,4 @@ - - - - - \ No newline at end of file diff --git a/sdk/Sdk/Targets/Microsoft.Azure.Functions.Worker.Sdk.props b/sdk/Sdk/Targets/Microsoft.Azure.Functions.Worker.Sdk.props index b60e95325..ae5a1bedd 100644 --- a/sdk/Sdk/Targets/Microsoft.Azure.Functions.Worker.Sdk.props +++ b/sdk/Sdk/Targets/Microsoft.Azure.Functions.Worker.Sdk.props @@ -20,6 +20,9 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and + + + - Support sdk-type binding reference type (#1107) +- Add MS Build property to disable source generation of function metadata (it is enabled automatically) (#1200) + - Prop name: "FunctionsMetadataSourceGen_Enabled" \ No newline at end of file From 9f40b308116b41247dd43208b9315464bf682afb Mon Sep 17 00:00:00 2001 From: Sarah Vu Date: Mon, 9 Jan 2023 16:14:21 -0800 Subject: [PATCH 10/10] typo fix --- sdk/release_notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/release_notes.md b/sdk/release_notes.md index e01360db6..641849aa8 100644 --- a/sdk/release_notes.md +++ b/sdk/release_notes.md @@ -5,4 +5,4 @@ - Support sdk-type binding reference type (#1107) - Add MS Build property to disable source generation of function metadata (it is enabled automatically) (#1200) - - Prop name: "FunctionsMetadataSourceGen_Enabled" \ No newline at end of file + - Prop name: `FunctionsMetadataSourceGen_Enabled` \ No newline at end of file