Skip to content

Commit

Permalink
Adding the README to the NuGet meta data. Also enabled the NetAnalyze…
Browse files Browse the repository at this point in the history
…rs and fixed some of the warnings.
  • Loading branch information
jooni91 committed Apr 23, 2022
1 parent effdb84 commit 5f4f1df
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 15 deletions.
4 changes: 2 additions & 2 deletions docs/Griesoft.AspNetCore.ReCaptcha.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/ReCaptcha/Configuration/RecaptchaOptions.cs
Expand Up @@ -12,7 +12,7 @@ public class RecaptchaOptions
/// <summary>
/// If set to true the remote IP will be send to Google when verifying the response token. The default is false.
/// </summary>
public bool UseRemoteIp { get; set; } = false;
public bool UseRemoteIp { get; set; }

/// <summary>
/// Configure the service on a global level whether it should block / short circuit the request pipeline
Expand Down
2 changes: 1 addition & 1 deletion src/ReCaptcha/Extensions/TagHelperOutputExtensions.cs
Expand Up @@ -72,7 +72,7 @@ internal static void AddClass(this TagHelperOutput tagHelperOutput, string class

var encodedSpaceChars = SpaceChars.Where(x => !x.Equals('\u0020')).Select(x => htmlEncoder.Encode(x.ToString(CultureInfo.InvariantCulture))).ToArray();

if (SpaceChars.Any(classValue.Contains) || encodedSpaceChars.Any(value => classValue.IndexOf(value, StringComparison.Ordinal) >= 0))
if (SpaceChars.Any(classValue.Contains) || encodedSpaceChars.Any(value => classValue.Contains(value)))
{
throw new ArgumentException(null, nameof(classValue));
}
Expand Down
10 changes: 10 additions & 0 deletions src/ReCaptcha/ReCaptcha.csproj
Expand Up @@ -21,6 +21,9 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationFile>..\..\docs\Griesoft.AspNetCore.ReCaptcha.xml</DocumentationFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<EnableNETAnalyzers>True</EnableNETAnalyzers>
<AnalysisLevel>latest-recommended</AnalysisLevel>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -48,6 +51,13 @@
<Folder Include="Properties\" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<Compile Update="Localization\Resources.Designer.cs">
<DesignTime>True</DesignTime>
Expand Down
8 changes: 4 additions & 4 deletions src/ReCaptcha/TagHelpers/RecaptchaInvisibleTagHelper.cs
Expand Up @@ -74,7 +74,7 @@ public class RecaptchaInvisibleTagHelper : TagHelper
/// <summary>
/// Set the tabindex of the reCAPTCHA element. If other elements in your page use tabindex, it should be set to make user navigation easier.
/// </summary>
public int? TabIndex { get; set; } = null;
public int? TabIndex { get; set; }

/// <summary>
/// The id of the form that will be submitted after a successful reCAPTCHA challenge.
Expand All @@ -86,7 +86,7 @@ public class RecaptchaInvisibleTagHelper : TagHelper
/// Set the name of your callback function, which is called when the reCAPTCHA challenge was successful.
/// A "g-recaptcha-response" token is added to your callback function parameters for server-side verification.
/// </summary>
public string Callback { get; set; } = string.Empty;
public string? Callback { get; set; }

/// <summary>
/// Set the name of your callback function, executed when the reCAPTCHA response expires and the user needs to re-verify.
Expand All @@ -101,14 +101,14 @@ public class RecaptchaInvisibleTagHelper : TagHelper

/// <inheritdoc />
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="NullReferenceException">Thrown when both <see cref="Callback"/> and <see cref="FormId"/> are null or empty.</exception>
/// <exception cref="InvalidOperationException">Thrown when both <see cref="Callback"/> and <see cref="FormId"/> are null or empty.</exception>
public override void Process(TagHelperContext context, TagHelperOutput output)
{
_ = output ?? throw new ArgumentNullException(nameof(output));

if (string.IsNullOrEmpty(Callback) && string.IsNullOrEmpty(FormId))
{
throw new NullReferenceException(Resources.CallbackPropertyNullErrorMessage);
throw new InvalidOperationException(Resources.CallbackPropertyNullErrorMessage);
}

if (output.TagName == "button")
Expand Down
4 changes: 2 additions & 2 deletions src/ReCaptcha/TagHelpers/RecaptchaScriptTagHelper.cs
Expand Up @@ -63,7 +63,7 @@ public override void Process(TagHelperContext context, TagHelperOutput output)

if (!string.IsNullOrEmpty(OnloadCallback) && !Render.HasFlag(Render.V3))
{
queryCollection.Add("onload", OnloadCallback);
queryCollection.Add("onload", OnloadCallback!);
}

if (Render == (Render.V3 | Render.Explicit))
Expand All @@ -77,7 +77,7 @@ public override void Process(TagHelperContext context, TagHelperOutput output)

if (!string.IsNullOrEmpty(Language) && !Render.HasFlag(Render.V3))
{
queryCollection.Add("hl", Language);
queryCollection.Add("hl", Language!);
}

output.Attributes.SetAttribute("src", TagHelperOutputExtensions.AddQueryString(RecaptchaScriptEndpoint, queryCollection));
Expand Down
2 changes: 1 addition & 1 deletion src/ReCaptcha/TagHelpers/RecaptchaTagHelper.cs
Expand Up @@ -64,7 +64,7 @@ public RecaptchaTagHelper(IOptionsMonitor<RecaptchaSettings> settings, IOptionsM
/// <summary>
/// Set the tabindex of the reCAPTCHA element. If other elements in your page use tabindex, it should be set to make user navigation easier.
/// </summary>
public int? TabIndex { get; set; } = null;
public int? TabIndex { get; set; }

/// <summary>
/// Set the name of your callback function, executed when the user submits a successful response. The "g-recaptcha-response" token is passed to your callback.
Expand Down
8 changes: 4 additions & 4 deletions src/ReCaptcha/TagHelpers/RecaptchaV3TagHelper.cs
Expand Up @@ -65,7 +65,7 @@ public RecaptchaV3TagHelper(IOptionsMonitor<RecaptchaSettings> settings, ITagHel
/// Set the name of your callback function, which is called when the reCAPTCHA challenge was successful.
/// A "g-recaptcha-response" token is added to your callback function parameters for server-side verification.
/// </summary>
public string Callback { get; set; } = string.Empty;
public string? Callback { get; set; }

/// <summary>
/// The name of the action that was triggered.
Expand All @@ -75,19 +75,19 @@ public RecaptchaV3TagHelper(IOptionsMonitor<RecaptchaSettings> settings, ITagHel

/// <inheritdoc />
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="NullReferenceException">Thrown when both <see cref="Callback"/> and <see cref="FormId"/> or <see cref="Action"/> are/is null or empty.</exception>
/// <exception cref="InvalidOperationException">Thrown when both <see cref="Callback"/> and <see cref="FormId"/> or <see cref="Action"/> are/is null or empty.</exception>
public override void Process(TagHelperContext context, TagHelperOutput output)
{
_ = output ?? throw new ArgumentNullException(nameof(output));

if (string.IsNullOrEmpty(Callback) && string.IsNullOrEmpty(FormId))
{
throw new NullReferenceException(Resources.CallbackPropertyNullErrorMessage);
throw new InvalidOperationException(Resources.CallbackPropertyNullErrorMessage);
}

if (string.IsNullOrEmpty(Action))
{
throw new NullReferenceException(Resources.ActionPropertyNullErrorMessage);
throw new InvalidOperationException(Resources.ActionPropertyNullErrorMessage);
}

if (string.IsNullOrEmpty(Callback))
Expand Down

0 comments on commit 5f4f1df

Please sign in to comment.