Skip to content

Commit ab2a424

Browse files
committed
Rearranged property initialization
Resolves `IDE0017`. This is a hackaround`IDE0017`, which encourages the use of inline property initialization. Generally, we want that. But, in these cases, it doesn't make sense to use it for one property, but then not the following property since `CurrentValue` can't usually be set inline due to its dependency on method calls. By rearranging the property assignments so that `CurrentValue` comes first, Code Analysis is satisfied, and the _Set model values_ remain logically grouped.
1 parent b078c70 commit ab2a424

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

OnTopic.Editor.AspNetCore/Components/FileListViewComponent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ string htmlFieldPrefix
7373
/*------------------------------------------------------------------------------------------------------------------------
7474
| Set model values
7575
\-----------------------------------------------------------------------------------------------------------------------*/
76-
model.AbsolutePath = _webHostEnvironment.ContentRootPath + attribute.Path;
7776
model.Files = GetFiles(model.InheritedValue, attribute, model.AbsolutePath);
77+
model.AbsolutePath = _webHostEnvironment.ContentRootPath + attribute.Path;
7878

7979
/*------------------------------------------------------------------------------------------------------------------------
8080
| Return view with view model

OnTopic.Editor.AspNetCore/Components/LastModifiedByViewComponent.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ string htmlFieldPrefix
4646
/*------------------------------------------------------------------------------------------------------------------------
4747
| Establish view model
4848
\-----------------------------------------------------------------------------------------------------------------------*/
49-
var model = new LastModifiedByAttributeViewModel(currentTopic, attribute);
49+
var model = new LastModifiedByAttributeViewModel(currentTopic, attribute);
5050

5151
/*------------------------------------------------------------------------------------------------------------------------
5252
| Set model values
5353
\-----------------------------------------------------------------------------------------------------------------------*/
54-
model.Value = HttpContext.User.Identity.Name ?? "System";
55-
model.CurrentValue = currentTopic.Attributes["LastModifiedBy"]?? model.Value;
54+
model.CurrentValue = currentTopic.Attributes["LastModifiedBy"]?? model.Value;
55+
model.Value = HttpContext.User.Identity.Name?? "System";
5656

5757
/*------------------------------------------------------------------------------------------------------------------------
5858
| Return view with view model

OnTopic.Editor.AspNetCore/Components/LastModifiedViewComponent.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ string htmlFieldPrefix
5353
/*------------------------------------------------------------------------------------------------------------------------
5454
| Set model values
5555
\-----------------------------------------------------------------------------------------------------------------------*/
56-
model.Value = DateTime.Now.ToString();
5756
if (currentTopic.LastModified != null && currentTopic.LastModified != DateTime.MinValue) {
58-
model.CurrentValue = currentTopic.LastModified.ToString();
57+
model.CurrentValue = currentTopic.LastModified.ToString();
5958
}
6059
else {
61-
model.CurrentValue = model.Value;
60+
model.CurrentValue = model.Value;
6261
}
62+
model.Value = DateTime.Now.ToString();
6363

6464
/*------------------------------------------------------------------------------------------------------------------------
6565
| Return view with view model

0 commit comments

Comments
 (0)