Skip to content
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.DotNet.Scaffolding.Shared.T4Templating;
using Microsoft.DotNet.Scaffolding.TextTemplating;

namespace Microsoft.DotNet.Tools.Scaffold.AspNet.Templates.net8.BlazorCrud
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.DotNet.Scaffolding.Shared.T4Templating;
using Microsoft.DotNet.Scaffolding.TextTemplating;

namespace Microsoft.DotNet.Tools.Scaffold.AspNet.Templates.net8.BlazorCrud
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.DotNet.Scaffolding.Shared.T4Templating;
using Microsoft.DotNet.Scaffolding.TextTemplating;

namespace Microsoft.DotNet.Tools.Scaffold.AspNet.Templates.net8.BlazorCrud
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.DotNet.Scaffolding.Shared.T4Templating;
using Microsoft.DotNet.Scaffolding.TextTemplating;

namespace Microsoft.DotNet.Tools.Scaffold.AspNet.Templates.net8.BlazorCrud
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.DotNet.Scaffolding.Shared.T4Templating;
using Microsoft.DotNet.Scaffolding.TextTemplating;

namespace Microsoft.DotNet.Tools.Scaffold.AspNet.Templates.net8.BlazorCrud
{
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,17 @@
"--page", "CRUD");
Assert.True(cliExitCode == 0, $"CLI scaffold should succeed.\nOutput: {cliOutput}\nError: {cliError}");

