Skip to content

Commit 089c96a

Browse files
committed
Merge branch 'maintenance/code-analysis' into develop
The latest version of Code Analysis and Visual Studio's Validation library exposed some new issues. These are fixed as part of this update. These include e.g. removing unnecessary suppressions, updating to the LTR release of .NET 3.1, and preferring the new range operators over `Substring()` where possible.
2 parents 4838da8 + 0aef6b1 commit 089c96a

7 files changed

Lines changed: 6 additions & 12 deletions

File tree

OnTopic.AspNetCore.Mvc.Host/OnTopic.AspNetCore.Mvc.Host.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.0</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
<UserSecretsId>62eb85bf-f802-4afd-8bec-3d344e1cfc79</UserSecretsId>
66
<IsPackable>false</IsPackable>
77
</PropertyGroup>

OnTopic.AspNetCore.Mvc.Tests/OnTopic.AspNetCore.Mvc.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.0</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<LangVersion>9.0</LangVersion>
77
</PropertyGroup>

OnTopic.AspNetCore.Mvc/OnTopic.AspNetCore.Mvc.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<ProjectGuid>{B7F136A1-C86D-4A74-AC4F-3693CD1358A4}</ProjectGuid>
55
<RootNamespace>OnTopic.AspNetCore.Mvc</RootNamespace>
6-
<TargetFramework>netcoreapp3.0</TargetFramework>
6+
<TargetFramework>netcoreapp3.1</TargetFramework>
77
<ShouldCreateLogs>True</ShouldCreateLogs>
88
<AdvancedSettingsExpanded>False</AdvancedSettingsExpanded>
99
<LangVersion>9.0</LangVersion>

OnTopic.AspNetCore.Mvc/TopicViewResultExecutor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public ViewEngineResult FindView(ActionContext actionContext, TopicViewResult vi
122122
// Get content-type after the slash and replace '+' characters in the content-type to '-' for view file encoding
123123
// purposes
124124
var acceptHeader = splitHeaders[i]
125-
.Substring(splitHeaders[i].IndexOf("/", StringComparison.InvariantCulture) + 1)
125+
[(splitHeaders[i].IndexOf("/", StringComparison.InvariantCulture) + 1)..]
126126
.Replace("+", "-", StringComparison.InvariantCulture);
127127
// Validate against available views; if content-type represents a valid view, stop validation
128128
if (acceptHeader is not null) {

OnTopic.TestDoubles/DummyTopicMappingService.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using OnTopic.Mapping.Annotations;
1111

1212
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
13-
#pragma warning disable IDE0060 // Remove unused parameter
1413

1514
namespace OnTopic.TestDoubles {
1615

@@ -57,5 +56,4 @@ public DummyTopicMappingService() {
5756
} //Class
5857
} //Namespace
5958

60-
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
61-
#pragma warning restore IDE0060 // Remove unused parameter
59+
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously

OnTopic.Tests/OnTopic.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.0</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<NoWarn>CS1591,1701,1702,CA1707,CA1062,CS8602,CS8604;CA1303;IDE0059</NoWarn>
77
<LangVersion>9.0</LangVersion>

OnTopic/Mapping/TopicMappingService.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -665,12 +665,10 @@ void AddToList(object dto) {
665665
try {
666666
targetList.Add(dto);
667667
}
668-
#pragma warning disable CA1031 // Do not catch general exception types
669668
catch (ArgumentException) {
670669
//Ignore exceptions caused by duplicate keys, in case the IList represents a keyed collection
671670
//We would defensively check for this, except IList doesn't provide a suitable method to do so
672671
}
673-
#pragma warning restore CA1031 // Do not catch general exception types
674672
}
675673
}
676674

@@ -710,11 +708,9 @@ ConcurrentDictionary<int, object> cache
710708
try {
711709
topicDto = await MapAsync(source, configuration.CrawlRelationships, cache).ConfigureAwait(false);
712710
}
713-
#pragma warning disable CA1031 // Do not catch general exception types
714711
catch (InvalidOperationException) {
715712
//Disregard errors caused by unmapped view models; those are functionally equivalent to IsAssignableFrom() mismatches
716713
}
717-
#pragma warning restore CA1031 // Do not catch general exception types
718714
if (topicDto is not null && configuration.Property.PropertyType.IsAssignableFrom(topicDto.GetType())) {
719715
configuration.Property.SetValue(target, topicDto);
720716
}

0 commit comments

Comments
 (0)