Skip to content

Commit

Permalink
Merge branch 'feature/mgmt-track2' of https://github.com/Azure/azure-…
Browse files Browse the repository at this point in the history
…sdk-for-net into mgmt-track2
  • Loading branch information
m-nash committed Jul 6, 2021
2 parents 3786863 + 4b6c1bf commit 96fef0c
Show file tree
Hide file tree
Showing 2,604 changed files with 730,423 additions and 142,658 deletions.
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Instructions for CODEOWNERS file format and automatic build failure notifications:
# https://github.com/Azure/azure-sdk/blob/master/docs/policies/opensource.md#codeowners
# https://github.com/Azure/azure-sdk/blob/main/docs/policies/opensource.md#codeowners

#########
# SDK
Expand Down Expand Up @@ -602,7 +602,7 @@ sdk/trafficmanager/Microsoft.Azure.Management.TrafficManager/ @tmsupp

# ServiceLabel: %Synapse %Service Attention
# PRLabel: %Synapse
/sdk/synapse/ @aim-for-better @idear1203 @chamons
/sdk/synapse/ @aim-for-better @idear1203 @annelo-msft

# PRLabel: %Tables
/sdk/tables/ @christothes
Expand Down
15 changes: 15 additions & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@
{
"filename": "**/eng/pipelines/templates/jobs/ci.yml",
"words": ["warnaserror"]
},
{
"filename": "**/sdk/storage/**/*.cs",
"words": [
"Aadds",
"Deprovisioning",
"Gzrs",
"Ntfs",
"Posix",
"Ragrs",
"Ragzrs",
"Rehydrated",
"Skus",
"Undelete"
]
}
],
"allowCompoundWords": true
Expand Down
50 changes: 50 additions & 0 deletions common/ManagementTestShared/Redesign/JsonHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.IO;
using System.Text;
using System.Text.Json;
using Azure.Core;
using NUnit.Framework;

namespace Azure.ResourceManager.TestFramework
{
internal static class JsonHelper
{
private static readonly JsonWriterOptions PrettyJsonOptions = new JsonWriterOptions() { Indented = true };
private static readonly JsonWriterOptions CompactJsonOptions = new JsonWriterOptions();

/// <summary>
/// This methods serialize the complete resource data to string.
/// </summary>
/// <param name="data"> Resource data that implements <see cref="IUtf8JsonSerializable"/>. </param>
/// <returns> Json string represent the data. </returns>
public static string SerializeToString(IUtf8JsonSerializable data, bool indented = false)
{
var stream = new MemoryStream();
Utf8JsonWriter writer = new(stream, indented ? PrettyJsonOptions : CompactJsonOptions);
writer.WriteObjectValue(data);
writer.Flush();
return Encoding.UTF8.GetString(stream.ToArray());
}

/// <summary>
/// This methods serialize the data properties to string under "properties" tag.
/// Please note if data has top level properties needed that goes outside of "properties",
/// use <see cref="JsonHelper.SerializeToString"/> instead.
/// </summary>
/// <param name="data"> data that implements <see cref="IUtf8JsonSerializable"/>. </param>
/// <returns> Json string represent the data object's properties. </returns>
public static string SerializePropertiesToString(IUtf8JsonSerializable data, bool indented = false)
{
var stream = new MemoryStream();
Utf8JsonWriter writer = new(stream, indented ? PrettyJsonOptions : CompactJsonOptions);
writer.WriteStartObject();
writer.WritePropertyName("properties");
writer.WriteObjectValue(data);
writer.WriteEndObject();
writer.Flush();
return Encoding.UTF8.GetString(stream.ToArray());
}
}
}
3 changes: 2 additions & 1 deletion eng/ApiListing.exclude-attributes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ T:System.Runtime.CompilerServices.AsyncIteratorStateMachineAttribute
T:System.Runtime.CompilerServices.AsyncStateMachineAttribute
T:System.Runtime.CompilerServices.CompilerGeneratedAttribute
T:System.Runtime.CompilerServices.NullableContextAttribute
T:System.Runtime.CompilerServices.NullableAttribute
T:System.Runtime.CompilerServices.NullableAttribute
T:Azure.Core.CodeGenSuppressAttribute
1 change: 1 addition & 0 deletions eng/BannedSymbols.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M:System.Uri.ToString();Prefer Uri.AbsoluteUri to Uri.ToString()
2 changes: 1 addition & 1 deletion eng/CHECKENFORCER
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ message: >

