Skip to content

Commit

Permalink
Merge pull request #1270 from AArnott/libtemplateUpdate
Browse files Browse the repository at this point in the history
Merge latest Library.Template
  • Loading branch information
AArnott authored Jan 6, 2024
2 parents c51f4d2 + 52a1e17 commit 9065e6e
Show file tree
Hide file tree
Showing 29 changed files with 78 additions and 49 deletions.
12 changes: 3 additions & 9 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,13 @@
"isRoot": true,
"tools": {
"powershell": {
"version": "7.3.8",
"version": "7.4.0",
"commands": [
"pwsh"
]
},
"dotnet-format": {
"version": "5.1.250801",
"commands": [
"dotnet-format"
]
},
"dotnet-coverage": {
"version": "17.9.3",
"version": "17.9.5",
"commands": [
"dotnet-coverage"
]
Expand All @@ -27,4 +21,4 @@
]
}
}
}
}
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Refer to https://hub.docker.com/_/microsoft-dotnet-sdk for available versions
FROM mcr.microsoft.com/dotnet/sdk:7.0.401-jammy
FROM mcr.microsoft.com/dotnet/sdk:8.0.100-jammy

# Installing mono makes `dotnet test` work without errors even for net472.
# But installing it takes a long time, so it's excluded by default.
Expand Down
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ indent_size = 4
[*.{cs,vb}]
# Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false
dotnet_style_qualification_for_field = true:warning
dotnet_style_qualification_for_property = true:warning
dotnet_style_qualification_for_method = true:warning
Expand Down
3 changes: 0 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@ updates:
schedule:
interval: weekly
ignore:
# This package has unlisted versions on nuget.org that are not supported. Avoid them.
- dependency-name: dotnet-format
versions: ["6.x", "7.x", "8.x"]
- dependency-name: Microsoft.CodeAnalysis* # We intentionally target older VS versions.
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@
"omnisharp.enableEditorConfigSupport": true,
"omnisharp.enableRoslynAnalyzers": true,
"dotnet.completion.showCompletionItemsFromUnimportedNamespaces": true,
"dotnet.defaultSolution": "Microsoft.VisualStudio.Threading.sln"
"dotnet.defaultSolution": "Microsoft.VisualStudio.Threading.sln",
"editor.formatOnSave": true,
"[xml]": {
"editor.wordWrap": "off"
}
}
3 changes: 2 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<RepoRootPath>$(MSBuildThisFileDirectory)</RepoRootPath>
<BaseIntermediateOutputPath>$(RepoRootPath)obj\$([MSBuild]::MakeRelative($(RepoRootPath), $(MSBuildProjectDirectory)))\</BaseIntermediateOutputPath>
<BaseOutputPath Condition=" '$(BaseOutputPath)' == '' ">$(RepoRootPath)bin\$(MSBuildProjectName)\</BaseOutputPath>
<PackageOutputPath>$(RepoRootPath)bin\Packages\$(Configuration)\NuGet\</PackageOutputPath>
<LangVersion>11</LangVersion>
<LangVersion>12</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<AnalysisLevel>latest</AnalysisLevel>
Expand Down
3 changes: 3 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<!-- Workaround https://github.com/dotnet/wpf/issues/1718 -->
Expand All @@ -8,4 +9,6 @@
<!-- Avoid compile error about missing namespace when combining ImplicitUsings with .NET Framework target frameworks. -->
<Using Remove="System.Net.Http" Condition="'$(TargetFrameworkIdentifier)'=='.NETFramework'" />
</ItemGroup>