// Assert — expected files were created (only if scaffolding produced output;
// the scaffolder may silently skip file generation for older TFMs if model
// resolution or template execution encounters issues)
// Assert — expected files were created
var blazorPagesDir = Path.Combine(_testProjectDir, "Components", "Pages", "TestModelPages");
bool scaffoldingProducedFiles = Directory.Exists(blazorPagesDir);
if (scaffoldingProducedFiles)
Assert.True(Directory.Exists(blazorPagesDir), $"Blazor pages directory '{blazorPagesDir}' should be created.");
foreach (var page in new[] { "Create.razor", "Delete.razor", "Details.razor", "Edit.razor", "Index.razor" })
{
foreach (var page in new[] { "Create.razor", "Delete.razor", "Details.razor", "Edit.razor", "Index.razor" })

Check failure on line 68 in test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs

View check run for this annotation

Azure Pipelines / scaffolding-ci (Build Linux debug_configuration)

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs#L68

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs(68,26): error CS0136: A local or parameter named 'page' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

Check failure on line 68 in test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs

View check run for this annotation

Azure Pipelines / scaffolding-ci (Build Linux release_configuration)

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs#L68

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs(68,26): error CS0136: A local or parameter named 'page' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

Check failure on line 68 in test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs

View check run for this annotation

Azure Pipelines / scaffolding-ci (Build OSX release_configuration)

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs#L68

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs(68,26): error CS0136: A local or parameter named 'page' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

Check failure on line 68 in test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs

View check run for this annotation

Azure Pipelines / scaffolding-ci (Build OSX debug_configuration)

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs#L68

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs(68,26): error CS0136: A local or parameter named 'page' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

Check failure on line 68 in test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs

View check run for this annotation

Azure Pipelines / scaffolding-ci

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs#L68

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs(68,26): error CS0136: A local or parameter named 'page' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter
{
Assert.True(File.Exists(Path.Combine(blazorPagesDir, page)), $"Blazor page '{page}' should be created.");
}

var editContent = File.ReadAllText(Path.Combine(blazorPagesDir, "Edit.razor"));

Check failure on line 73 in test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs

View check run for this annotation

Azure Pipelines / scaffolding-ci (Build Linux debug_configuration)

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs#L73

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs(73,17): error CS0136: A local or parameter named 'editContent' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

Check failure on line 73 in test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs

View check run for this annotation

Azure Pipelines / scaffolding-ci (Build Linux release_configuration)

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs#L73

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs(73,17): error CS0136: A local or parameter named 'editContent' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

Check failure on line 73 in test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs

View check run for this annotation

Azure Pipelines / scaffolding-ci (Build OSX release_configuration)

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs#L73

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs(73,17): error CS0136: A local or parameter named 'editContent' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

Check failure on line 73 in test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs

View check run for this annotation

Azure Pipelines / scaffolding-ci (Build OSX debug_configuration)

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs#L73

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs(73,17): error CS0136: A local or parameter named 'editContent' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

Check failure on line 73 in test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs

View check run for this annotation

Azure Pipelines / scaffolding-ci

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs#L73

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs(73,17): error CS0136: A local or parameter named 'editContent' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter
Assert.Contains("ApplicationState.TryTakeFromJson<TestModel>(nameof(TestModel), out var restoredTestModel)", editContent);
Assert.Contains("TestModel = restoredTestModel", editContent);
Assert.Contains("ApplicationState.PersistAsJson(nameof(TestModel), TestModel)", editContent);
Expand All @@ -87,8 +85,24 @@
// Assert — no NuGet errors and project builds after scaffolding
Assert.False(cliOutput.Contains("error: NU"),
$"Scaffolding should not produce NuGet errors for {TargetFramework}.\nOutput: {cliOutput}");
var (afterExitCode, _, afterError) = await RunBuildAsync(_testProjectDir);

Check failure on line 88 in test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs

View check run for this annotation

Azure Pipelines / scaffolding-ci (Build Linux debug_configuration)

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs#L88

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs(88,18): error CS0136: A local or parameter named 'afterExitCode' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

Check failure on line 88 in test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs

View check run for this annotation

Azure Pipelines / scaffolding-ci (Build Linux debug_configuration)

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs#L88

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs(88,36): error CS0136: A local or parameter named 'afterError' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

Check failure on line 88 in test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs

View check run for this annotation

Azure Pipelines / scaffolding-ci (Build Linux release_configuration)

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs#L88

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs(88,18): error CS0136: A local or parameter named 'afterExitCode' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

Check failure on line 88 in test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs

View check run for this annotation

Azure Pipelines / scaffolding-ci (Build Linux release_configuration)

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs#L88

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs(88,36): error CS0136: A local or parameter named 'afterError' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

Check failure on line 88 in test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs

View check run for this annotation

Azure Pipelines / scaffolding-ci (Build OSX release_configuration)

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs#L88

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs(88,18): error CS0136: A local or parameter named 'afterExitCode' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

Check failure on line 88 in test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs

View check run for this annotation

Azure Pipelines / scaffolding-ci (Build OSX release_configuration)

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs#L88

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs(88,36): error CS0136: A local or parameter named 'afterError' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

Check failure on line 88 in test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs

View check run for this annotation

Azure Pipelines / scaffolding-ci (Build OSX debug_configuration)

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs#L88

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs(88,18): error CS0136: A local or parameter named 'afterExitCode' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

Check failure on line 88 in test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs

View check run for this annotation

Azure Pipelines / scaffolding-ci (Build OSX debug_configuration)

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs#L88

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs(88,36): error CS0136: A local or parameter named 'afterError' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

Check failure on line 88 in test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs

View check run for this annotation

Azure Pipelines / scaffolding-ci

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs#L88

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs(88,18): error CS0136: A local or parameter named 'afterExitCode' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

Check failure on line 88 in test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs

View check run for this annotation

Azure Pipelines / scaffolding-ci

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs#L88

test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Integration/Blazor/BlazorCrudNet8IntegrationTests.cs(88,36): error CS0136: A local or parameter named 'afterError' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter
Assert.True(afterExitCode == 0, $"Project should still build after scaffolding. Error: {afterError}");
Assert.True(File.Exists(Path.Combine(blazorPagesDir, page)), $"Blazor page '{page}' should be created.");
}
var editContent = File.ReadAllText(Path.Combine(blazorPagesDir, "Edit.razor"));
Assert.Contains("ApplicationState.TryTakeFromJson<TestModel>(nameof(TestModel), out var restoredTestModel)", editContent);
Assert.Contains("TestModel = restoredTestModel", editContent);
Assert.Contains("ApplicationState.PersistAsJson(nameof(TestModel), TestModel)", editContent);
Assert.True(File.Exists(Path.Combine(_testProjectDir, "Data", "TestDbContext.cs")),
"DbContext file 'Data/TestDbContext.cs' should be created.");
var programContent = File.ReadAllText(Path.Combine(_testProjectDir, "Program.cs"));
Assert.Contains("builder.Configuration.GetConnectionString", programContent);
Assert.Contains("builder.Services.AddDbContextFactory<TestDbContext>", programContent);

// Assert — no NuGet errors and project builds after scaffolding
Assert.False(cliOutput.Contains("error: NU"),
$"Scaffolding should not produce NuGet errors for {TargetFramework}.\nOutput: {cliOutput}");
var (afterExitCode, _, afterError) = await RunBuildAsync(_testProjectDir);
Assert.True(afterExitCode == 0, $"Project should still build after scaffolding. Error: {afterError}");
}
}
Loading