## For track 1 management-plane SDKs

Please open a separate PR and to your service SDK path in [this file](https://github.com/Azure/azure-sdk-for-net/blob/master/eng/pipelines/mgmt.yml). Once that PR has been merged, you can re-run the pipeline to trigger the verification.
Please open a separate PR and to your service SDK path in [this file](https://github.com/Azure/azure-sdk-for-net/blob/main/eng/pipelines/mgmt.yml). Once that PR has been merged, you can re-run the pipeline to trigger the verification.

1 change: 1 addition & 0 deletions eng/Directory.Build.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<EnableClientSdkAnalyzers Condition="'$(IsShippingClientLibrary)' == 'true'">true</EnableClientSdkAnalyzers>
<EnableFxCopAnalyzers Condition="'$(IsShippingClientLibrary)' == 'true'">true</EnableFxCopAnalyzers>
<EnableStyleCopAnalyzers Condition="'$(EnableStyleCopAnalyzers)' == '' and '$(IsClientLibrary)' == 'true'">true</EnableStyleCopAnalyzers>
<EnableBannedApiAnalyzers Condition="'$(IsShippingClientLibrary)' == 'true'">true</EnableBannedApiAnalyzers>
<GenerateAPIListing Condition="'$(IsShippingClientLibrary)' == 'true'">true</GenerateAPIListing>
<UpdateSourceOnBuild Condition="'$(UpdateSourceOnBuild)' == ''">$(AZURE_DEV_UPDATESOURCESONBUILD)</UpdateSourceOnBuild>
<PowerShellExe Condition="'$(PowerShellExe)' == ''">pwsh</PowerShellExe>
Expand Down
34 changes: 29 additions & 5 deletions eng/Directory.Build.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@

<PackageReference Condition="'$(EnableClientSdkAnalyzers)' == 'true'" Include="Azure.ClientSdk.Analyzers" PrivateAssets="All" />

<PackageReference Condition="'$(EnableFxCopAnalyzers)' == 'true'" Include="Microsoft.CodeAnalysis.FxCopAnalyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Condition="'$(EnableFxCopAnalyzers)' == 'true'" Include="Microsoft.CodeAnalysis.FxCopAnalyzers" PrivateAssets="All" />

<PackageReference Condition="'$(EnableBannedApiAnalyzers)' == 'true'" Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" PrivateAssets="All" />

</ItemGroup>

<!-- Add Package Icon to DataPlane Packages -->
Expand All @@ -105,7 +105,7 @@
</ItemGroup>

<!-- Add StyleCop Analyzers -->
<ItemGroup Condition="'$(EnableStyleCopAnalyzers)' == 'true'" >
<ItemGroup Condition="'$(EnableStyleCopAnalyzers)' == 'true'" >
<PackageReference Include="StyleCop.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand All @@ -115,6 +115,12 @@
</AdditionalFiles>
</ItemGroup>

<ItemGroup Condition="'$(IsClientLibrary)' == 'true'">
<AdditionalFiles Include="$(RepoEngPath)\BannedSymbols.txt">
<Visible>false</Visible>
</AdditionalFiles>
</ItemGroup>

<!-- Enable SourceLink -->
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
Expand Down Expand Up @@ -276,5 +282,23 @@
<Target Name="RunApiCompat" DependsOnTargets="ValidateApiCompatForSrc" Condition="'$(ApiCompatVersion)' != ''">
</Target>

<Target Name="GetPackageInfo">
<PropertyGroup>
<PackageIsNewSdk>false</PackageIsNewSdk>
<PackageIsNewSdk Condition="'$(IsClientLibrary)' == 'true'">true</PackageIsNewSdk>

<PackageSdkType>data</PackageSdkType>
<PackageSdkType Condition="'$(IsClientLibrary)' == 'true'">client</PackageSdkType>
<PackageSdkType Condition="'$(IsMgmtLibrary)' == 'true'">mgmt</PackageSdkType>

<PackageRootDirectory>$([MSBuild]::NormalizeDirectory($(MSBuildProjectDirectory)/../).Trim("/").Trim("\\"))</PackageRootDirectory>

<!-- Parse out the service directory based on the relative path to the sdk folder -->
<ServiceDirectory><![CDATA[$([System.Text.RegularExpressions.Regex]::Replace($(PackageRootDirectory), '^.*[\\/]+sdk[\\/]+([^\\/]+).*$', '$1'))]]></ServiceDirectory>
</PropertyGroup>

<Message Condition="'$(IsShippingLibrary)' == 'true'" Text="'$(PackageRootDirectory)' '$(ServiceDirectory)' '$(PackageId)' '$(_VersionInProject)' '$(PackageSdkType)' '$(PackageIsNewSdk)'" Importance="High" />
</Target>

<Import Project="$(CentralPackageVersionPackagePath)\Sdk.targets" />
</Project>
8 changes: 4 additions & 4 deletions eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@

<!-- Azure SDK packages -->
<PackageReference Update="Azure.Communication.Common" Version="1.0.1" />
<PackageReference Update="Azure.Core" Version="1.15.0" />
<PackageReference Update="Azure.Core" Version="1.16.0" />
<PackageReference Update="Azure.Core.Amqp" Version="1.1.0" />
<PackageReference Update="Azure.Core.Experimental" Version="0.1.0-preview.13" />
<PackageReference Update="Azure.Core.Experimental" Version="0.1.0-preview.14" />
<PackageReference Update="Azure.Messaging.EventHubs" Version="5.4.1" />
<PackageReference Update="Azure.Messaging.EventGrid" Version="4.3.0" />
<PackageReference Update="Azure.Messaging.ServiceBus" Version="7.2.0" />
Expand All @@ -88,7 +88,6 @@
<PackageReference Update="Azure.Security.KeyVault.Keys" Version="4.0.2" />
<PackageReference Update="Azure.Security.KeyVault.Certificates" Version="4.0.2" />
<PackageReference Update="Azure.Storage.Blobs" Version="12.8.0" />
<PackageReference Update="Azure.ResourceManager.Resources" Version="1.0.0-preview.2" />

<!-- Other approved packages -->
<PackageReference Update="Microsoft.Azure.Amqp" Version="2.4.13" />
Expand Down Expand Up @@ -137,10 +136,11 @@
All should have PrivateAssets="All" set so they don't become pacakge dependencies
-->
<ItemGroup>
<PackageReference Update="Microsoft.Azure.AutoRest.CSharp" Version="3.0.0-beta.20210622.3" PrivateAssets="All" />
<PackageReference Update="Microsoft.Azure.AutoRest.CSharp" Version="3.0.0-beta.20210629.5" PrivateAssets="All" />
<PackageReference Update="Azure.ClientSdk.Analyzers" Version="0.1.1-dev.20210601.1" PrivateAssets="All" />
<PackageReference Update="coverlet.collector" Version="1.3.0" PrivateAssets="All" />
<PackageReference Update="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.1" PrivateAssets="All" />
<PackageReference Update="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.2" PrivateAssets="All" />
<PackageReference Update="Microsoft.DotNet.ApiCompat" Version="5.0.0-beta.20467.1" PrivateAssets="All" />
<PackageReference Update="Microsoft.DotNet.GenAPI" Version="5.0.0-beta.19552.1" PrivateAssets="All" />
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
Expand Down
6 changes: 3 additions & 3 deletions eng/SnippetGenerator/CSharpProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ namespace SnippetGenerator
{
public class CSharpProcessor
{
private static readonly string _snippetFormat = "{3} <code snippet=\"{0}\">{1}{2} </code>";
private static readonly string _snippetExampleFormat = "{3} <example snippet=\"{0}\">{1}{3} <code>{1}{2} </code>{1}{3} </example>";
private static readonly string _snippetFormat = "{3} <code snippet=\"{0}\" language=\"csharp\">{1}{2} </code>";
private static readonly string _snippetExampleFormat = "{3} <example snippet=\"{0}\">{1}{3} <code language=\"csharp\">{1}{2} </code>{1}{3} </example>";

private static readonly Regex _snippetRegex = new Regex("^(?<indent>\\s*)\\/{3}\\s*<code snippet=\"(?<name>[\\w:]+)\">.*?\\s*<\\/code>",
private static readonly Regex _snippetRegex = new Regex("^(?<indent>\\s*)\\/{3}\\s*<code snippet=\"(?<name>[\\w:]+)\"[^>]*?>.*?\\s*<\\/code>",
RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);

private static readonly Regex _snippetExampleRegex = new Regex("^(?<indent>\\s*)\\/{3}\\s*<example snippet=\"(?<name>[\\w:]+)\">.*?\\s*<\\/example>",
Expand Down
27 changes: 23 additions & 4 deletions eng/SnippetGenerator/DirectoryProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -37,9 +38,8 @@ public DirectoryProcessor(string directory)
_snippets = new Lazy<Task<List<Snippet>>>(DiscoverSnippetsAsync);
}

public async Task ProcessAsync()
public async Task<IEnumerable<string>> ProcessAsync()
{

List<string> files = new List<string>();
files.AddRange(Directory.EnumerateFiles(_directory, "*.md", SearchOption.AllDirectories));
files.AddRange(Directory.EnumerateFiles(_directory, "*.cs", SearchOption.AllDirectories));
Expand All @@ -61,8 +61,10 @@ async ValueTask<string> SnippetProvider(string s)
}

var selectedSnippet = selectedSnippets.Single();
selectedSnippet.IsUsed = true;
Console.WriteLine($"Replaced {selectedSnippet.Name} in {file}");
return FormatSnippet(selectedSnippet.Text);
var result = FormatSnippet(selectedSnippet.Text);
return result;
}

var originalText = await File.ReadAllTextAsync(file);
Expand All @@ -86,13 +88,30 @@ async ValueTask<string> SnippetProvider(string s)
await File.WriteAllTextAsync(file, text, _utf8EncodingWithoutBOM);
}
}
var snippets = await _snippets.Value;
var unUsedSnippets = snippets
.Where(s => !s.IsUsed)
.Select(s => $"{GetServiceDirName(s.FilePath)}: {s.Name}");
return unUsedSnippets;

}

private string GetServiceDirName(string path)
{
string sdk = $"{Path.DirectorySeparatorChar}sdk{Path.DirectorySeparatorChar}";
int start = path.IndexOf(sdk) + sdk.Length;
int end = path.IndexOf(Path.DirectorySeparatorChar, start);
return path.Substring(start, end - start);
}

private async Task<List<Snippet>> DiscoverSnippetsAsync()
{
var snippets = await GetSnippetsInDirectoryAsync(_directory);
if (snippets.Count == 0)
{
return snippets;
}
Console.WriteLine($"Discovered snippets:");

foreach (var snippet in snippets)
{
Console.WriteLine($" {snippet.Name} in {snippet.FilePath}");
Expand Down
35 changes: 29 additions & 6 deletions eng/SnippetGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
Expand All @@ -13,27 +14,49 @@ namespace SnippetGenerator
{
public class Program
{

[Option(ShortName = "b")]
public string BasePath { get; set; }
[Option(ShortName = "b")] public string BasePath { get; set; }
[Option(ShortName = "sm")] public bool StrictMode { get; set; }

public async Task OnExecuteAsync()
{
List<string> unUsedSnippets = null;
Stopwatch sw = new Stopwatch();
sw.Start();
var baseDirectory = new DirectoryInfo(BasePath).Name;
if (baseDirectory.Equals("sdk"))
{
var tasks = new List<Task>();
var tasks = new List<Task<IEnumerable<string>>>();
foreach (var sdkDir in Directory.GetDirectories(BasePath))
{
tasks.Add(new DirectoryProcessor(sdkDir).ProcessAsync());
}

await Task.WhenAll(tasks);
unUsedSnippets = tasks
.SelectMany(t => t.Result)
.ToList();
}
else
{
unUsedSnippets = (await new DirectoryProcessor(BasePath).ProcessAsync()).ToList();
}
Console.WriteLine();
Console.ForegroundColor = ConsoleColor.Red;
string message = $"Not all snippets were used.\n{string.Join(Environment.NewLine, unUsedSnippets)}";
unUsedSnippets.Sort();
if (StrictMode)
{
if (unUsedSnippets.Any())
{
throw new InvalidOperationException(message);
}
}
else
{
await new DirectoryProcessor(BasePath).ProcessAsync();
Console.WriteLine(message);
}
sw.Stop();
Console.WriteLine($"SnippetGenerator completed in {sw.Elapsed}");
}

public static int Main(string[] args)
Expand All @@ -57,4 +80,4 @@ public static int Main(string[] args)
}
}
}
}
}
3 changes: 2 additions & 1 deletion eng/SnippetGenerator/Snippet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

namespace SnippetGenerator
{
internal class Snippet
public class Snippet
{
public string Name { get; }
public SourceText Text { get; }
public string FilePath { get; }
public bool IsUsed { get; set; }

public Snippet(string name, SourceText text, string filePath)
{
Expand Down
Loading

0 comments on commit 96fef0c

Please sign in to comment.