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

V15: Update to dotnet 9 #16625

Merged
merged 13 commits into from
Jul 1, 2024
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Company>Umbraco HQ</Company>
<Authors>Umbraco</Authors>
<Copyright>Copyright © Umbraco $([System.DateTime]::Today.ToString('yyyy'))</Copyright>
Expand Down
46 changes: 23 additions & 23 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@
<ItemGroup>
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" />
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
<GlobalPackageReference Include="Umbraco.Code" Version="2.1.0" />
<GlobalPackageReference Include="Umbraco.Code" Version="2.2.0" />
<GlobalPackageReference Include="Umbraco.GitVersioning.Extensions" Version="0.2.0" />
</ItemGroup>
<!-- Microsoft packages -->
<ItemGroup>
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.5" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
<PackageVersion Include="Microsoft.Data.Sqlite" Version="8.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.5" />
<PackageVersion Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.5" />
<PackageVersion Include="Microsoft.Extensions.FileProviders.Physical" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Identity.Core" Version="8.0.5" />
<PackageVersion Include="Microsoft.Extensions.Identity.Stores" Version="8.0.5" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="8.0.2" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options.DataAnnotations" Version="8.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="9.0.0-preview.5.24306.11" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
<PackageVersion Include="Microsoft.Data.Sqlite" Version="9.0.0-preview.5.24306.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0-preview.5.24306.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0-preview.5.24306.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.6" />
<PackageVersion Include="Microsoft.Extensions.Caching.Abstractions" Version="9.0.0-preview.5.24306.7" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="9.0.0-preview.5.24306.7" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.0-preview.5.24306.7" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0-preview.5.24306.7" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0-preview.5.24306.7" />
<PackageVersion Include="Microsoft.Extensions.FileProviders.Embedded" Version="9.0.0-preview.5.24306.11" />
<PackageVersion Include="Microsoft.Extensions.FileProviders.Physical" Version="9.0.0-preview.5.24306.7" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.0-preview.5.24306.7" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="9.0.0-preview.5.24306.7" />
<PackageVersion Include="Microsoft.Extensions.Identity.Core" Version="9.0.0-preview.5.24306.11" />
<PackageVersion Include="Microsoft.Extensions.Identity.Stores" Version="9.0.0-preview.5.24306.11" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.0-preview.5.24306.7" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="9.0.0-preview.5.24306.7" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="9.0.0-preview.5.24306.7" />
<PackageVersion Include="Microsoft.Extensions.Options.DataAnnotations" Version="9.0.0-preview.5.24306.7" />
</ItemGroup>
<!-- Umbraco packages -->
<ItemGroup>
Expand Down Expand Up @@ -83,7 +83,7 @@
<!-- Dazinator.Extensions.FileProviders brings in a vulnerable version of System.Net.Http -->
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<!-- Examine brings in a vulnerable version of System.Security.Cryptography.Xml -->
<PackageVersion Include="System.Security.Cryptography.Xml" Version="8.0.1" />
<PackageVersion Include="System.Security.Cryptography.Xml" Version="9.0.0-preview.5.24306.7" />
<!-- Both Dazinator.Extensions.FileProviders and MiniProfiler.AspNetCore.Mvc bring in a vulnerable version of System.Text.RegularExpressions -->
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>
Expand Down
9 changes: 8 additions & 1 deletion build/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ stages:
displayName: Use .NET SDK from global.json
inputs:
useGlobalJson: true
includePreviewVersions: true
Zeegaan marked this conversation as resolved.
Show resolved Hide resolved
- task: DotNetCoreCLI@2
displayName: Run dotnet restore
inputs:
Expand Down Expand Up @@ -163,6 +164,7 @@ stages:
displayName: Use .NET SDK from global.json
inputs:
useGlobalJson: true
includePreviewVersions: true
- task: PowerShell@2
displayName: Install DocFX
inputs:
Expand Down Expand Up @@ -280,6 +282,7 @@ stages:
displayName: Use .NET SDK from global.json
inputs:
useGlobalJson: true
includePreviewVersions: true
- task: DotNetCoreCLI@2
displayName: Run dotnet test
inputs:
Expand Down Expand Up @@ -321,6 +324,7 @@ stages:
displayName: Use .NET SDK from global.json
inputs:
useGlobalJson: true
includePreviewVersions: true

# Test
- task: DotNetCoreCLI@2
Expand Down Expand Up @@ -369,6 +373,7 @@ stages:
displayName: Use .NET SDK from global.json
inputs:
useGlobalJson: true
includePreviewVersions: true

