* Used compound assignment * -||- * -||-pull/1923/head
| @@ -31,7 +31,7 @@ namespace _02_commands_framework.Modules | |||||
| [Command("userinfo")] | [Command("userinfo")] | ||||
| public async Task UserInfoAsync(IUser user = null) | public async Task UserInfoAsync(IUser user = null) | ||||
| { | { | ||||
| user = user ?? Context.User; | |||||
| user ??= Context.User; | |||||
| await ReplyAsync(user.ToString()); | await ReplyAsync(user.ToString()); | ||||
| } | } | ||||
| @@ -116,7 +116,7 @@ namespace Discord.Commands | |||||
| builder.AddAliases(alias.Aliases); | builder.AddAliases(alias.Aliases); | ||||
| break; | break; | ||||
| case GroupAttribute group: | case GroupAttribute group: | ||||
| builder.Name = builder.Name ?? group.Prefix; | |||||
| builder.Name ??= group.Prefix; | |||||
| builder.Group = group.Prefix; | builder.Group = group.Prefix; | ||||
| builder.AddAliases(group.Prefix); | builder.AddAliases(group.Prefix); | ||||
| break; | break; | ||||
| @@ -158,7 +158,7 @@ namespace Discord.Commands | |||||
| case CommandAttribute command: | case CommandAttribute command: | ||||
| builder.AddAliases(command.Text); | builder.AddAliases(command.Text); | ||||
| builder.RunMode = command.RunMode; | builder.RunMode = command.RunMode; | ||||
| builder.Name = builder.Name ?? command.Text; | |||||
| builder.Name ??= command.Text; | |||||
| builder.IgnoreExtraArgs = command.IgnoreExtraArgs ?? service._ignoreExtraArgs; | builder.IgnoreExtraArgs = command.IgnoreExtraArgs ?? service._ignoreExtraArgs; | ||||
| break; | break; | ||||
| case NameAttribute name: | case NameAttribute name: | ||||
| @@ -131,7 +131,7 @@ namespace Discord.Commands.Builders | |||||
| internal ParameterInfo Build(CommandInfo info) | internal ParameterInfo Build(CommandInfo info) | ||||
| { | { | ||||
| if ((TypeReader ?? (TypeReader = GetReader(ParameterType))) == null) | |||||
| if ((TypeReader ??= GetReader(ParameterType)) == null) | |||||
| throw new InvalidOperationException($"No type reader found for type {ParameterType.Name}, one must be specified"); | throw new InvalidOperationException($"No type reader found for type {ParameterType.Name}, one must be specified"); | ||||
| return new ParameterInfo(this, info, Command.Module.Service); | return new ParameterInfo(this, info, Command.Module.Service); | ||||
| @@ -189,7 +189,7 @@ namespace Discord.Commands | |||||
| /// </returns> | /// </returns> | ||||
| public async Task<ModuleInfo> AddModuleAsync(Type type, IServiceProvider services) | public async Task<ModuleInfo> AddModuleAsync(Type type, IServiceProvider services) | ||||
| { | { | ||||
| services = services ?? EmptyServiceProvider.Instance; | |||||
| services ??= EmptyServiceProvider.Instance; | |||||
| await _moduleLock.WaitAsync().ConfigureAwait(false); | await _moduleLock.WaitAsync().ConfigureAwait(false); | ||||
| try | try | ||||
| @@ -224,7 +224,7 @@ namespace Discord.Commands | |||||
| /// </returns> | /// </returns> | ||||
| public async Task<IEnumerable<ModuleInfo>> AddModulesAsync(Assembly assembly, IServiceProvider services) | public async Task<IEnumerable<ModuleInfo>> AddModulesAsync(Assembly assembly, IServiceProvider services) | ||||
| { | { | ||||
| services = services ?? EmptyServiceProvider.Instance; | |||||
| services ??= EmptyServiceProvider.Instance; | |||||
| await _moduleLock.WaitAsync().ConfigureAwait(false); | await _moduleLock.WaitAsync().ConfigureAwait(false); | ||||
| try | try | ||||
| @@ -507,7 +507,7 @@ namespace Discord.Commands | |||||
| /// </returns> | /// </returns> | ||||
| public async Task<IResult> ExecuteAsync(ICommandContext context, string input, IServiceProvider services, MultiMatchHandling multiMatchHandling = MultiMatchHandling.Exception) | public async Task<IResult> ExecuteAsync(ICommandContext context, string input, IServiceProvider services, MultiMatchHandling multiMatchHandling = MultiMatchHandling.Exception) | ||||
| { | { | ||||
| services = services ?? EmptyServiceProvider.Instance; | |||||
| services ??= EmptyServiceProvider.Instance; | |||||
| var searchResult = Search(input); | var searchResult = Search(input); | ||||
| if (!searchResult.IsSuccess) | if (!searchResult.IsSuccess) | ||||
| @@ -123,7 +123,7 @@ namespace Discord.Commands | |||||
| public async Task<PreconditionResult> CheckPreconditionsAsync(ICommandContext context, IServiceProvider services = null) | public async Task<PreconditionResult> CheckPreconditionsAsync(ICommandContext context, IServiceProvider services = null) | ||||
| { | { | ||||
| services = services ?? EmptyServiceProvider.Instance; | |||||
| services ??= EmptyServiceProvider.Instance; | |||||
| async Task<PreconditionResult> CheckGroups(IEnumerable<PreconditionAttribute> preconditions, string type) | async Task<PreconditionResult> CheckGroups(IEnumerable<PreconditionAttribute> preconditions, string type) | ||||
| { | { | ||||
| @@ -164,7 +164,7 @@ namespace Discord.Commands | |||||
| public async Task<ParseResult> ParseAsync(ICommandContext context, int startIndex, SearchResult searchResult, PreconditionResult preconditionResult = null, IServiceProvider services = null) | public async Task<ParseResult> ParseAsync(ICommandContext context, int startIndex, SearchResult searchResult, PreconditionResult preconditionResult = null, IServiceProvider services = null) | ||||
| { | { | ||||
| services = services ?? EmptyServiceProvider.Instance; | |||||
| services ??= EmptyServiceProvider.Instance; | |||||
| if (!searchResult.IsSuccess) | if (!searchResult.IsSuccess) | ||||
| return ParseResult.FromError(searchResult); | return ParseResult.FromError(searchResult); | ||||
| @@ -201,7 +201,7 @@ namespace Discord.Commands | |||||
| } | } | ||||
| public async Task<IResult> ExecuteAsync(ICommandContext context, IEnumerable<object> argList, IEnumerable<object> paramList, IServiceProvider services) | public async Task<IResult> ExecuteAsync(ICommandContext context, IEnumerable<object> argList, IEnumerable<object> paramList, IServiceProvider services) | ||||
| { | { | ||||
| services = services ?? EmptyServiceProvider.Instance; | |||||
| services ??= EmptyServiceProvider.Instance; | |||||
| try | try | ||||
| { | { | ||||
| @@ -75,7 +75,7 @@ namespace Discord.Commands | |||||
| public async Task<PreconditionResult> CheckPreconditionsAsync(ICommandContext context, object arg, IServiceProvider services = null) | public async Task<PreconditionResult> CheckPreconditionsAsync(ICommandContext context, object arg, IServiceProvider services = null) | ||||
| { | { | ||||
| services = services ?? EmptyServiceProvider.Instance; | |||||
| services ??= EmptyServiceProvider.Instance; | |||||
| foreach (var precondition in Preconditions) | foreach (var precondition in Preconditions) | ||||
| { | { | ||||
| @@ -89,7 +89,7 @@ namespace Discord.Commands | |||||
| public async Task<TypeReaderResult> ParseAsync(ICommandContext context, string input, IServiceProvider services = null) | public async Task<TypeReaderResult> ParseAsync(ICommandContext context, string input, IServiceProvider services = null) | ||||
| { | { | ||||
| services = services ?? EmptyServiceProvider.Instance; | |||||
| services ??= EmptyServiceProvider.Instance; | |||||
| return await _reader.ReadAsync(context, input, services).ConfigureAwait(false); | return await _reader.ReadAsync(context, input, services).ConfigureAwait(false); | ||||
| } | } | ||||
| @@ -177,7 +177,7 @@ namespace Discord.API | |||||
| public async Task SendAsync(string method, string endpoint, | public async Task SendAsync(string method, string endpoint, | ||||
| BucketId bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) | BucketId bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) | ||||
| { | { | ||||
| options = options ?? new RequestOptions(); | |||||
| options ??= new RequestOptions(); | |||||
| options.HeaderOnly = true; | options.HeaderOnly = true; | ||||
| options.BucketId = bucketId; | options.BucketId = bucketId; | ||||
| @@ -191,7 +191,7 @@ namespace Discord.API | |||||
| public async Task SendJsonAsync(string method, string endpoint, object payload, | public async Task SendJsonAsync(string method, string endpoint, object payload, | ||||
| BucketId bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) | BucketId bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) | ||||
| { | { | ||||
| options = options ?? new RequestOptions(); | |||||
| options ??= new RequestOptions(); | |||||
| options.HeaderOnly = true; | options.HeaderOnly = true; | ||||
| options.BucketId = bucketId; | options.BucketId = bucketId; | ||||
| @@ -206,7 +206,7 @@ namespace Discord.API | |||||
| public async Task SendMultipartAsync(string method, string endpoint, IReadOnlyDictionary<string, object> multipartArgs, | public async Task SendMultipartAsync(string method, string endpoint, IReadOnlyDictionary<string, object> multipartArgs, | ||||
| BucketId bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) | BucketId bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) | ||||
| { | { | ||||
| options = options ?? new RequestOptions(); | |||||
| options ??= new RequestOptions(); | |||||
| options.HeaderOnly = true; | options.HeaderOnly = true; | ||||
| options.BucketId = bucketId; | options.BucketId = bucketId; | ||||
| @@ -220,7 +220,7 @@ namespace Discord.API | |||||
| public async Task<TResponse> SendAsync<TResponse>(string method, string endpoint, | public async Task<TResponse> SendAsync<TResponse>(string method, string endpoint, | ||||
| BucketId bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) where TResponse : class | BucketId bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) where TResponse : class | ||||
| { | { | ||||
| options = options ?? new RequestOptions(); | |||||
| options ??= new RequestOptions(); | |||||
| options.BucketId = bucketId; | options.BucketId = bucketId; | ||||
| var request = new RestRequest(RestClient, method, endpoint, options); | var request = new RestRequest(RestClient, method, endpoint, options); | ||||
| @@ -233,7 +233,7 @@ namespace Discord.API | |||||
| public async Task<TResponse> SendJsonAsync<TResponse>(string method, string endpoint, object payload, | public async Task<TResponse> SendJsonAsync<TResponse>(string method, string endpoint, object payload, | ||||
| BucketId bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) where TResponse : class | BucketId bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) where TResponse : class | ||||
| { | { | ||||
| options = options ?? new RequestOptions(); | |||||
| options ??= new RequestOptions(); | |||||
| options.BucketId = bucketId; | options.BucketId = bucketId; | ||||
| string json = payload != null ? SerializeJson(payload) : null; | string json = payload != null ? SerializeJson(payload) : null; | ||||
| @@ -248,7 +248,7 @@ namespace Discord.API | |||||
| public async Task<TResponse> SendMultipartAsync<TResponse>(string method, string endpoint, IReadOnlyDictionary<string, object> multipartArgs, | public async Task<TResponse> SendMultipartAsync<TResponse>(string method, string endpoint, IReadOnlyDictionary<string, object> multipartArgs, | ||||
| BucketId bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) | BucketId bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) | ||||
| { | { | ||||
| options = options ?? new RequestOptions(); | |||||
| options ??= new RequestOptions(); | |||||
| options.BucketId = bucketId; | options.BucketId = bucketId; | ||||
| var request = new MultipartRestRequest(RestClient, method, endpoint, multipartArgs, options); | var request = new MultipartRestRequest(RestClient, method, endpoint, multipartArgs, options); | ||||
| @@ -62,7 +62,7 @@ namespace Discord.Rest | |||||
| public async Task<RestApplication> GetApplicationInfoAsync(RequestOptions options = null) | public async Task<RestApplication> GetApplicationInfoAsync(RequestOptions options = null) | ||||
| { | { | ||||
| return _applicationInfo ?? (_applicationInfo = await ClientHelper.GetApplicationInfoAsync(this, options).ConfigureAwait(false)); | |||||
| return _applicationInfo ??= await ClientHelper.GetApplicationInfoAsync(this, options).ConfigureAwait(false); | |||||
| } | } | ||||
| public Task<RestChannel> GetChannelAsync(ulong id, RequestOptions options = null) | public Task<RestChannel> GetChannelAsync(ulong id, RequestOptions options = null) | ||||
| @@ -344,7 +344,7 @@ namespace Discord.Rest | |||||
| tags.Add(new Tag<Emote>(TagType.Emoji, index, content.Length, emoji.Id, emoji)); | tags.Add(new Tag<Emote>(TagType.Emoji, index, content.Length, emoji.Id, emoji)); | ||||
| else //Bad Tag | else //Bad Tag | ||||
| { | { | ||||
| index = index + 1; | |||||
| index++; | |||||
| continue; | continue; | ||||
| } | } | ||||
| index = endIndex + 1; | index = endIndex + 1; | ||||
| @@ -322,7 +322,7 @@ namespace Discord.WebSocket | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public override async Task<RestApplication> GetApplicationInfoAsync(RequestOptions options = null) | public override async Task<RestApplication> GetApplicationInfoAsync(RequestOptions options = null) | ||||
| => _applicationInfo ?? (_applicationInfo = await ClientHelper.GetApplicationInfoAsync(this, options ?? RequestOptions.Default).ConfigureAwait(false)); | |||||
| => _applicationInfo ??= await ClientHelper.GetApplicationInfoAsync(this, options ?? RequestOptions.Default).ConfigureAwait(false); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public override SocketGuild GetGuild(ulong id) | public override SocketGuild GetGuild(ulong id) | ||||
| @@ -187,7 +187,7 @@ namespace TestHelper | |||||
| private static HashSet<Assembly> RecursiveReferencedAssemblies(Assembly a, HashSet<Assembly> assemblies = null) | private static HashSet<Assembly> RecursiveReferencedAssemblies(Assembly a, HashSet<Assembly> assemblies = null) | ||||
| { | { | ||||
| assemblies = assemblies ?? new HashSet<Assembly>(); | |||||
| assemblies ??= new HashSet<Assembly>(); | |||||
| if (assemblies.Add(a)) | if (assemblies.Add(a)) | ||||
| { | { | ||||
| foreach (var referencedAssemblyName in a.GetReferencedAssemblies()) | foreach (var referencedAssemblyName in a.GetReferencedAssemblies()) | ||||