Skip to content

Commit

Permalink
Deprecate stand-alone error message and fieldset tag helpers (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
gunndabad authored Jan 14, 2025
1 parent 40f4fe4 commit f5123d0
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#### `asp-for` attributes
The `asp-for` attribute is now obsolete; the `for` attribute should be used in its place.

#### `<govuk-error-message>` and `<govuk-fieldset>` tag helpers
The `<govuk-error-message>` and `<govuk-fieldset>` tag helpers are deprecated and will be removed in a future release.

## 2.8.0

Targets GOV.UK Frontend v5.8.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<NoWarn>CS0618</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace GovUk.Frontend.AspNetCore.TagHelpers;
/// </summary>
[HtmlTargetElement(TagName)]
[OutputElementHint(ComponentGenerator.ErrorMessageElement)]
[Obsolete("This tag helper will be removed in a future release.")]
public class ErrorMessageTagHelper : TagHelper
{
internal const string TagName = "govuk-error-message";
Expand Down
4 changes: 4 additions & 0 deletions src/GovUk.Frontend.AspNetCore/TagHelpers/FieldsetContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ public void SetLegend(

if (Legend != null)
{
#pragma warning disable CS0618 // Type or member is obsolete
throw ExceptionHelper.OnlyOneElementIsPermittedIn(
FieldsetLegendTagHelper.TagName,
FieldsetTagHelper.TagName);
#pragma warning restore CS0618 // Type or member is obsolete
}

Legend = (isPageHeading, attributes, content);
Expand All @@ -28,7 +30,9 @@ public void ThrowIfNotComplete()
{
if (Legend == null)
{
#pragma warning disable CS0618 // Type or member is obsolete
throw ExceptionHelper.AChildElementMustBeProvided(FieldsetLegendTagHelper.TagName);
#pragma warning restore CS0618 // Type or member is obsolete
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Threading.Tasks;
using GovUk.Frontend.AspNetCore.HtmlGeneration;
using Microsoft.AspNetCore.Razor.TagHelpers;
Expand All @@ -9,6 +10,7 @@ namespace GovUk.Frontend.AspNetCore.TagHelpers;
/// </summary>
[HtmlTargetElement(TagName, ParentTag = FieldsetTagHelper.TagName)]
[OutputElementHint(ComponentGenerator.FieldsetLegendElement)]
[Obsolete("This tag helper will be removed in a future release.")]
public class FieldsetLegendTagHelper : TagHelper
{
internal const string TagName = "govuk-fieldset-legend";
Expand Down
2 changes: 2 additions & 0 deletions src/GovUk.Frontend.AspNetCore/TagHelpers/FieldsetTagHelper.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Threading.Tasks;
using GovUk.Frontend.AspNetCore.HtmlGeneration;
using Microsoft.AspNetCore.Html;
Expand All @@ -11,6 +12,7 @@ namespace GovUk.Frontend.AspNetCore.TagHelpers;
/// </summary>
[HtmlTargetElement(TagName)]
[OutputElementHint(ComponentGenerator.FieldsetElement)]
[Obsolete("This tag helper will be removed in a future release.")]
public class FieldsetTagHelper : TagHelper
{
internal const string TagName = "govuk-fieldset";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.AspNetCore.Razor.TagHelpers;
using Moq;
using Xunit;
#pragma warning disable CS0618 // Type or member is obsolete

namespace GovUk.Frontend.AspNetCore.Tests.TagHelpers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Xunit;
#pragma warning disable CS0618 // Type or member is obsolete

namespace GovUk.Frontend.AspNetCore.Tests.TagHelpers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Xunit;
#pragma warning disable CS0618 // Type or member is obsolete

namespace GovUk.Frontend.AspNetCore.Tests.TagHelpers;

Expand Down

0 comments on commit f5123d0

Please sign in to comment.