# Start SQL Server
- powershell: docker run --name mssql -d -p 1433:1433 -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=$(SA_PASSWORD)" mcr.microsoft.com/mssql/server:2022-latest
Expand Down Expand Up @@ -462,6 +467,7 @@ stages:
displayName: Use .NET SDK from global.json
inputs:
useGlobalJson: true
includePreviewVersions: true

- pwsh: |
"UMBRACO_USER_LOGIN=$(UMBRACO__CMS__UNATTENDED__UNATTENDEDUSEREMAIL)
Expand Down Expand Up @@ -528,7 +534,7 @@ stages:
- ${{ if eq(parameters.isNightly, true) }}:
pwsh: npm run test --ignore-certificate-errors
${{ else }}:
pwsh: npm run smokeTest --ignore-certificate-errors
pwsh: npm run smokeTest --ignore-certificate-errors
displayName: Run Playwright tests
continueOnError: true
workingDirectory: tests/Umbraco.Tests.AcceptanceTest
Expand Down Expand Up @@ -597,6 +603,7 @@ stages:
displayName: Use .NET SDK from global.json
inputs:
useGlobalJson: true
includePreviewVersions: true

- pwsh: |
"UMBRACO_USER_LOGIN=$(UMBRACO__CMS__UNATTENDED__UNATTENDEDUSEREMAIL)
Expand Down
5 changes: 3 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"sdk": {
"version": "8.0.100",
"rollForward": "latestFeature"
"version": "9.0.100-preview.5.24307.3",
"rollForward": "latestFeature",
"allowPrerelease": true
Zeegaan marked this conversation as resolved.
Show resolved Hide resolved
}
}
2 changes: 1 addition & 1 deletion src/Umbraco.Cms.Api.Common/OpenApi/SchemaIdHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private string SanitizedTypeName(Type t) => t.Name
// first grab the "non-generic" part of any generic type name (i.e. "PagedViewModel`1" becomes "PagedViewModel")
.Split('`').First()
// then remove the "ViewModel" postfix from type names
.TrimEnd("ViewModel");
.TrimEndExact("ViewModel");

private string HandleGenerics(string name, Type type)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private IPublishedMediaCache GetRequiredPublishedMediaCache()
return null;
}

var childrenOf = fetch.TrimStart(childrenOfParameter);
var childrenOf = fetch.TrimStartExact(childrenOfParameter);
if (childrenOf.IsNullOrWhiteSpace())
{
// this mirrors the current behavior of the Content Delivery API :-)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public RequestRedirectService(
}

