WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
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
@@ -0,0 +1,43 @@
<!--
***********************************************************************************************
Azure.Functions.Sdk.Analyzers.props

WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.

***********************************************************************************************
-->

<Project>

<PropertyGroup>
<FunctionsExecutionModel>isolated</FunctionsExecutionModel>
<FunctionsEnableMetadataSourceGen>true</FunctionsEnableMetadataSourceGen>
<FunctionsAutoRegisterGeneratedMetadataProvider>true</FunctionsAutoRegisterGeneratedMetadataProvider>
<FunctionsEnableExecutorSourceGen>true</FunctionsEnableExecutorSourceGen>
<FunctionsAutoRegisterGeneratedFunctionsExecutor>true</FunctionsAutoRegisterGeneratedFunctionsExecutor>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk.Analyzers" Version="1.2.2" IsImplicitlyDefined="true">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk.Generators" Version="1.3.6" IsImplicitlyDefined="true">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<CompilerVisibleProperty Include="FunctionsEnableMetadataSourceGen" />
<CompilerVisibleProperty Include="FunctionsEnableExecutorSourceGen" />
<CompilerVisibleProperty Include="FunctionsAutoRegisterGeneratedFunctionsExecutor" />
<CompilerVisibleProperty Include="FunctionsAutoRegisterGeneratedMetadataProvider" />
<CompilerVisibleProperty Include="FunctionsGeneratedCodeNamespace" />
<CompilerVisibleProperty Include="TargetFrameworkIdentifier" />
<CompilerVisibleProperty Include="FunctionsExecutionModel" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!--
***********************************************************************************************
Azure.Functions.Sdk.Analyzers.targets

WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.

***********************************************************************************************
-->

<Project>

<PropertyGroup>
<FunctionsGeneratedCodeNamespace Condition="'$(FunctionsGeneratedCodeNamespace)' == ''">$(RootNamespace.Replace("-", "_"))</FunctionsGeneratedCodeNamespace>
</PropertyGroup>

</Project>
1 change: 1 addition & 0 deletions src/Azure.Functions.Sdk/Targets/Azure.Functions.Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
</PropertyGroup>

<Import Sdk="Microsoft.NET.Sdk.Worker" Project="Sdk.props" />
<Import Project="$(MSBuildThisFileDirectory)Azure.Functions.Sdk.Analyzers.props" />
<Import Project="$(MSBuildThisFileDirectory)extensions/Azure.Functions.Sdk.Extensions.props" />

<!-- Enable Azure Functions project capability to enable tools -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
<UsingTask TaskName="$(AzureFunctionsTaskNamespace).FuncSdkLog" AssemblyFile="$(AzureFunctionsSdkTasksAssembly)" />
<UsingTask TaskName="$(AzureFunctionsTaskNamespace).GenerateWorkerConfig" AssemblyFile="$(AzureFunctionsSdkTasksAssembly)" />


<PropertyGroup>
<_AzureFunctionsVersionStandardized>$(AzureFunctionsVersion.ToLowerInvariant().Split('-')[0])</_AzureFunctionsVersionStandardized>
<_FunctionsRuntimeMajorVersion>$(_AzureFunctionsVersionStandardized.TrimStart('vV'))</_FunctionsRuntimeMajorVersion>
Expand All @@ -24,6 +23,7 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
<FunctionsToolingSuffix Condition="'$(FunctionsToolingSuffix)' == ''">$(_ToolingSuffix)</FunctionsToolingSuffix>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)Azure.Functions.Sdk.Analyzers.targets" />
<Import Project="$(MSBuildThisFileDirectory)extensions/Azure.Functions.Sdk.Extensions.targets" />
<Import Project="$(MSBuildFunctionsTargetsPath)Microsoft.Azure.Functions.Designtime.targets"
Condition="Exists('$(MSBuildFunctionsTargetsPath)Microsoft.Azure.Functions.Designtime.targets')" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ namespace Azure.Functions.Sdk.Tests.Integration;

public partial class SdkEndToEndTests
{
private static readonly string[] CompilerVisiblePropertiesExpected =
[
"FunctionsEnableMetadataSourceGen",
"FunctionsAutoRegisterGeneratedMetadataProvider",
"FunctionsEnableExecutorSourceGen",
"FunctionsAutoRegisterGeneratedFunctionsExecutor",
"FunctionsGeneratedCodeNamespace",
"TargetFrameworkIdentifier",
"FunctionsExecutionModel",
];

[Fact]
public void Item_LocalSettingsJson_ExpectedMetadata()
{
Expand Down Expand Up @@ -45,7 +56,7 @@ public void Item_HostJson_ExpectedMetadata()
}

[Fact]
public void Item_WorkerPackage_IsIncluded()
public void Item_ImplicitPackages_AreIncluded()
{
// Arrange
ProjectCreator project = ProjectCreator.Templates.AzureFunctionsProject(
Expand All @@ -56,9 +67,32 @@ public void Item_WorkerPackage_IsIncluded()

// Assert
items.Should().ContainSingle(x => x.EvaluatedInclude == "Microsoft.Azure.Functions.Worker")
.Which.Should()
.HaveMetadata("Version", "2.2.0")
.And.HaveMetadata("IsImplicitlyDefined", "true");
.Which.Should().HaveMetadata("IsImplicitlyDefined", "true");

items.Should().ContainSingle(x => x.EvaluatedInclude == "Microsoft.Azure.Functions.Worker.Sdk.Analyzers")
.Which.Should().HaveMetadata("IsImplicitlyDefined", "true")
.And.HaveMetadata("PrivateAssets", "all");

items.Should().ContainSingle(x => x.EvaluatedInclude == "Microsoft.Azure.Functions.Worker.Sdk.Generators")
.Which.Should().HaveMetadata("IsImplicitlyDefined", "true")
.And.HaveMetadata("PrivateAssets", "all");
}

[Fact]
public void Item_CompilerVisibleProperty_AreIncluded()
{
// Arrange
ProjectCreator project = ProjectCreator.Templates.AzureFunctionsProject(
GetTempCsproj());

// Act
project.TryGetItems("CompilerVisibleProperty", out IReadOnlyCollection<ProjectItem>? items);

// Assert
foreach (string expected in CompilerVisiblePropertiesExpected)
{
items.Should().ContainSingle(x => x.EvaluatedInclude == expected);
}
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,19 @@ public void Property_ToolingSuffix_NetFx_MatchesTargetFramework(string tfm)
// Assert
toolingSuffix.Should().Be("netfx-isolated");
}

[Fact]
public void Property_AnalyzerProperties_ArePresent()
{
// Arrange
ProjectCreator project = ProjectCreator.Templates.AzureFunctionsProject(
GetTempCsproj());

// Act & Assert
foreach (string property in CompilerVisiblePropertiesExpected)
{
project.TryGetPropertyValue(property, out string? value);
value.Should().NotBeNullOrEmpty($"Property '{property}' should have a value.");
}
}
}
Loading