Skip to content

Commit

Permalink
revert discard
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelbannov committed Oct 12, 2020
1 parent 5e11f96 commit c622be8
Show file tree
Hide file tree
Showing 479 changed files with 3,565 additions and 3,563 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,6 @@ dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

# Default severity for analyzer diagnostics with category 'Style'
dotnet_analyzer_diagnostic.category-Style.severity = silent
6 changes: 3 additions & 3 deletions common/ASC.Api.Core/Auth/ConfirmAuthHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ protected override Task<AuthenticateResult> HandleAuthenticateAsync()
{
if (emailValidationKeyModel.UiD.HasValue && !emailValidationKeyModel.UiD.Equals(Guid.Empty))
{
_ = SecurityContext.AuthenticateMe(emailValidationKeyModel.UiD.Value, claims);
SecurityContext.AuthenticateMe(emailValidationKeyModel.UiD.Value, claims);
}
else
{
_ = SecurityContext.AuthenticateMe(ASC.Core.Configuration.Constants.CoreSystem, claims);
SecurityContext.AuthenticateMe(ASC.Core.Configuration.Constants.CoreSystem, claims);
}
}
else
{
_ = SecurityContext.AuthenticateMe(SecurityContext.CurrentAccount, claims);
SecurityContext.AuthenticateMe(SecurityContext.CurrentAccount, claims);
}
}

Expand Down
4 changes: 2 additions & 2 deletions common/ASC.Api.Core/Core/ApiContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public void AuthByClaim()
var id = HttpContextAccessor.HttpContext.User.Claims.FirstOrDefault(r => r.Type == ClaimTypes.Sid);
if (Guid.TryParse(id?.Value, out var userId))
{
_ = SecurityContext.AuthenticateMe(userId);
SecurityContext.AuthenticateMe(userId);
}
}
}
Expand Down Expand Up @@ -275,7 +275,7 @@ public static DIHelper AddApiContextService(this DIHelper services)
{
if (services.TryAddScoped<ApiContext>())
{
_ = services
services
.AddTenantManagerService()
.AddSecurityContextService();
}
Expand Down
32 changes: 16 additions & 16 deletions common/ASC.Api.Core/Core/BaseStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public BaseStartup(IConfiguration configuration, IHostEnvironment hostEnvironmen

public virtual void ConfigureServices(IServiceCollection services)
{
_ = services.AddHttpContextAccessor();
services.AddHttpContextAccessor();

var diHelper = new DIHelper(services);

if (AddControllers)
{
_ = services.AddControllers()
services.AddControllers()
.AddXmlSerializerFormatters()
.AddJsonOptions(options =>
{
Expand All @@ -62,7 +62,7 @@ public virtual void ConfigureServices(IServiceCollection services)
});
}

_ = diHelper
diHelper
.AddCultureMiddleware()
.AddIpSecurityFilter()
.AddPaymentFilter()
Expand All @@ -85,44 +85,44 @@ public virtual void ConfigureServices(IServiceCollection services)
config.OutputFormatters.Add(new XmlOutputFormatter());
});

_ = diHelper.AddCookieAuthHandler();
diHelper.AddCookieAuthHandler();
var authBuilder = services.AddAuthentication("cookie")
.AddScheme<AuthenticationSchemeOptions, CookieAuthHandler>("cookie", a => { });

if (ConfirmAddScheme)
{
_ = authBuilder.AddScheme<AuthenticationSchemeOptions, ConfirmAuthHandler>("confirm", a => { });
authBuilder.AddScheme<AuthenticationSchemeOptions, ConfirmAuthHandler>("confirm", a => { });
}

if (LogParams != null)
{
_ = diHelper.AddNLogManager(LogParams);
diHelper.AddNLogManager(LogParams);
}

_ = services.AddAutofac(Configuration, HostEnvironment.ContentRootPath);
services.AddAutofac(Configuration, HostEnvironment.ContentRootPath);
}

public virtual void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
_ = app.UseForwardedHeaders(new ForwardedHeadersOptions
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});

_ = app.UseRouting();
app.UseRouting();

_ = app.UseAuthentication();
app.UseAuthentication();

_ = app.UseAuthorization();
app.UseAuthorization();

_ = app.UseCultureMiddleware();
app.UseCultureMiddleware();

_ = app.UseDisposeMiddleware();
app.UseDisposeMiddleware();