// important: redirect URLs are always tracked without trailing slashes
IRedirectUrl? redirectUrl = _redirectUrlService.GetMostRecentRedirectUrl(requestedPath.TrimEnd("/"), culture);
IRedirectUrl? redirectUrl = _redirectUrlService.GetMostRecentRedirectUrl(requestedPath.TrimEndExact("/"), culture);
IPublishedContent? content = redirectUrl != null
? _apiPublishedContentCache.GetById(redirectUrl.ContentKey)
: null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Task<PagedViewModel<IndexResponseModel>> All(
{
IndexResponseModel[] indexes = _examineManager.Indexes
.Select(_indexPresentationFactory.Create)
.OrderBy(indexModel => indexModel.Name.TrimEnd("Indexer")).ToArray();
.OrderBy(indexModel => indexModel.Name.TrimEndExact("Indexer")).ToArray();

var viewModel = new PagedViewModel<IndexResponseModel> { Items = indexes.Skip(skip).Take(take), Total = indexes.Length };
return Task.FromResult(viewModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task<ActionResult<PagedViewModel<SearcherResponse>>> All(
var searchers = new List<SearcherResponse>(
_examineManager.RegisteredSearchers.Select(searcher => new SearcherResponse { Name = searcher.Name })
.OrderBy(x =>
x.Name.TrimEnd("Searcher"))); // order by name , but strip the "Searcher" from the end if it exists
x.Name.TrimEndExact("Searcher"))); // order by name , but strip the "Searcher" from the end if it exists
var viewModel = new PagedViewModel<SearcherResponse>
{
Items = searchers.Skip(skip).Take(take),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<title>Website is Under Maintainance</title>

<link rel="stylesheet" href="@WebPath.Combine(backOfficePath.TrimStart("~") , "website", "/nonodes.css")" />
<link rel="stylesheet" href="@WebPath.Combine(backOfficePath.TrimStartExact("~") , "website", "/nonodes.css")" />
<style type="text/css">
body {
color:initial;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<title>Umbraco: No Published Content</title>

<link rel="stylesheet" href="@WebPath.Combine(backOfficePath.TrimStart("~") , "website", "/nonodes.css")" />
<link rel="stylesheet" href="@WebPath.Combine(backOfficePath.TrimStartExact("~") , "website", "/nonodes.css")" />
</head>
<body>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<title>Page Not Found</title>

<link rel="stylesheet" href="@WebPath.Combine(backOfficePath.TrimStart("~") , "website", "/nonodes.css")" />
<link rel="stylesheet" href="@WebPath.Combine(backOfficePath.TrimStartExact("~") , "website", "/nonodes.css")" />
<style type="text/css">
body {
color:initial;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal static string GetModelsDirectory(string root, string config, bool accep

if (config.StartsWith("~/"))
{
var dir = Path.Combine(root, config.TrimStart("~/"));
var dir = Path.Combine(root, config.TrimStartExact("~/"));

// sanitize - GetFullPath will take care of any relative
// segments in path, eg '../../foo.tmp' - it may throw a SecurityException
Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Core/DeliveryApi/ApiContentRouteBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public ApiContentRouteBuilder(

if (_globalSettings.HideTopLevelNodeFromPath == false)
{
contentPath = contentPath.TrimStart(rootPath.EnsureStartsWith("/")).EnsureStartsWith("/");
contentPath = contentPath.TrimStartExact(rootPath.EnsureStartsWith("/")).EnsureStartsWith("/");
}

return new ApiContentRoute(contentPath, new ApiContentStartItem(root.Key, rootPath));
Expand Down
8 changes: 4 additions & 4 deletions src/Umbraco.Core/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Umbraco.

Check warning on line 1 in src/Umbraco.Core/Extensions/StringExtensions.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v15/dev)

❌ Getting worse: Low Cohesion

The number of different responsibilities increases from 13 to 15, threshold = 3. Cohesion is calculated using the LCOM4 metric. Low cohesion means that the module/class has multiple unrelated responsibilities, doing too many things and breaking the Single Responsibility Principle.
// See LICENSE for more details.

using System.ComponentModel;
Expand Down Expand Up @@ -294,7 +294,7 @@
return value;
}

return value.TrimEnd(forRemoving).TrimStart(forRemoving);
return value.TrimEndExact(forRemoving).TrimStartExact(forRemoving);
Zeegaan marked this conversation as resolved.
Show resolved Hide resolved
}

public static string EncodeJsString(this string s)
Expand Down Expand Up @@ -343,7 +343,7 @@
return sb.ToString();
}

public static string TrimEnd(this string value, string forRemoving)
public static string TrimEndExact(this string value, string forRemoving)
{
if (string.IsNullOrEmpty(value))
{
Expand All @@ -363,7 +363,7 @@
return value;
}

public static string TrimStart(this string value, string forRemoving)
public static string TrimStartExact(this string value, string forRemoving)
{
if (string.IsNullOrEmpty(value))
{
Expand All @@ -390,7 +390,7 @@
return input;
}

return toStartWith + input.TrimStart(toStartWith);
return toStartWith + input.TrimStartExact(toStartWith);
Zeegaan marked this conversation as resolved.
Show resolved Hide resolved
}

public static string EnsureStartsWith(this string input, char value) =>
Expand Down
12 changes: 6 additions & 6 deletions src/Umbraco.Core/Models/Content.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,19 +353,19 @@ public override bool IsPropertyDirty(string propertyName)
// Special check here since we want to check if the request is for changed cultures
if (propertyName.StartsWith(ChangeTrackingPrefix.PublishedCulture))
{
var culture = propertyName.TrimStart(ChangeTrackingPrefix.PublishedCulture);
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.PublishedCulture);
return _currentPublishCultureChanges.addedCultures?.Contains(culture) ?? false;
}

if (propertyName.StartsWith(ChangeTrackingPrefix.UnpublishedCulture))
{
var culture = propertyName.TrimStart(ChangeTrackingPrefix.UnpublishedCulture);
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.UnpublishedCulture);
return _currentPublishCultureChanges.removedCultures?.Contains(culture) ?? false;
}

if (propertyName.StartsWith(ChangeTrackingPrefix.ChangedCulture))
{
var culture = propertyName.TrimStart(ChangeTrackingPrefix.ChangedCulture);
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.ChangedCulture);
return _currentPublishCultureChanges.updatedCultures?.Contains(culture) ?? false;
}

Expand All @@ -379,19 +379,19 @@ public override bool WasPropertyDirty(string propertyName)
// Special check here since we want to check if the request is for changed cultures
if (propertyName.StartsWith(ChangeTrackingPrefix.PublishedCulture))
{
var culture = propertyName.TrimStart(ChangeTrackingPrefix.PublishedCulture);
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.PublishedCulture);
return _previousPublishCultureChanges.addedCultures?.Contains(culture) ?? false;
}

if (propertyName.StartsWith(ChangeTrackingPrefix.UnpublishedCulture))
{
var culture = propertyName.TrimStart(ChangeTrackingPrefix.UnpublishedCulture);
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.UnpublishedCulture);
return _previousPublishCultureChanges.removedCultures?.Contains(culture) ?? false;
}

