Skip to content

Commit

Permalink
VCST-1550: Remove obsolete code, fix warnings and vulnerabilities (#2828
Browse files Browse the repository at this point in the history
)
  • Loading branch information
artem-dudarev authored Aug 27, 2024
1 parent 32a05dd commit 7548397
Show file tree
Hide file tree
Showing 93 changed files with 366 additions and 4,692 deletions.
4 changes: 4 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
<NoWarn>$(NoWarn);S3875;S4457</NoWarn>
</PropertyGroup>

<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup Condition="'$(MSBuildProjectName.Contains(Tests))' == false">
<!-- Nuget Package Details -->
<PackageVersion>$(VersionPrefix)</PackageVersion>
Expand Down
1 change: 1 addition & 0 deletions VirtoCommerce.Platform.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=UI/@EntryIndexedValue">UI</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=15b5b1f1_002D457c_002D4ca6_002Db278_002D5615aedc07d3/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static readonly fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=236f7aa5_002D7b06_002D43ca_002Dbf2a_002D9b31bfcff09a/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Any" AccessRightKinds="Private" Description="Constant fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="CONSTANT_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EPredefinedNamingRulesToUserRulesUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=auditable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=hangfire/@EntryIndexedValue">True</s:Boolean>
Expand Down
10 changes: 0 additions & 10 deletions module.ignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Azure.Core.dll
Azure.Data.AppConfiguration.dll
Azure.Identity.dll
Azure.Messaging.EventGrid.dll
Azure.Security.KeyVault.Secrets.dll
Dapper.dll
DnsClient.dll
Expand All @@ -20,13 +19,6 @@ Hangfire.SqlServer.dll
Humanizer.dll
MessagePack.Annotations.dll
MessagePack.dll
Microsoft.AI.DependencyCollector.dll
Microsoft.AI.EventCounterCollector.dll
Microsoft.AI.PerfCounterCollector.dll
Microsoft.AI.ServerTelemetryChannel.dll
Microsoft.AI.WindowsServer.dll
Microsoft.ApplicationInsights.AspNetCore.dll
Microsoft.ApplicationInsights.dll
Microsoft.AspNetCore.Authentication.JwtBearer.dll
Microsoft.AspNetCore.Authentication.OpenIdConnect.dll
Microsoft.AspNetCore.Authorization.dll
Expand Down Expand Up @@ -84,7 +76,6 @@ Microsoft.Extensions.Http.Polly.dll
Microsoft.Extensions.Identity.Core.dll
Microsoft.Extensions.Identity.Stores.dll
Microsoft.Extensions.Logging.Abstractions.dll
Microsoft.Extensions.Logging.ApplicationInsights.dll
Microsoft.Extensions.Logging.AzureAppServices.dll
Microsoft.Extensions.Options.dll
Microsoft.Extensions.PlatformAbstractions.dll
Expand Down Expand Up @@ -165,7 +156,6 @@ System.Composition.Runtime.dll
System.Composition.TypedParts.dll
System.Configuration.ConfigurationManager.dll
System.Data.SqlClient.dll
System.Diagnostics.PerformanceCounter.dll
System.Drawing.Common.dll
System.IdentityModel.Tokens.Jwt.dll
System.IO.Abstractions.dll
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
using System;

