Many Azure.ResourceManager.* sample projects are missing necessary package references
See original GitHub issueRelated to #33969, many MPG sample projects are lacking references they need to actually build, such as Azure.Identity or NUnit. In fact, the fact they are using NUnit means they should be under the tests/ subdirectory (by convention) and have a “.Tests” suffix. See https://github.com/Azure/azure-sdk-for-net/blob/main/doc/DataPlaneCodeGeneration/Create_Samples_Guidance.md. While this mentions data plane, I see no reason management plane shouldn’t be similar.
Several years ago when many of our samples didn’t work or didn’t even compile, several of us creating conventions and tools to make sure they are always run (at least with live tests, if not recorded) and built, and from there we get snippets. This convention is also assumed in many build files. For example, right now these source files will get included anytime IncludeSamples=true IncludeTests=false
is passed to builds (effectively; not exact syntax) because the directories are used to determine what are tests, what are samples, etc. Conversely, all these tests that use NUnit won’t get run when running many of these same commands because they are treated like samples and not tests.
As an example, in sdk\iothub\Azure.ResourceManager.IotHub\samples\Generated\Samples\Sample_EventHubConsumerGroupInfoCollection.cs:
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.IotHub;
using Azure.ResourceManager.IotHub.Models;
namespace Azure.ResourceManager.IotHub.Samples
{
public partial class Sample_EventHubConsumerGroupInfoCollection
{
// IotHubResource_ListEventHubConsumerGroups
[NUnit.Framework.Test]
[NUnit.Framework.Ignore("Only verifying that the sample builds")]
public async Task GetAll_IotHubResourceListEventHubConsumerGroups()
// ...
Here’s the project that contains that sample:
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\src\Azure.ResourceManager.IotHub.csproj" />
</ItemGroup>
</Project>
As you can see, there are no PackageReference
items to Azure.Identity or NUnit.Framework.
Issue Analytics
- State:
- Created 7 months ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
Hi @heaths we are able to find and fix some of them in this PR: https://github.com/Azure/azure-sdk-for-net/pull/34283
Well, we might forgot to add the package references for nunit when creating the new project. @dvbb could you take a look and provide some fixes?