diff --git a/sdk/Sdk.Generators/FunctionsUtil.cs b/sdk/Sdk.Generators/FunctionsUtil.cs
index 7f5046aed..0ba73d454 100644
--- a/sdk/Sdk.Generators/FunctionsUtil.cs
+++ b/sdk/Sdk.Generators/FunctionsUtil.cs
@@ -80,17 +80,12 @@ internal static string GetFullyQualifiedMethodName(IMethodSymbol method)
///
internal static string GetNamespaceForGeneratedCode(GeneratorExecutionContext context)
{
- // If csproj has the msbuild property specified, use it's value.
- if (context.AnalyzerConfigOptions.GlobalOptions.TryGetValue(Constants.BuildProperties.GeneratedCodeNamespace, out var namespaceValue)
- && !string.IsNullOrWhiteSpace(namespaceValue))
- {
- return namespaceValue;
- }
+ // If user has not provided a custom namespace explicitly,
+ // our msbuild target will set the RootNamespace msbuild property value as the value of this property.
+ context.AnalyzerConfigOptions.GlobalOptions.TryGetValue(Constants.BuildProperties.GeneratedCodeNamespace, out var namespaceValue);
- // Get the "RootNamespace" msbuild property value.(This gets populated in Microsoft.NET.Sdk.props and can be overridden by user in their function app)
- context.AnalyzerConfigOptions.GlobalOptions.TryGetValue(Constants.BuildProperties.MSBuildRootNamespace, out var rootNamespaceValue);
+ return namespaceValue!;
- return rootNamespaceValue!;
}
}
}
diff --git a/sdk/Sdk/Targets/Microsoft.Azure.Functions.Worker.Sdk.targets b/sdk/Sdk/Targets/Microsoft.Azure.Functions.Worker.Sdk.targets
index 8ff55d245..a6fa6dd62 100644
--- a/sdk/Sdk/Targets/Microsoft.Azure.Functions.Worker.Sdk.targets
+++ b/sdk/Sdk/Targets/Microsoft.Azure.Functions.Worker.Sdk.targets
@@ -42,6 +42,7 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
false
true
true
+ $(RootNamespace.Replace("-", "_"))
-### Microsoft.Azure.Functions.Worker.Sdk 1.16.3 (meta package)
+### Microsoft.Azure.Functions.Worker.Sdk 1.16.4 (meta package)
+
+- Update Microsoft.Azure.Functions.Worker.Sdk.Generators dependency to 1.1.5
+
+### Microsoft.Azure.Functions.Worker.Sdk.Generators 1.1.5
- Update worker.config generation to accurate worker executable name (#1053)
-- Bug fix for scenarios with `$return` output binding and `HttpTrigger` breaking output-binding rules (#2098)
\ No newline at end of file
+- Generate valid namespace when root namespace contains `-` (#2097)
+- Bug fix for scenarios with `$return` output binding and `HttpTrigger` breaking output-binding rules (#2098)
diff --git a/test/Sdk.Generator.Tests/TestHelpers.cs b/test/Sdk.Generator.Tests/TestHelpers.cs
index c1d015ebc..71605e43e 100644
--- a/test/Sdk.Generator.Tests/TestHelpers.cs
+++ b/test/Sdk.Generator.Tests/TestHelpers.cs
@@ -26,7 +26,8 @@ public static Task RunTestAsync(
string? expectedFileName,
string? expectedOutputSource,
List? expectedDiagnosticResults = null,
- IDictionary? buildPropertiesDictionary = null) where TSourceGenerator : ISourceGenerator, new()
+ IDictionary? buildPropertiesDictionary = null,
+ string? generatedCodeNamespace = null) where TSourceGenerator : ISourceGenerator, new()
{
CSharpSourceGeneratorVerifier.Test test = new()
{
@@ -49,7 +50,7 @@ public static Task RunTestAsync(
var config = $@"is_global = true
build_property.FunctionsEnableExecutorSourceGen = {true}
build_property.FunctionsEnableMetadataSourceGen = {true}
- build_property.RootNamespace = TestProject";
+ build_property.FunctionsGeneratedCodeNamespace = {generatedCodeNamespace ?? "TestProject"}";
// Add test specific MSBuild properties.
if (buildPropertiesDictionary is not null)