This commit is contained in:
Jan Jones 2024-10-14 11:22:18 +02:00 коммит произвёл GitHub
Родитель faba442747
Коммит 8c4254387d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
7 изменённых файлов: 54 добавлений и 11 удалений

Просмотреть файл

@ -63,7 +63,6 @@
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="$(_MicrosoftExtensionsPackageVersion)" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="$(_MicrosoftExtensionsPackageVersion)" />
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="$(_MicrosoftExtensionsPackageVersion)" />
<PackageVersion Include="Microsoft.Extensions.NonCapturingTimer.Sources" Version="5.0.0-preview.4.20205.1" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="$(_MicrosoftExtensionsPackageVersion)" />
<PackageVersion Include="Microsoft.Extensions.ObjectPool" Version="$(MicrosoftExtensionsObjectPoolPackageVersion)" />
<PackageVersion Include="Microsoft.Internal.VisualStudio.Shell.Framework" Version="$(_MicrosoftVisualStudioShellPackagesVersion)" />

Просмотреть файл

@ -67,7 +67,6 @@
</packageSource>
<packageSource key="dotnet6-transport">
<package pattern="microsoft.net.sdk.razor" />
<package pattern="microsoft.extensions.noncapturingtimer.sources" />
</packageSource>
<packageSource key="dotnet8">
<package pattern="microsoft.*" />

Просмотреть файл

@ -1,4 +1,7 @@
using System;
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.AspNetCore.Razor.Language;

Просмотреть файл

@ -7,18 +7,12 @@
<IsShippingPackage>false</IsShippingPackage>
<ExcludeFromSourceOnlyBuild>true</ExcludeFromSourceOnlyBuild>
<IsPackable Condition="'$(OS)' != 'Windows_NT'">false</IsPackable>
<!--
The NonCapturingTimer package is a source package, and the source files in there don't conform to our header
poilcy, so we have to ignore that error code for this project.
-->
<NoWarn>$(NoWarn);IDE0073</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
<PackageReference Include="Microsoft.CodeAnalysis.ExternalAccess.Razor" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" />
<PackageReference Include="Microsoft.Extensions.NonCapturingTimer.Sources" PrivateAssets="all" />
<PackageReference Include="Microsoft.VisualStudio.LanguageServer.Protocol" />
<PackageReference Include="Microsoft.VisualStudio.LanguageServer.Protocol.Extensions" />
<PackageReference Include="Microsoft.VisualStudio.LanguageServer.Protocol.Internal" />

Просмотреть файл

@ -0,0 +1,44 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
// https://github.com/dotnet/runtime/blob/11c86d8acba2f248b3afb5e8594f5f41ceebf098/src/libraries/Common/src/Extensions/NonCapturingTimer/NonCapturingTimer.cs
using System;
using System.Threading;
namespace Microsoft.Extensions.Internal;
// A convenience API for interacting with System.Threading.Timer in a way
// that doesn't capture the ExecutionContext. We should be using this (or equivalent)
// everywhere we use timers to avoid rooting any values stored in asynclocals.
internal static class NonCapturingTimer
{
public static Timer Create(TimerCallback callback, object state, TimeSpan dueTime, TimeSpan period)
{
if (callback is null)
{
throw new ArgumentNullException(nameof(callback));
}
// Don't capture the current ExecutionContext and its AsyncLocals onto the timer
var restoreFlow = false;
try
{
if (!ExecutionContext.IsFlowSuppressed())
{
ExecutionContext.SuppressFlow();
restoreFlow = true;
}
return new Timer(callback, state, dueTime, period);
}
finally
{
// Restore the current ExecutionContext
if (restoreFlow)
{
ExecutionContext.RestoreFlow();
}
}
}
}

Просмотреть файл

@ -1,4 +1,7 @@
using System.Runtime.Serialization;
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Runtime.Serialization;
using Microsoft.CodeAnalysis.Razor.Formatting;
using Microsoft.CodeAnalysis.Razor.Settings;

Просмотреть файл

@ -1,4 +1,5 @@
// Licensed under the MIT license. See License.txt in the project root for license information.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.Buffers;