<Import Project="azure-pipelines\NuGetSbom.targets" Condition="'$(IsPackable)'!='false'" />
</Project>
13 changes: 7 additions & 6 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!-- https://learn.microsoft.com/nuget/consume-packages/central-package-management -->
<PropertyGroup>
Expand All @@ -24,7 +25,7 @@
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.CodeFix.Testing.XUnit" Version="$(CodefixTestingVersion)" />
<PackageVersion Include="Microsoft.Diagnostics.Runtime.Utilities" Version="$(MicrosoftDiagnosticsRuntimeVersion)" />
<PackageVersion Include="Microsoft.Diagnostics.Runtime" Version="$(MicrosoftDiagnosticsRuntimeVersion)" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="Microsoft.VisualStudio.Internal.MicroBuild.NonShipping" Version="$(MicroBuildVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.Interop" Version="17.4.33103.184" />
<PackageVersion Include="Microsoft.VisualStudio.Shell.15.0" Version="17.4.33103.184" />
Expand All @@ -34,16 +35,16 @@
<PackageVersion Include="Microsoft.Windows.CsWin32" Version="0.2.188-beta" />
<PackageVersion Include="Nullable" Version="1.3.1" />
<PackageVersion Include="System.Collections.Immutable" Version="6.0.0" />
<PackageVersion Include="System.Drawing.Common" Version="7.0.0" />
<PackageVersion Include="System.Drawing.Common" Version="8.0.0" />
<PackageVersion Include="System.Memory" Version="4.5.5" />
<PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageVersion Include="System.Threading.Tasks.Dataflow" Version="7.0.0" />
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageVersion Include="System.ValueTuple" Version="4.5.0" />
<PackageVersion Include="xunit" Version="2.5.3" />
<PackageVersion Include="xunit" Version="2.6.3" />
<PackageVersion Include="xunit.abstractions" Version="2.0.3" />
<PackageVersion Include="Xunit.Combinatorial" Version="1.5.25" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.3" />
<PackageVersion Include="Xunit.Combinatorial" Version="1.6.24" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.5" />
<PackageVersion Include="Xunit.SkippableFact" Version="1.4.13" />
<PackageVersion Include="Xunit.StaFact" Version="1.1.11" />
</ItemGroup>
Expand All @@ -56,6 +57,6 @@
<GlobalPackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.507" />
</ItemGroup>
<ItemGroup>
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion azure-pipelines/Install-NuGetPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ try {

if ($PSCmdlet.ShouldProcess($PackageId, 'nuget install')) {
$p = Start-Process $nugetPath $nugetArgs -NoNewWindow -Wait -PassThru
if ($p.ExitCode -ne 0) { throw }
if ($null -ne $p.ExitCode -and $p.ExitCode -ne 0) { throw }
}

# Provide the path to the installed package directory to our caller.
Expand Down
12 changes: 12 additions & 0 deletions azure-pipelines/NuGetSbom.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project>
<PropertyGroup>
<GenerateSBOMThisProject>true</GenerateSBOMThisProject>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);IncludeSbomInNupkg</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>

<Target Name="IncludeSbomInNupkg">
<ItemGroup>
<BuildOutputInPackage Include="@(SbomOutput)" />
</ItemGroup>
</Target>
</Project>
6 changes: 6 additions & 0 deletions azure-pipelines/artifacts/_stage_all.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ function Create-SymbolicLink {
} else {
cmd /c "mklink `"$Link`" `"$Target`"" | Out-Null
}

if ($LASTEXITCODE -ne 0) {
# Windows requires admin privileges to create symbolic links
# unless Developer Mode has been enabled.
throw "Failed to create symbolic link at $Link that points to $Target"
}
}

# Stage all artifacts
Expand Down
3 changes: 3 additions & 0 deletions azure-pipelines/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ jobs:
- template: dotnet.yml
parameters:
RunTests: ${{ parameters.RunTests }}
- script: dotnet format --verify-no-changes --no-restore
displayName: 💅 Verify formatted code
enabled: false

- job: macOS
condition: and(${{ parameters.includeMacOS }}, ne(variables['OptProf'], 'true'))
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines/variables/TeamName.ps1
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# This value is used to craft a \\cpvsbuild\drops path for symbol archival.
# This value is used as an input to the MicroBuild Insert VS task.
'VS IDE'
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.401",
"version": "8.0.100",
"rollForward": "patch",
"allowPrerelease": false
},
Expand Down
Empty file modified init.ps1
100644 → 100755
Empty file.
3 changes: 3 additions & 0 deletions settings.VisualStudio.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"textEditor.codeCleanup.profile": "profile1"
}
1 change: 1 addition & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!-- Include and reference README in nuget package, if a README is in the project directory. -->
<PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)AssemblyInfo.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ internal static async Task<ImmutableArray<string>> ReadAdditionalFilesAsync(IEnu
}

