Skip to content

Commit

Permalink
merge from main
Browse files Browse the repository at this point in the history
  • Loading branch information
m-nash committed Jul 6, 2021
2 parents 9e01b40 + 7631373 commit 4b6c1bf
Show file tree
Hide file tree
Showing 1,963 changed files with 124,740 additions and 89,009 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
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>
7 changes: 4 additions & 3 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 Down Expand Up @@ -136,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
30 changes: 20 additions & 10 deletions eng/SnippetGenerator/SnippetGenerator.Tests/CSharpProcessorTests.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using NUnit.Framework;
using SnippetGenerator;

namespace SnippetGenerator.Tests
{
public class Tests
{
private const string Processed = "processed";
private const string ProcessedAgain = "processed again";

[Test]
[TestCaseSource(nameof(CodeInputs))]
public void CSharpProcsesorFindsCodeXMLDocs(string code, string expected)
public async Task CSharpProcsesorFindsCodeXMLDocs(string code, string expected)
{
var actual = CSharpProcessor.Process(code, SnippetProvider);
var actual = await CSharpProcessor.ProcessAsync(code, SnippetProvider);
Assert.AreEqual(expected, actual);

var reProcessed = CSharpProcessor.Process(actual, SnippetProvider);
Assert.AreEqual(expected, reProcessed);
var reProcessed = await CSharpProcessor.ProcessAsync(actual, SnippetProvider2);
Assert.AreEqual(expected.Replace(Processed, ProcessedAgain), reProcessed);
}

private string SnippetProvider(string s) => Processed;
private ValueTask<string> SnippetProvider(string s) => new(Processed);
private ValueTask<string> SnippetProvider2(string s) => new(ProcessedAgain);

public static IEnumerable<object[]> CodeInputs()
{
Expand All @@ -31,7 +33,7 @@ public static IEnumerable<object[]> CodeInputs()
" foo" + Environment.NewLine +
" {",
@" /// </remarks>" + Environment.NewLine +
@" /// <code snippet=""Snippet:A"">" + Environment.NewLine +
@" /// <code snippet=""Snippet:A"" language=""csharp"">" + Environment.NewLine +
$" /// {Processed} </code>" + Environment.NewLine +
" foo" + Environment.NewLine +
" {"
Expand All @@ -40,7 +42,7 @@ public static IEnumerable<object[]> CodeInputs()
yield return new[]
{
@"/// <code snippet=""Snippet:B""></code>",
@"/// <code snippet=""Snippet:B"">" + Environment.NewLine +
@"/// <code snippet=""Snippet:B"" language=""csharp"">" + Environment.NewLine +
$"/// {Processed} </code>"
};

Expand All @@ -50,7 +52,7 @@ public static IEnumerable<object[]> CodeInputs()
@" /// <code snippet=""Snippet:C""></code>" + Environment.NewLine +
" foo",
@" /// Example of enumerating an AsyncPageable using the <c> async foreach </c> loop:" + Environment.NewLine +
@" /// <code snippet=""Snippet:C"">" + Environment.NewLine +
@" /// <code snippet=""Snippet:C"" language=""csharp"">" + Environment.NewLine +
$" /// {Processed} </code>" + Environment.NewLine +
" foo"
};
Expand All @@ -62,11 +64,19 @@ public static IEnumerable<object[]> CodeInputs()
" foo",
@" /// Example of enumerating an AsyncPageable using the <c> async foreach </c> loop:" + Environment.NewLine +
@" /// <example snippet=""Snippet:Example"">" + Environment.NewLine +
@" /// <code>" + Environment.NewLine +
@" /// <code language=""csharp"">" + Environment.NewLine +
$" /// {Processed} </code>" + Environment.NewLine +
@" /// </example>" + Environment.NewLine +
" foo"
};

yield return new[]
{
@"/// <code snippet=""Snippet:AcceptsAnyTagSuffix"" any string here></code>",
@"/// <code snippet=""Snippet:AcceptsAnyTagSuffix"" language=""csharp"">" + Environment.NewLine +
$"/// {Processed} </code>"
};

}
}
}
Loading

0 comments on commit 4b6c1bf

Please sign in to comment.