From 05bf1f5b7a545b342fb6caa2dc560689a38d5567 Mon Sep 17 00:00:00 2001 From: lulunac27a <100660343+lulunac27a@users.noreply.github.com> Date: Sun, 10 Nov 2024 19:19:52 -0600 Subject: [PATCH] Add namespaces to fix warnings --- text-counter-razor/Pages/Error.cshtml.cs | 39 +++++++++--------- text-counter-razor/Pages/Index.cshtml.cs | 23 ++++++----- .../Pages/TextCounter.cshtml.cs | 41 ++++++++++--------- 3 files changed, 54 insertions(+), 49 deletions(-) diff --git a/text-counter-razor/Pages/Error.cshtml.cs b/text-counter-razor/Pages/Error.cshtml.cs index 6189b83..9d66b3d 100644 --- a/text-counter-razor/Pages/Error.cshtml.cs +++ b/text-counter-razor/Pages/Error.cshtml.cs @@ -1,26 +1,27 @@ -using System.Diagnostics; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace text_counter_razor.Pages; - -[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] -[IgnoreAntiforgeryToken] -public class ErrorModel : PageModel +namespace text_counter_razor.Pages { - public string? RequestId { get; set; } + using System.Diagnostics; + using Microsoft.AspNetCore.Mvc; + using Microsoft.AspNetCore.Mvc.RazorPages; - public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + [IgnoreAntiforgeryToken] + public class ErrorModel : PageModel + { + public string? RequestId { get; set; } - private readonly ILogger _logger; + public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); - public ErrorModel(ILogger logger) - { - _logger = logger; - } + private readonly ILogger _logger; - public void OnGet() - { - RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; + public ErrorModel(ILogger logger) + { + _logger = logger; + } + + public void OnGet() + { + RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; + } } } diff --git a/text-counter-razor/Pages/Index.cshtml.cs b/text-counter-razor/Pages/Index.cshtml.cs index 9a4ceda..1f12625 100644 --- a/text-counter-razor/Pages/Index.cshtml.cs +++ b/text-counter-razor/Pages/Index.cshtml.cs @@ -1,16 +1,17 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace text_counter_razor.Pages; - -public class IndexModel : PageModel +namespace text_counter_razor.Pages { - private readonly ILogger _logger; + using Microsoft.AspNetCore.Mvc; + using Microsoft.AspNetCore.Mvc.RazorPages; - public IndexModel(ILogger logger) + public class IndexModel : PageModel { - _logger = logger; - } + private readonly ILogger _logger; - public void OnGet() { } + public IndexModel(ILogger logger) + { + _logger = logger; + } + + public void OnGet() { } + } } diff --git a/text-counter-razor/Pages/TextCounter.cshtml.cs b/text-counter-razor/Pages/TextCounter.cshtml.cs index e8dc284..a35f84c 100644 --- a/text-counter-razor/Pages/TextCounter.cshtml.cs +++ b/text-counter-razor/Pages/TextCounter.cshtml.cs @@ -1,24 +1,27 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -public class TextCounterModel : PageModel +namespace text_counter_razor.Pages { - [BindProperty] - public string? TextContent { get; set; } //text content string input from text box - public int Characters { get; set; } //number of characters - public int Words { get; set; } //number of words - public int Lines { get; set; } //number of lines + using Microsoft.AspNetCore.Mvc; + using Microsoft.AspNetCore.Mvc.RazorPages; - public void OnPost() + public class TextCounterModel : PageModel { - this.TextContent = this.Request.Form["textContent"]; //get text box input - this.Characters = this.TextContent?.Length ?? 0; //update number of characters, words and lines based on entered text - this.Words = - this.TextContent?.Split( - new char[] { ' ', '\r', '\n' }, - StringSplitOptions.RemoveEmptyEntries - ).Length ?? 0; - this.Lines = - this.TextContent?.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length ?? 0; + [BindProperty] + public string? TextContent { get; set; } //text content string input from text box + public int Characters { get; set; } //number of characters + public int Words { get; set; } //number of words + public int Lines { get; set; } //number of lines + + public void OnPost() + { + this.TextContent = this.Request.Form["textContent"]; //get text box input + this.Characters = this.TextContent?.Length ?? 0; //update number of characters, words and lines based on entered text + this.Words = + this.TextContent?.Split( + new char[] { ' ', '\r', '\n' }, + StringSplitOptions.RemoveEmptyEntries + ).Length ?? 0; + this.Lines = + this.TextContent?.Split('\n', StringSplitOptions.RemoveEmptyEntries).Length ?? 0; + } } }