namespace VirtoCommerce.Platform.Redis
{
public class RedisCachingOptions
{
public string ChannelName { get; set; }

[Obsolete("Use Redis connection string parameters for retry policy configration")]
public int BusRetryCount { get; set; } = 3;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<noWarn>1591</noWarn>
<noWarn>1591;NU5048</noWarn>
<OutputType>Library</OutputType>
<IsPackable>True</IsPackable>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static async Task<IList<TItem>> GetOrLoadByIdsAsync<TItem>(

if (!TryGetByIds<TItem>(memoryCache, keyPrefix, ids, out var result))
{
using (await AsyncLock.GetLockByKey(keyPrefix).GetReleaserAsync())
using (await AsyncLock.GetLockByKey(keyPrefix).LockAsync())
{
if (!TryGetByIds(memoryCache, keyPrefix, ids, out result))
{
Expand Down Expand Up @@ -96,7 +96,7 @@ public static async Task<TItem> GetOrCreateExclusiveAsync<TItem>(this IMemoryCac
{
if (!cache.TryGetValue(key, out var result))
{
using (await AsyncLock.GetLockByKey(key).GetReleaserAsync())
using (await AsyncLock.GetLockByKey(key).LockAsync())
{
if (!cache.TryGetValue(key, out result))
{
Expand Down
19 changes: 8 additions & 11 deletions src/VirtoCommerce.Platform.Core/Common/AsyncLock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public AsyncLock(string key)
_key = key;
}

private static readonly Dictionary<string, RefCounted<SemaphoreSlim>> _semaphoreSlims = new Dictionary<string, RefCounted<SemaphoreSlim>>();
private static readonly Dictionary<string, RefCounted<SemaphoreSlim>> _semaphoreSlims = new();

private SemaphoreSlim GetOrCreate(string key)
private static SemaphoreSlim GetOrCreate(string key)
{
RefCounted<SemaphoreSlim> item;
lock (_semaphoreSlims)
Expand All @@ -41,22 +41,19 @@ public static AsyncLock GetLockByKey(string key)
return new AsyncLock(key);
}

// TODO: Rename to LockAsync after resolving problem with backward compatibility
// in the modules (look on this ticket https://virtocommerce.atlassian.net/browse/PT-3548)
public async Task<IDisposable> GetReleaserAsync()
[Obsolete("Use LockAsync()", DiagnosticId = "VC0009", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions")]
public Task<IDisposable> GetReleaserAsync()
{
await GetOrCreate(_key).WaitAsync().ConfigureAwait(false);
return new Releaser(_key);
return LockAsync();
}

[Obsolete("Left for backward compatibility. Use GetReleaserAsync")]
public async Task<Releaser> LockAsync()
public async Task<IDisposable> LockAsync()
{
await GetOrCreate(_key).WaitAsync().ConfigureAwait(false);
return new Releaser(_key);
}

public struct Releaser : IDisposable
public readonly struct Releaser : IDisposable
{
private readonly string _key;

Expand Down Expand Up @@ -90,7 +87,7 @@ public RefCounted(T value)
}

public int RefCount { get; set; }
public T Value { get; private set; }
public T Value { get; }
}
}
}
10 changes: 1 addition & 9 deletions src/VirtoCommerce.Platform.Core/Common/MigrationName.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
using System;

namespace VirtoCommerce.Platform.Core.Common
{
public static class MigrationName
{
/// <summary>
/// It's important thing of naming for correct migration to v.3
/// The migration of update from v.2 should be apply at the first
/// The migration from v.2 should be applied first
/// </summary>
/// <param name="moduleName"></param>
/// <returns>20000000000000_UpdateModuleNameV2</returns>
public static string GetUpdateV2MigrationName(string moduleName)
{
return $"20000000000000_Update{moduleName.Replace(".", "").Replace("VirtoCommerce", "")}V2";
}

[Obsolete("use GetUpdateV2MigrationName")]
public static string GetUpdateV2MigrationNameByOwnerName(string moduleName, string ownerName)
{
return GetUpdateV2MigrationName(moduleName);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using System;
using System.Threading.Tasks;
using VirtoCommerce.Platform.Core.GenericCrud;

namespace VirtoCommerce.Platform.Core.DynamicProperties
{
public interface IDynamicPropertyDictionaryItemsSearchService : ISearchService<DynamicPropertyDictionaryItemSearchCriteria, DynamicPropertyDictionaryItemSearchResult, DynamicPropertyDictionaryItem>
{
[Obsolete("Use SearchAsync()", DiagnosticId = "VC0005", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")]
Task<DynamicPropertyDictionaryItemSearchResult> SearchDictionaryItemsAsync(DynamicPropertyDictionaryItemSearchCriteria criteria);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using System;
using System.Threading.Tasks;
using VirtoCommerce.Platform.Core.GenericCrud;

namespace VirtoCommerce.Platform.Core.DynamicProperties
{
public interface IDynamicPropertySearchService : ISearchService<DynamicPropertySearchCriteria, DynamicPropertySearchResult, DynamicProperty>
{
[Obsolete("Use SearchAsync()", DiagnosticId = "VC0005", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")]
Task<DynamicPropertySearchResult> SearchDynamicPropertiesAsync(DynamicPropertySearchCriteria criteria);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -38,11 +37,4 @@ public static async Task<TModel> GetByIdAsync<TModel>(this ICrudService<TModel>

return entities?.FirstOrDefault();
}

[Obsolete("Use GetAsync() or GetNoCloneAsync()")]
public static Task<IList<TModel>> GetByIdsAsync<TModel>(this ICrudService<TModel> crudService, IList<string> ids, string responseGroup = null, bool clone = true)
where TModel : Entity
{
return crudService.GetAsync(ids, responseGroup, clone);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -45,24 +44,6 @@ public static Task<TResult> SearchNoCloneAsync<TCriteria, TResult, TModel>(this
return searchService.SearchAsync(searchCriteria, clone: false);
}

[Obsolete("Use SearchBatchesNoCloneAsync()", DiagnosticId = "VC0005", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")]
public static IAsyncEnumerable<TResult> SearchBatchesNoClone<TCriteria, TResult, TModel>(this ISearchService<TCriteria, TResult, TModel> searchService, TCriteria searchCriteria)
where TCriteria : SearchCriteriaBase
where TResult : GenericSearchResult<TModel>
where TModel : Entity, ICloneable
{
return searchService.SearchBatchesNoCloneAsync(searchCriteria);
}

[Obsolete("Use SearchBatchesAsync()", DiagnosticId = "VC0005", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")]
public static IAsyncEnumerable<TResult> SearchBatches<TCriteria, TResult, TModel>(this ISearchService<TCriteria, TResult, TModel> searchService, TCriteria searchCriteria, bool clone = true)
where TCriteria : SearchCriteriaBase
where TResult : GenericSearchResult<TModel>
where TModel : Entity, ICloneable
{
return searchService.SearchBatchesAsync(searchCriteria, clone);
}

/// <summary>
/// Returns data from the cache without cloning. This consumes less memory, but the returned data must not be modified.
/// </summary>
Expand Down
16 changes: 1 addition & 15 deletions src/VirtoCommerce.Platform.Core/Modularity/ModuleAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,11 @@ public sealed class ModuleAttribute : Attribute
/// <value>The name of the module.</value>
public string ModuleName { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the module should be loaded at startup.
/// </summary>
/// When <see langword="true"/> (default value), it indicates that this module should be loaded at startup.
/// Otherwise you should explicitly load this module on demand.
/// <value>A <see cref="bool"/> value.</value>
[Obsolete("StartupLoaded has been replaced by the OnDemand property.")]
public bool StartupLoaded
{
get { return !OnDemand; }
set { OnDemand = !value; }
}


/// <summary>
/// Gets or sets the value indicating whether the module should be loaded OnDemand.
/// </summary>
/// When <see langword="false"/> (default value), it indicates the module should be loaded as soon as it's dependencies are satisfied.
/// Otherwise you should explicitily load this module via the ModuleManager.
/// Otherwise, you should explicitly load this module via the ModuleManager.
public bool OnDemand { get; set; }
}
}

This file was deleted.

11 changes: 0 additions & 11 deletions src/VirtoCommerce.Platform.Core/Notifications/IEmailSender.cs

This file was deleted.

Loading

0 comments on commit 7548397

Please sign in to comment.