_ = app.UseEndpoints(endpoints =>
app.UseEndpoints(endpoints =>
{
_ = endpoints.MapControllers();
_ = endpoints.MapCustom();
endpoints.MapControllers();
endpoints.MapCustom();
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions common/ASC.Api.Core/Middleware/ResponseWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public override void OnResultExecuting(ResultExecutingContext context)
{
if (context.Result is ObjectResult result)
{
_ = context.HttpContext.Items.TryGetValue("TotalCount", out var total);
_ = context.HttpContext.Items.TryGetValue("Count", out var count);
context.HttpContext.Items.TryGetValue("TotalCount", out var total);
context.HttpContext.Items.TryGetValue("Count", out var count);
result.Value = new SuccessApiResponse((HttpStatusCode)context.HttpContext.Response.StatusCode, result.Value, (long?)total, (int?)count);
}

Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Api.Core/Model/EmployeeWraperFull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public EmployeeWraperFull GetFull(UserInfo userInfo)
IsSSO = userInfo.IsSSO()
};

_ = Init(result, userInfo);
Init(result, userInfo);

if (userInfo.Sex.HasValue)
{
Expand Down
10 changes: 5 additions & 5 deletions common/ASC.Common/Caching/AscCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static void OnClearCache()

foreach (var k in keys)
{
_ = MemoryCache.Default.Remove(k);
MemoryCache.Default.Remove(k);
}
}
}
Expand Down Expand Up @@ -96,7 +96,7 @@ public void Insert(string key, object value, DateTime absolutExpiration)
public void Remove(string key)
{
var cache = GetCache();
_ = cache.Remove(key);
cache.Remove(key);
}

public void Remove(Regex pattern)
Expand All @@ -108,7 +108,7 @@ public void Remove(Regex pattern)
var keys = copy.Select(p => p.Key).Where(k => pattern.IsMatch(k)).ToArray();
foreach (var key in keys)
{
_ = cache.Remove(key);
cache.Remove(key);
}
}

Expand Down Expand Up @@ -146,10 +146,10 @@ public void HashSet<T>(string key, string field, T value)
}
else if (dic != null)
{
_ = dic.Remove(field);
dic.Remove(field);
if (dic.Count == 0)
{
_ = cache.Remove(key);
cache.Remove(key);
}
else
{
Expand Down
10 changes: 5 additions & 5 deletions common/ASC.Common/Caching/KafkaCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void Publish(T obj, CacheNotifyAction cacheNotifyAction)
}
};