IEnumerable<TextDocument>? docs = from doc in additionalFiles.OrderBy(x => x.FilePath, StringComparer.Ordinal)
let fileName = Path.GetFileName(doc.Name)
where fileNamePattern.IsMatch(fileName)
select doc;
let fileName = Path.GetFileName(doc.Name)
where fileNamePattern.IsMatch(fileName)
select doc;
ImmutableArray<string>.Builder? result = ImmutableArray.CreateBuilder<string>();
foreach (TextDocument? doc in docs)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ private void AnalyzeNode(OperationAnalysisContext context)
if (firstArgExpression is IDelegateCreationOperation { Target: IAnonymousFunctionOperation anonFunc })
{
System.Collections.Generic.IEnumerable<IInvocationOperation>? problems = from invocation in anonFunc.Descendants().OfType<IInvocationOperation>()
let invokedSymbol = invocation.TargetMethod
where invokedSymbol is object && CommonInterest.SyncBlockingMethods.Any(m => m.Method.IsMatch(invokedSymbol))
select invocation;
let invokedSymbol = invocation.TargetMethod
where invokedSymbol is object && CommonInterest.SyncBlockingMethods.Any(m => m.Method.IsMatch(invokedSymbol))
select invocation;
IInvocationOperation? firstProblem = problems.FirstOrDefault();
if (firstProblem is object)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Microsoft.VisualStudio.Threading/AsyncLazy`1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ public class AsyncLazy<T>
private readonly object syncObject = new object();

/// <summary>
/// The unique instance identifier.
/// An optional means to avoid deadlocks when synchronous APIs are called that must invoke async methods in user code.
/// </summary>
private AsyncLocal<object>? recursiveFactoryCheck;
private readonly JoinableTaskFactory? jobFactory;

/// <summary>
/// An optional means to avoid deadlocks when synchronous APIs are called that must invoke async methods in user code.
/// The unique instance identifier.
/// </summary>
private readonly JoinableTaskFactory? jobFactory;
private AsyncLocal<object>? recursiveFactoryCheck;

/// <summary>
/// The function to invoke to produce the task.
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.VisualStudio.Threading/TplExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static void ApplyResultTo<T>(this Task<T> task, TaskCompletionSource<T> t
/// <param name="task">The task whose completion should be applied to another.</param>
/// <param name="tcs">The task that should receive the completion status.</param>
public static void ApplyResultTo<T>(this Task task, TaskCompletionSource<T> tcs)
//// where T : defaultable
//// where T : defaultable
{
Requires.NotNull(task, nameof(task));
Requires.NotNull(tcs, nameof(tcs));
Expand Down
1 change: 1 addition & 0 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove($(MSBuildThisFile), $(MSBuildThisFileDirectory)..))" />

Expand Down
1 change: 1 addition & 0 deletions test/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove($(MSBuildThisFile), $(MSBuildThisFileDirectory)..))" />
</Project>
4 changes: 2 additions & 2 deletions test/IsolatedTestHost/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="xunit.core" publicKeyToken="8d05b1bb7a6fdb6c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.5.3.0" newVersion="2.5.3.0" />
<bindingRedirect oldVersion="0.0.0.0-2.6.3.0" newVersion="2.6.3.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="xunit.execution.desktop" publicKeyToken="8d05b1bb7a6fdb6c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.5.3.0" newVersion="2.5.3.0" />
<bindingRedirect oldVersion="0.0.0.0-2.6.3.0" newVersion="2.6.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ public class Test : CSharpCodeFixVerifier<VSTHRD002UseJtfRunAnalyzer, EmptyCodeF
protected override IEnumerable<DiagnosticAnalyzer> GetDiagnosticAnalyzers()
{
IEnumerable<DiagnosticAnalyzer>? analyzers = from type in typeof(VSTHRD002UseJtfRunAnalyzer).Assembly.GetTypes()
where type.GetCustomAttributes(typeof(DiagnosticAnalyzerAttribute), true).Any()
select (DiagnosticAnalyzer?)Activator.CreateInstance(type) ?? throw Assumes.Fail("Unable to instantiate the analyzer");
where type.GetCustomAttributes(typeof(DiagnosticAnalyzerAttribute), true).Any()
select (DiagnosticAnalyzer?)Activator.CreateInstance(type) ?? throw Assumes.Fail("Unable to instantiate the analyzer");
return analyzers.ToImmutableArray();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public void SetReturnsBeforeInlinedContinuations()
.ContinueWith(
delegate
{
// Arrange to synchronously block the continuation until Set() has returned,
// which would deadlock if Set does not return until inlined continuations complete.
Assert.True(setReturned.Wait(AsyncDelay));
// Arrange to synchronously block the continuation until Set() has returned,
// which would deadlock if Set does not return until inlined continuations complete.
Assert.True(setReturned.Wait(AsyncDelay));
},
TaskContinuationOptions.ExecuteSynchronously);
this.evt.Set();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4512,7 +4512,7 @@ await Task.WhenAll(
await secondLockInQueue.SetAsync();
}),
secondLockObtained.Task);
});
});
}

private Task UncontestedTopLevelLocksAllocFreeHelperAsync(Func<AsyncReaderWriterLock.Awaitable> locker, bool yieldingLock)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ public void GetHangReportProducesDgmlWithNamedJoinableCollections()
this.Logger.WriteLine(report.Content);
var dgml = XDocument.Parse(report.Content);
IEnumerable<string>? collectionLabels = from node in dgml.Root!.Element(XName.Get("Nodes", DgmlNamespace))!.Elements()
where node.Attribute(XName.Get("Category"))?.Value == "Collection"
select node.Attribute(XName.Get("Label"))?.Value;
where node.Attribute(XName.Get("Category"))?.Value == "Collection"
select node.Attribute(XName.Get("Label"))?.Value;
Assert.Contains(collectionLabels, label => label == jtcName);
return Task.CompletedTask;
});
Expand All @@ -433,8 +433,8 @@ public void GetHangReportProducesDgmlWithMethodNameRequestingMainThread()
this.Logger.WriteLine(report.Content);
var dgml = XDocument.Parse(report.Content);
IEnumerable<string>? collectionLabels = from node in dgml.Root!.Element(XName.Get("Nodes", DgmlNamespace))!.Elements()
where node.Attribute(XName.Get("Category"))?.Value == "Task"
select node.Attribute(XName.Get("Label"))?.Value;
where node.Attribute(XName.Get("Category"))?.Value == "Task"
select node.Attribute(XName.Get("Label"))?.Value;
Assert.Contains(collectionLabels, label => label.Contains(nameof(this.GetHangReportProducesDgmlWithMethodNameRequestingMainThread)));
}

Expand All @@ -456,8 +456,8 @@ public void GetHangReportProducesDgmlWithMethodNameYieldingOnMainThread()
this.Logger.WriteLine(report.Content);
var dgml = XDocument.Parse(report.Content);
IEnumerable<string>? collectionLabels = from node in dgml.Root!.Element(XName.Get("Nodes", DgmlNamespace))!.Elements()
where node.Attribute(XName.Get("Category"))?.Value == "Task"
select node.Attribute(XName.Get("Label"))?.Value;
where node.Attribute(XName.Get("Category"))?.Value == "Task"
select node.Attribute(XName.Get("Label"))?.Value;
Assert.Contains(collectionLabels, label => label.Contains(nameof(this.YieldingMethodAsync)));
});
}
Expand Down

0 comments on commit 9065e6e

Please sign in to comment.