diff --git a/src/lib/PnP.Framework/PnP.Framework.csproj b/src/lib/PnP.Framework/PnP.Framework.csproj index 49eebe7b9..e730e549e 100644 --- a/src/lib/PnP.Framework/PnP.Framework.csproj +++ b/src/lib/PnP.Framework/PnP.Framework.csproj @@ -2,7 +2,7 @@ <PropertyGroup> <TargetFrameworks>netstandard2.0;net8.0;net9.0</TargetFrameworks> - <LangVersion>10.0</LangVersion> + <LangVersion>13.0</LangVersion> <RootNamespace>PnP.Framework</RootNamespace> <AssemblyName>PnP.Framework</AssemblyName> <Version>1.17.0</Version> @@ -250,6 +250,16 @@ <PackageReference Include="Portable.Xaml" Version="0.26.0" /> </ItemGroup> + <ItemGroup> + <PackageReference Include="Backport.System.Threading.Lock" Version="3.1.4"> + <PrivateAssets>all</PrivateAssets> + <IncludeAssets>analyzers</IncludeAssets> + </PackageReference> + <Using Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net9.0'))" Alias="Lock" Include="System.Threading.Lock" /> + <Using Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net9.0'))" Alias="Lock" Include="Backport.System.Threading.Lock" /> + <Using Alias="LockFactory" Include="Backport.System.Threading.LockFactory" /> + </ItemGroup> + <ItemGroup Condition="'$(PnPCoreSdkPath)' != ''"> <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.1.1" Condition="'$(TargetFramework)' == 'netstandard2.0'" /> <Reference Include="PnP.Core" Condition="'$(TargetFramework)' == 'netstandard2.0'"> diff --git a/src/lib/PnP.Framework/TimerJobs/Utilities/SiteEnumeration.cs b/src/lib/PnP.Framework/TimerJobs/Utilities/SiteEnumeration.cs index ed98db2f7..301c2bf34 100644 --- a/src/lib/PnP.Framework/TimerJobs/Utilities/SiteEnumeration.cs +++ b/src/lib/PnP.Framework/TimerJobs/Utilities/SiteEnumeration.cs @@ -16,7 +16,7 @@ internal class SiteEnumeration #region Singleton implementation // Singleton variables private static volatile SiteEnumeration instance; - private static readonly object syncRoot = new Object(); + private static readonly Lock syncRoot = LockFactory.Create(); // Singleton private constructor private SiteEnumeration() { } diff --git a/src/lib/PnP.Framework/Utilities/Cache/InMemoryCacheProvider.cs b/src/lib/PnP.Framework/Utilities/Cache/InMemoryCacheProvider.cs index 612eb5f01..cec9ba99a 100644 --- a/src/lib/PnP.Framework/Utilities/Cache/InMemoryCacheProvider.cs +++ b/src/lib/PnP.Framework/Utilities/Cache/InMemoryCacheProvider.cs @@ -8,7 +8,7 @@ namespace PnP.Framework.Utilities.Cache public class InMemoryCacheProvider : ICacheProvider { private readonly Dictionary<string, object> _cacheStore = new Dictionary<string, object>(); - private readonly object _syncRoot = new object(); + private readonly Lock _syncRoot = LockFactory.Create(); /// <summary> /// Gets an item from the cache diff --git a/src/lib/PnP.Framework/Utilities/Cache/MsalCacheHelperUtility.cs b/src/lib/PnP.Framework/Utilities/Cache/MsalCacheHelperUtility.cs index 75a409832..4120ac8ce 100644 --- a/src/lib/PnP.Framework/Utilities/Cache/MsalCacheHelperUtility.cs +++ b/src/lib/PnP.Framework/Utilities/Cache/MsalCacheHelperUtility.cs @@ -9,7 +9,7 @@ public class MsalCacheHelperUtility { private static MsalCacheHelper MsalCacheHelper; - private static readonly object ObjectLock = new(); + private static readonly Lock ObjectLock = LockFactory.Create(); private static class Config {