if (propertyName.StartsWith(ChangeTrackingPrefix.ChangedCulture))
{
var culture = propertyName.TrimStart(ChangeTrackingPrefix.ChangedCulture);
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.ChangedCulture);
return _previousPublishCultureChanges.updatedCultures?.Contains(culture) ?? false;
}

Expand Down
12 changes: 6 additions & 6 deletions src/Umbraco.Core/Models/ContentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -578,19 +578,19 @@ public override bool IsPropertyDirty(string propertyName)
// Special check here since we want to check if the request is for changed cultures
if (propertyName.StartsWith(ChangeTrackingPrefix.AddedCulture))
{
var culture = propertyName.TrimStart(ChangeTrackingPrefix.AddedCulture);
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.AddedCulture);
return _currentCultureChanges.addedCultures?.Contains(culture) ?? false;
}

if (propertyName.StartsWith(ChangeTrackingPrefix.RemovedCulture))
{
var culture = propertyName.TrimStart(ChangeTrackingPrefix.RemovedCulture);
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.RemovedCulture);
return _currentCultureChanges.removedCultures?.Contains(culture) ?? false;
}

if (propertyName.StartsWith(ChangeTrackingPrefix.UpdatedCulture))
{
var culture = propertyName.TrimStart(ChangeTrackingPrefix.UpdatedCulture);
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.UpdatedCulture);
return _currentCultureChanges.updatedCultures?.Contains(culture) ?? false;
}

Expand All @@ -609,19 +609,19 @@ public override bool WasPropertyDirty(string propertyName)
// Special check here since we want to check if the request is for changed cultures
if (propertyName.StartsWith(ChangeTrackingPrefix.AddedCulture))
{
var culture = propertyName.TrimStart(ChangeTrackingPrefix.AddedCulture);
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.AddedCulture);
return _previousCultureChanges.addedCultures?.Contains(culture) ?? false;
}

if (propertyName.StartsWith(ChangeTrackingPrefix.RemovedCulture))
{
var culture = propertyName.TrimStart(ChangeTrackingPrefix.RemovedCulture);
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.RemovedCulture);
return _previousCultureChanges.removedCultures?.Contains(culture) ?? false;
}

if (propertyName.StartsWith(ChangeTrackingPrefix.UpdatedCulture))
{
var culture = propertyName.TrimStart(ChangeTrackingPrefix.UpdatedCulture);
var culture = propertyName.TrimStartExact(ChangeTrackingPrefix.UpdatedCulture);
return _previousCultureChanges.updatedCultures?.Contains(culture) ?? false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Umbraco.Core/Routing/UmbracoRequestPaths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public UmbracoRequestPaths(IOptions<GlobalSettings> globalSettings, IHostingEnvi
_appPath = hostingEnvironment.ApplicationVirtualPath;

_backOfficePath = globalSettings.Value.GetBackOfficePath(hostingEnvironment)
.EnsureStartsWith('/').TrimStart(_appPath).EnsureStartsWith('/');
.EnsureStartsWith('/').TrimStartExact(_appPath).EnsureStartsWith('/');

string mvcArea = globalSettings.Value.GetUmbracoMvcArea(hostingEnvironment);

Expand Down Expand Up @@ -73,7 +73,7 @@ public UmbracoRequestPaths(IOptions<GlobalSettings> globalSettings, IHostingEnvi
/// </remarks>
public bool IsBackOfficeRequest(string absPath)
{
string urlPath = absPath.TrimStart(_appPath).EnsureStartsWith('/');
string urlPath = absPath.TrimStartExact(_appPath).EnsureStartsWith('/');

// check if this is in the umbraco back office
if (!urlPath.InvariantStartsWith(_backOfficePath))
Expand Down
Loading
Loading