Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use is operator for null check instead of == #16035

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public bool TryMapAreaControllerRoute(IEndpointRouteBuilder routes, ControllerAc
var controllerAttribute = descriptor.ControllerTypeInfo.GetCustomAttribute<AdminAttribute>();
var actionAttribute = descriptor.MethodInfo.GetCustomAttribute<AdminAttribute>();

if (descriptor.ControllerName != "Admin" && controllerAttribute == null && actionAttribute == null)
if (descriptor.ControllerName != "Admin" && controllerAttribute is null && actionAttribute is null)
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void Apply(PageRouteModel model)
{
var route = model.Selectors.FirstOrDefault()?.AttributeRouteModel;

if (route == null)
if (route is null)
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void OnProvidersExecuting(PageRouteModelProviderContext context)
{
var attribute = type.GetCustomAttribute<AdminAttribute>();

if (attribute != null)
if (attribute is not null)
{
adminPaths.Add(descriptor.RelativePath);
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@if (Model.Content == null)
@if (Model.Content is null)
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@inject IDisplayManager<Navbar> DisplayManager
@inject IUpdateModelAccessor UpdateModelAccessor

@if (Model.Content == null)
@if (Model.Content is null)
{
var shape = await DisplayManager.BuildDisplayAsync(UpdateModelAccessor.ModelUpdater, (string)Model.Metadata.DisplayType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public async Task<IActionResult> Update([FromForm] DashboardPartViewModel[] part
// Load the latest version first if any.
var latestItems = await _contentManager.GetAsync(contentItemIds, VersionOptions.Latest);

if (latestItems == null)
if (latestItems is null)
{
return NotFound();
}
Expand All @@ -165,7 +165,7 @@ public async Task<IActionResult> Update([FromForm] DashboardPartViewModel[] part
foreach (var contentItem in latestItems)
{
var dashboardPart = contentItem.As<DashboardPart>();
if (dashboardPart == null)
if (dashboardPart is null)
{
return Forbid();
}
Expand All @@ -184,7 +184,7 @@ public async Task<IActionResult> Update([FromForm] DashboardPartViewModel[] part
{
var publishedVersion = publishedItems.FirstOrDefault(p => p.ContentItemId == contentItem.ContentItemId);
var publishedMetaData = publishedVersion?.As<DashboardPart>();
if (publishedMetaData != null)
if (publishedMetaData is not null)
{
publishedMetaData.Position = partViewModel.Position;
publishedMetaData.Width = partViewModel.Width;
Expand All @@ -195,7 +195,7 @@ public async Task<IActionResult> Update([FromForm] DashboardPartViewModel[] part
}
}

if (Request.Headers != null && Request.Headers.XRequestedWith == "XMLHttpRequest")
if (Request.Headers is not null && Request.Headers.XRequestedWith == "XMLHttpRequest")
{
return Ok();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public override async Task<IDisplayResult> DisplayAsync(ContentItem model, Build
var dashboardFeature = httpContext.Features.Get<DashboardFeature>();

// Return if it's not Manage dashboard request
if (dashboardFeature == null || !dashboardFeature.IsManageRequest)
if (dashboardFeature is null || !dashboardFeature.IsManageRequest)
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public override void Describe(DescribeContext<ContentItem> context)
return null;
}

if (dashboardPart != null)
if (dashboardPart is not null)
{
return new DashboardPartIndex
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
},
start: function (e, ui) {

if(_menu != null){
if(_menu is not null){
$(document).trigger('click');
}

Expand All @@ -218,7 +218,7 @@
helper: "ui-resizable-helper"
,
start: function (event, ui) {
if(_menu != null){
if(_menu is not null){
$(document).trigger('click');
}
setUndoValues();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

}

@if (dashboardFeature != null && dashboardFeature.IsManageRequest)
@if (dashboardFeature is not null && dashboardFeature.IsManageRequest)
{
ContentItem contentItem = Model.ContentItem;
var modifiedUtc = contentItem.ModifiedUtc?.ToString("yyyy-MM-ddTHH:mm:sszzz", CultureInfo.InvariantCulture);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<div class="card h-100 @string.Join(' ', Model.Classes.ToArray())">
@if (Model.Header != null || Model.Leading != null || Model.ActionsMenu != null)
@if (Model.Header is not null || Model.Leading is not null || Model.ActionsMenu is not null)
{
<div class="card-header">
@await DisplayAsync(Model.Leading)
@await DisplayAsync(Model.Header)
@if (Model.ActionsMenu != null)
@if (Model.ActionsMenu is not null)
{
<div class="btn-group float-end" title="@T["Actions"]">
<button type="button" class="btn btn-sm " data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Expand All @@ -18,7 +18,7 @@
</div>
}
<div class="dashboard-body-container card-body p-0 h-100">
@if (Model.Tags != null || Model.Meta != null)
@if (Model.Tags is not null || Model.Meta is not null)
{
<div class="dashboard-meta">
@await DisplayAsync(Model.Meta)
Expand All @@ -27,7 +27,7 @@
}
@await DisplayAsync(Model.Content)
</div>
@if (Model.Footer != null)
@if (Model.Footer is not null)
{
<div class="card-footer">
@await DisplayAsync(Model.Footer)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div class="@string.Join(" ", Model.Classes.ToArray())">
@if (Model.Header != null || Model.Meta != null)
@if (Model.Header is not null || Model.Meta is not null)
{
<div class="widget-header">
@await DisplayAsync(Model.Header)
@if (Model.Meta != null)
@if (Model.Meta is not null)
{
<div class="widget-metadata">
@await DisplayAsync(Model.Meta)
Expand All @@ -14,7 +14,7 @@
<div class="widget-body">
@await DisplayAsync(Model.Content)
</div>
@if (Model.Footer != null)
@if (Model.Footer is not null)
{
<div class="widget-footer">
@await DisplayAsync(Model.Footer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@
@contentItem
}
- <small class="text-muted">@contentItem.ContentType</small>
@if (Model.Header != null)
@if (Model.Header is not null)
{
<div class="header">@await DisplayAsync(Model.Header)</div>
}
@if (Model.Tags != null)
@if (Model.Tags is not null)
{
@await DisplayAsync(Model.Tags)
}
@if (Model.Meta != null)
@if (Model.Meta is not null)
{
<div class="d-inline">@await DisplayAsync(Model.Meta)</div>
}
</div>
<div class="col-xl-3 col-sm-12">
<div class="float-end button-group">
@if (Model.Actions != null)
@if (Model.Actions is not null)
{
@await DisplayAsync(Model.Actions)
}
@if (Model.ActionsMenu != null)
@if (Model.ActionsMenu is not null)
{
<div class="btn-group">
<button type="button" class="btn btn-sm text-secondary" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Expand All @@ -54,7 +54,7 @@
</div>
</div>

@if (Model.Content != null)
@if (Model.Content is not null)
{
<div class="primary">@await DisplayAsync(Model.Content)</div>
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div class="@string.Join(" ", Model.Classes.ToArray())">
@if (Model.Header != null || Model.Meta != null)
@if (Model.Header is not null || Model.Meta is not null)
{
<div class="widget-header">
@await DisplayAsync(Model.Header)
@if (Model.Meta != null)
@if (Model.Meta is not null)
{
<div class="widget-metadata">
@await DisplayAsync(Model.Meta)
Expand All @@ -14,7 +14,7 @@
<div class="widget-body">
@await DisplayAsync(Model.Content)
</div>
@if (Model.Footer != null)
@if (Model.Footer is not null)
{
<div class="widget-footer">
@await DisplayAsync(Model.Footer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public override async Task<IDisplayResult> UpdateAsync(LinkAdminNode treeNode, I
treeNode.LinkUrl = model.LinkUrl;
treeNode.IconClass = model.IconClass;

var selectedPermissions = (model.SelectedPermissionNames == null ? [] : model.SelectedPermissionNames.Split(',', StringSplitOptions.RemoveEmptyEntries));
var selectedPermissions = (model.SelectedPermissionNames is null ? [] : model.SelectedPermissionNames.Split(',', StringSplitOptions.RemoveEmptyEntries));

var permissions = await _adminMenuPermissionService.GetPermissionsAsync();
treeNode.PermissionNames = permissions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public LinkAdminNodeNavigationBuilder(
public Task BuildNavigationAsync(MenuItem menuItem, NavigationBuilder builder, IEnumerable<IAdminNodeNavigationBuilder> treeNodeBuilders)
{
var node = menuItem as LinkAdminNode;
if (node == null || string.IsNullOrEmpty(node.LinkText) || !node.Enabled)
if (node is null || string.IsNullOrEmpty(node.LinkText) || !node.Enabled)
{
return Task.CompletedTask;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public override async Task<IDisplayResult> UpdateAsync(PlaceholderAdminNode tree
treeNode.LinkText = model.LinkText;
treeNode.IconClass = model.IconClass;

var selectedPermissions = (model.SelectedPermissionNames == null ? Array.Empty<string>() : model.SelectedPermissionNames.Split(',', StringSplitOptions.RemoveEmptyEntries));
var selectedPermissions = (model.SelectedPermissionNames is null ? Array.Empty<string>() : model.SelectedPermissionNames.Split(',', StringSplitOptions.RemoveEmptyEntries));
var permissions = await _adminMenuPermissionService.GetPermissionsAsync();
treeNode.PermissionNames = permissions
.Where(p => selectedPermissions.Contains(p.Name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public Task BuildNavigationAsync(MenuItem menuItem, NavigationBuilder builder, I
{
var node = menuItem as PlaceholderAdminNode;

if (node == null || string.IsNullOrEmpty(node.LinkText) || !node.Enabled)
if (node is null || string.IsNullOrEmpty(node.LinkText) || !node.Enabled)
{
return Task.CompletedTask;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public async Task<IActionResult> Edit(string id)
var adminMenuList = await _adminMenuService.GetAdminMenuListAsync();
var adminMenu = _adminMenuService.GetAdminMenuById(adminMenuList, id);

if (adminMenu == null)
if (adminMenu is null)
{
return NotFound();
}
Expand All @@ -190,7 +190,7 @@ public async Task<IActionResult> Edit(AdminMenuEditViewModel model)
var adminMenuList = await _adminMenuService.LoadAdminMenuListAsync();
var adminMenu = _adminMenuService.GetAdminMenuById(adminMenuList, model.Id);

if (adminMenu == null)
if (adminMenu is null)
{
return NotFound();
}
Expand Down Expand Up @@ -220,7 +220,7 @@ public async Task<IActionResult> Delete(string id)
var adminMenuList = await _adminMenuService.LoadAdminMenuListAsync();
var adminMenu = _adminMenuService.GetAdminMenuById(adminMenuList, id);

if (adminMenu == null)
if (adminMenu is null)
{
await _notifier.ErrorAsync(H["Can't find the admin menu."]);
return RedirectToAction(nameof(List));
Expand Down Expand Up @@ -284,7 +284,7 @@ public async Task<IActionResult> Toggle(string id)
var adminMenuList = await _adminMenuService.LoadAdminMenuListAsync();
var adminMenu = _adminMenuService.GetAdminMenuById(adminMenuList, id);

if (adminMenu == null)
if (adminMenu is null)
{
return NotFound();
}
Expand Down
Loading