* minor Blazor Identity fixes (#2997)

* updated ProjectModifierHelper.ModifyDocumentText

* use ignore case extension for the 'Contains' check.

* more small fixes
This commit is contained in:
Deep Choudhery 2024-10-07 13:41:48 -07:00 коммит произвёл GitHub
Родитель 17eb9f0891
Коммит 0eeba65d51
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
5 изменённых файлов: 20 добавлений и 9 удалений

Просмотреть файл

@ -62,7 +62,7 @@
<PropertyGroup>
<VersionPrefix>9.0.0</VersionPrefix>
<PreReleaseVersionLabel>rc</PreReleaseVersionLabel>
<PreReleaseVersionIteration>1</PreReleaseVersionIteration>
<PreReleaseVersionIteration>2</PreReleaseVersionIteration>
<IncludeSourceRevisionInInformationalVersion>False</IncludeSourceRevisionInInformationalVersion>
<IsServicingBuild Condition="'$(PreReleaseVersionLabel)' == 'servicing'">true</IsServicingBuild>
<!--

Просмотреть файл

@ -1,5 +1,5 @@
set VERSION=9.0.0-dev
set DEFAULT_NUPKG_PATH=%userprofile%/.nuget/packages
set DEFAULT_NUPKG_PATH=C:\Nuget
set SRC_DIR=%cd%
set NUPKG=artifacts\packages\Debug\Shipping\
call taskkill /f /im dotnet.exe

Просмотреть файл

@ -357,10 +357,14 @@ namespace Microsoft.VisualStudio.Web.CodeGenerators.Mvc.Blazor
if (file.FileName.Equals("Routes.razor", StringComparison.OrdinalIgnoreCase) &&
FileSystem.FileExists(fileDoc.Name))
{
var usingStatement = $"@using {blazorIdentityModel.BlazorIdentityNamespace}.Shared";
var fileText = FileSystem.ReadAllText(fileDoc.Name);
fileText = $"@using {blazorIdentityModel.BlazorIdentityNamespace}.Shared" + Environment.NewLine + fileText;
FileSystem.WriteAllText(fileDoc.Name, fileText.ToString());
Logger.LogMessage($"Modified {fileDoc.Name}.\n");
if (!fileText.Contains(usingStatement, StringComparison.OrdinalIgnoreCase))
{
fileText = usingStatement + Environment.NewLine + fileText;
FileSystem.WriteAllText(fileDoc.Name, fileText.ToString());
Logger.LogMessage($"Modified {fileDoc.Name}.\n");
}
}
}
}

Просмотреть файл

@ -111,7 +111,8 @@
" <RedirectToLogin />",
" </NotAuthorized>",
" </AuthorizeRouteView>"
]
],
"CheckBlock": "<NotAuthorized>"
}
]
},
@ -124,6 +125,7 @@
" background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E\");",
"}"
],
"CheckBlock": "bi-lock-nav-menu",
"MultiLineBlock": [
".bi-list-nested-nav-menu {",
" background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E\");",
@ -151,6 +153,7 @@
"FileName" : "NavMenu.razor",
"Replacements": [
{
"CheckBlock": "@implements IDisposable",
"ReplaceSnippet": [
"<div class=\"top-row ps-3 navbar navbar-dark\">"
],
@ -161,6 +164,7 @@
]
},
{
"CheckBlock": "<AuthorizeView>",
"ReplaceSnippet": [
"<span class=\"bi bi-list-nested-nav-menu\" aria-hidden=\"true\"></span> Weather",
" </NavLink>",
@ -203,6 +207,7 @@
]
},
{
"CheckBlock": "OnInitialized()",
"MultiLineBlock": [
"@code {",
" private string? currentUrl;",
@ -238,9 +243,10 @@
"MultiLineBlock": [
"@using Microsoft.AspNetCore.Components.Forms",
"@using Microsoft.AspNetCore.Components.Authorization"
]
],
"CheckBlock": "Microsoft.AspNetCore.Components.Authorization"
}
]
}
]
}
}

Просмотреть файл

@ -553,7 +553,8 @@ namespace Microsoft.DotNet.Scaffolding.Shared.Project
if (change.ReplaceSnippet != null)
{
var replaceSnippet = string.Join(Environment.NewLine, change.ReplaceSnippet);
if (sourceFileString.Contains(replaceSnippet))
if (!sourceFileString.ContainsIgnoreCase(change.CheckBlock) &&
sourceFileString.ContainsIgnoreCase(replaceSnippet))
{
sourceFileString = sourceFileString.Replace(replaceSnippet, change.Block);
}