Summary
Couldn't the framework (and doc examples) save one more vertical line with file-scoped namespaces by collapsing the namespace line into any lines at the top of the file (e.g., make it the last line or the first line)?
Motivation and goals
My understanding is that one of the benefits of this feature is to vertically collapse code. As implemented today, it only saves one line that doesn't affect scrolling. Only the final brace } line is dropped/saved.
Risks / unknowns
I think the risk of disorganization is low.
Example
src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Pages/Error.cshtml.cs:
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace ComponentsWebAssembly_CSharp.Server.Pages;
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
...
}
... TO ...
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace ComponentsWebAssembly_CSharp.Server.Pages;
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
...
}
... OR with the namespace at the top of the file ...
namespace ComponentsWebAssembly_CSharp.Server.Pages;
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
...
}
🤔
I kind'a like it at the top of the file. That locates it quickly at a glance 👀, which is all that placing it on a line with vertical space around it seems to accomplish.
Summary
Couldn't the framework (and doc examples) save one more vertical line with file-scoped namespaces by collapsing the
namespaceline into any lines at the top of the file (e.g., make it the last line or the first line)?Motivation and goals
My understanding is that one of the benefits of this feature is to vertically collapse code. As implemented today, it only saves one line that doesn't affect scrolling. Only the final brace
}line is dropped/saved.Risks / unknowns
I think the risk of disorganization is low.
Example
src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Pages/Error.cshtml.cs:... TO ...
... OR with the namespace at the top of the file ...
🤔
I kind'a like it at the top of the file. That locates it quickly at a glance 👀, which is all that placing it on a line with vertical space around it seems to accomplish.