_ = Producer.ProduceAsync(channelName, message);
Producer.ProduceAsync(channelName, message);
}
catch (ProduceException<Null, string> e)
{
Expand Down Expand Up @@ -165,7 +165,7 @@ private string GetChannelName(CacheNotifyAction cacheNotifyAction)

public void Unsubscribe(CacheNotifyAction action)
{
_ = Cts.TryGetValue(GetChannelName(action), out var source);
Cts.TryGetValue(GetChannelName(action), out var source);
if (source != null)
{
source.Cancel();
Expand Down Expand Up @@ -223,14 +223,14 @@ public void Subscribe(Action<T> onchange, CacheNotifyAction notifyAction)
if (onchange != null)
{
var key = GetKey(notifyAction);
_ = actions.TryAdd(key, new List<Action<T>>());
actions.TryAdd(key, new List<Action<T>>());
actions[key].Add(onchange);
}
}

public void Unsubscribe(CacheNotifyAction action)
{
_ = actions.Remove(GetKey(action));
actions.Remove(GetKey(action));
}

private string GetKey(CacheNotifyAction cacheNotifyAction)
Expand All @@ -243,7 +243,7 @@ public static class KafkaExtention
{
public static DIHelper AddKafkaService(this DIHelper services)
{
_ = services.TryAddSingleton(typeof(ICacheNotify<>), typeof(KafkaCache<>));
services.TryAddSingleton(typeof(ICacheNotify<>), typeof(KafkaCache<>));

return services;
}
Expand Down
8 changes: 4 additions & 4 deletions common/ASC.Common/DIHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public DIHelper AddSingleton<TService, TImplementation>() where TService : class
if (!Singleton.Contains(serviceName))
{
Singleton.Add(serviceName);
_ = ServiceCollection.AddSingleton<TService, TImplementation>();
ServiceCollection.AddSingleton<TService, TImplementation>();
}

return this;
Expand Down Expand Up @@ -155,7 +155,7 @@ public DIHelper Configure<TOptions>(Action<TOptions> configureOptions) where TOp
if (!Configured.Contains(serviceName))
{
Configured.Add(serviceName);
_ = ServiceCollection.Configure(configureOptions);
ServiceCollection.Configure(configureOptions);
}

return this;
Expand All @@ -166,7 +166,7 @@ private void AddToConfigured<TOptions>(string type, Action<TOptions> action) whe
if (!Configured.Contains(type))
{
Configured.Add(type);
_ = ServiceCollection.Configure(action);
ServiceCollection.Configure(action);
}
}

Expand Down Expand Up @@ -201,7 +201,7 @@ public DIHelper Configure<TOptions>(string name, Action<TOptions> configureOptio
if (!Configured.Contains(serviceName))
{
Configured.Add(serviceName);
_ = ServiceCollection.Configure(name, configureOptions);
ServiceCollection.Configure(name, configureOptions);
}

return this;
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Common/Data/StreamExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static byte[] GetCorrectBuffer(this Stream stream)
using var mem = stream.GetBuffered();
var buffer = new byte[mem.Length];
mem.Position = 0;
_ = mem.Read(buffer, 0, buffer.Length);
mem.Read(buffer, 0, buffer.Length);
return buffer;
}
}
6 changes: 3 additions & 3 deletions common/ASC.Common/DependencyInjection/AutofacExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ public static IContainer AddAutofac(this IServiceCollection services, IConfigura
var config = new ConfigurationBuilder();
if (p.Item1)
{
_ = config.SetBasePath(configuration["pathToConf"]);
config.SetBasePath(configuration["pathToConf"]);
}
_ = config.AddJsonFile(p.Item2);
config.AddJsonFile(p.Item2);

var root = config.Build();
var module = new ConfigurationModule(root);
_ = builder.RegisterModule(module);
builder.RegisterModule(module);

if (p.Item2 == "autofac.products.json")
{
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Common/Logging/EFLoggerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public static DIHelper AddLoggerService(this DIHelper services)
{
if (services.TryAddScoped<EFLoggerFactory>())
{
_ = services.TryAddScoped<EFLoggerProvider>();
services.TryAddScoped<EFLoggerProvider>();
}

return services;
Expand Down
16 changes: 8 additions & 8 deletions common/ASC.Common/Logging/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public class Log : ILog
{
static Log()
{
_ = XmlConfigurator.Configure(log4net.LogManager.GetRepository(Assembly.GetCallingAssembly()));
XmlConfigurator.Configure(log4net.LogManager.GetRepository(Assembly.GetCallingAssembly()));
}

private readonly log4net.ILog loger;
Expand Down Expand Up @@ -877,23 +877,23 @@ public static class StudioNotifyHelperExtension
{
const string baseName = "ASC";
var baseSqlName = $"{baseName}.SQL";
_ = services.Configure<T>(r => r.Name = baseName);
_ = services.Configure<T>(baseName, r => r.Name = baseName);
_ = services.Configure<T>(baseSqlName, r => r.Name = baseSqlName);
services.Configure<T>(r => r.Name = baseName);
services.Configure<T>(baseName, r => r.Name = baseName);
services.Configure<T>(baseSqlName, r => r.Name = baseSqlName);

foreach (var l in additionalLoggers)
{
_ = services.Configure<T>(l, r => r.Name = l);
services.Configure<T>(l, r => r.Name = l);
}

_ = services.TryAddSingleton(typeof(IOptionsMonitor<ILog>), typeof(LogManager<T>));
services.TryAddSingleton(typeof(IOptionsMonitor<ILog>), typeof(LogManager<T>));
return services;
}

public static DIHelper AddNLogManager(this DIHelper services, params string[] additionalLoggers)
{
_ = services.TryAddSingleton<IConfigureNamedOptions<LogNLog>, ConfigureLogNLog>();
_ = services.TryAddSingleton<IConfigureOptions<LogNLog>, ConfigureLogNLog>();
services.TryAddSingleton<IConfigureNamedOptions<LogNLog>, ConfigureLogNLog>();
services.TryAddSingleton<IConfigureOptions<LogNLog>, ConfigureLogNLog>();
return services.AddLogManager<LogNLog>(additionalLoggers);
}
}
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Common/Logging/SelfCleaningAppender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private static int GetCleanPeriod()

if (repo != null && repo.Properties.GetKeys().Contains(key))
{
_ = int.TryParse(repo.Properties[key].ToString(), out value);
int.TryParse(repo.Properties[key].ToString(), out value);
}

_cleanPeriod = value;
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Common/Logging/SelfCleaningTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private static int GetCleanPeriod()

if (variable != null && !string.IsNullOrEmpty(variable.Text))
{
_ = int.TryParse(variable.Text, out value);
int.TryParse(variable.Text, out value);
}
}

Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Common/Security/Cryptography/InstanceCrypto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static class InstanceCryptoExtension
{
public static DIHelper AddInstanceCryptoService(this DIHelper services)
{
_ = services.TryAddSingleton<InstanceCrypto>();
services.TryAddSingleton<InstanceCrypto>();

return services
.AddMachinePseudoKeysService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static class MachinePseudoKeysExtension
{
public static DIHelper AddMachinePseudoKeysService(this DIHelper services)
{
_ = services.TryAddSingleton<MachinePseudoKeys>();
services.TryAddSingleton<MachinePseudoKeys>();

return services;
}
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Common/Security/Cryptography/PasswordHasher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static class PasswordHasherExtension
{
public static DIHelper AddPasswordHasherService(this DIHelper services)
{
_ = services.TryAddSingleton<PasswordHasher>();
services.TryAddSingleton<PasswordHasher>();

return services.AddMachinePseudoKeysService();
}
Expand Down
Loading

0 comments on commit c622be8

Please sign in to comment.