Skip to content
Merged
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
72 changes: 10 additions & 62 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,77 +4,25 @@ root = true
charset = utf-8
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
insert_final_newline = true
resharper_csharp_max_line_length = 160

[*.{cshtml,css,yml,props,targets,csproj}]
indent_size = 2

[*.min.js]
insert_final_newline = false

[*.{cs,cshtml}]
resharper_csharp_max_line_length = 160

[*.cs]
# IDE0079: Remove unnecessary suppression
dotnet_remove_unnecessary_suppression_exclusions = category:ReSharper

# IDE0079: Remove unnecessary suppression
# dotnet_diagnostic.IDE0079.severity = none

# CA2255: The 'ModuleInitializer' attribute should not be used in libraries
dotnet_diagnostic.CA2255.severity = none

# CS8600: Converting null literal or possible null value to non-nullable type.
dotnet_diagnostic.CS8600.severity = error

# CS8601: Possible null reference assignment.
dotnet_diagnostic.CS8601.severity = error

# CS8602: Dereference of a possibly null reference.
dotnet_diagnostic.CS8602.severity = error

# CS8603: Possible null reference return.
dotnet_diagnostic.CS8603.severity = error

# CS8604: Possible null reference argument.
dotnet_diagnostic.CS8604.severity = error

# CS8610: Nullability of reference types in type of parameter doesn't match overridden member.
dotnet_diagnostic.CS8610.severity = error

# CS8613: Nullability of reference types in return type doesn't match implicitly implemented member.
dotnet_diagnostic.CS8613.severity = error

# CS8614: Nullability of reference types in type of parameter doesn't match implicitly implemented member.
dotnet_diagnostic.CS8614.severity = error

# CS8618: Non-nullable field is uninitialized. Consider declaring as nullable.
dotnet_diagnostic.CS8618.severity = error

# CS8619: Nullability of reference types in value doesn't match target type.
dotnet_diagnostic.CS8619.severity = error

# CS8620: Argument cannot be used for parameter due to differences in the nullability of reference types.
dotnet_diagnostic.CS8620.severity = error

# CS8625: Cannot convert null literal to non-nullable reference type.
dotnet_diagnostic.CS8625.severity = error

# CS8634: The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match 'class' constraint.
dotnet_diagnostic.CS8634.severity = error

# CS8643: Nullability of reference types in explicit interface specifier doesn't match interface implemented by the type.
dotnet_diagnostic.CS8643.severity = error

# CS8653: A default expression introduces a null value for a type parameter.
dotnet_diagnostic.CS8653.severity = error

# CS8714: The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match 'notnull' constraint.
dotnet_diagnostic.CS8714.severity = error

# IDE0059: Unnecessary assignment of a value
dotnet_diagnostic.IDE0059.severity = none
[tests/**.cs]
# CA1707: Identifiers should not contain underscores
# Tests follow the Method_Condition_ExpectedResult naming convention.
dotnet_diagnostic.CA1707.severity = none

# IDE0060: Remove unused parameter
dotnet_diagnostic.IDE0060.severity = none
# CA1859: Use concrete types when possible for improved performance
# Tests exercise interface contracts and use abstract ASP.NET Core types.
dotnet_diagnostic.CA1859.severity = none
15 changes: 15 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project>
<PropertyGroup>
<NoWarn>$(NoWarn);CS0649</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>
<AnalysisMode>Recommended</AnalysisMode>
<AnalysisModeStyle>Default</AnalysisModeStyle>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
</PropertyGroup>
</Project>
1 change: 1 addition & 0 deletions Ramstack.HtmxToolkit.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<File Path=".editorconfig" />
<File Path=".gitattributes" />
<File Path=".gitignore" />
<File Path="Directory.Build.props" />
<File Path="LICENSE" />
<File Path="package.json" />
<File Path="README.md" />
Expand Down
4 changes: 4 additions & 0 deletions src/Ramstack.HtmxToolkit/Properties/JetBrains.Annotations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// ReSharper disable CheckNamespace
// ReSharper disable ConvertToPrimaryConstructor

using System.Diagnostics.CodeAnalysis;

namespace JetBrains.Annotations;

/// <summary>
Expand Down Expand Up @@ -163,6 +165,8 @@ internal enum ImplicitUseKindFlags
/// with <see cref="MeansImplicitUseAttribute"/> or <see cref="UsedImplicitlyAttribute"/>.
/// </summary>
[Flags]
[SuppressMessage("Design", "CA1069:Enums values should not be duplicated",
Justification = "JetBrains annotations intentionally declare Default as an alias before Itself.")]
internal enum ImplicitUseTargetFlags
{
Default = Itself,
Expand Down
5 changes: 0 additions & 5 deletions src/Ramstack.HtmxToolkit/Ramstack.HtmxToolkit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
<Deterministic>true</Deterministic>
</PropertyGroup>

<PropertyGroup>
<NoWarn>649;1591</NoWarn>
<WarningsAsErrors>CS8600;CS8601;CS8602;CS8603;CS8604;CS8610;CS8613;CS8614;CS8618;CS8619;CS8620;CS8625;CS8643;CS8653;CS8714</WarningsAsErrors>
</PropertyGroup>

<PropertyGroup>
<RepositoryUrl>https://github.com/rameel/ramstack.htmxtoolkit</RepositoryUrl>
<Authors>Rameel</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ public void Constructor_FromSmallDictionary_WithDifferentComparer_ReSortsEntries
public void Constructor_NullCollection_ThrowsArgumentNullException()
{
Assert.Throws<ArgumentNullException>(
() => new SmallDictionary<int, string>(null!, Comparer<int>.Default));
() => _ = new SmallDictionary<int, string>(null!, Comparer<int>.Default));
}

[Test]
public void Constructor_NullComparer_ThrowsArgumentNullException()
{
Assert.Throws<ArgumentNullException>(
() => new SmallDictionary<int, string>([], null!));
() => _ = new SmallDictionary<int, string>([], null!));
}

[Test]
Expand Down Expand Up @@ -642,6 +642,8 @@ public void Enumerators_Reset_ThrowsNotSupportedException()
}

[Test]
[SuppressMessage("Performance", "CA1841:Prefer dictionary Contains methods",
Justification = "The test exercises the Keys collection's Contains implementation.")]
public void ConfiguredComparer_AllOperations_UseComparerForKeyIdentity()
{
IDictionary<string, int> dictionary = new SmallDictionary<string, int>(StringComparer.OrdinalIgnoreCase);
Expand Down
3 changes: 3 additions & 0 deletions tests/Ramstack.HtmxToolkit.Tests/HtmxFieldValuesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public void Constructor_Array_StoresArrayWithoutCopying()
}

[Test]
[SuppressMessage("ReSharper", "UseArrayEmptyMethod")]
[SuppressMessage("Performance", "CA1825:Avoid zero-length array allocations",
Justification = "A distinct empty array verifies that the constructor preserves reference identity.")]
public void Constructor_EmptyArray_PreservesArrayRepresentation()
{
var source = new string [0];
Expand Down
2 changes: 1 addition & 1 deletion tests/Ramstack.HtmxToolkit.Tests/HtmxResponseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public void TriggerEvent_Htmx4_AddsEveryTimingToReceiveTrigger()

[JsonSourceGenerationOptions(WriteIndented = true, PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)]
[JsonSerializable(typeof(TriggerEventDetail))]
internal partial class TriggerEventJsonSerializerContext : JsonSerializerContext;
internal sealed partial class TriggerEventJsonSerializerContext : JsonSerializerContext;

internal sealed class TriggerEventDetail
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
</PropertyGroup>

<ItemGroup>
<Using Include="System.Diagnostics.CodeAnalysis" />
<Using Include="NUnit.Framework" />
<Using Include="Ramstack.HtmxToolkit.Internal" />
<Using Include="Ramstack.HtmxToolkit.TagHelpers" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ public async Task ProcessAsync_SerializesOnlyHtmx1Options()

var json = await RenderJson(options);

Assert.That(json.Keys, Is.EquivalentTo(new[]
{
Assert.That(json.Keys, Is.EquivalentTo(
[
"historyEnabled", "historyCacheSize", "refreshOnHistoryMiss", "defaultSwapStyle",
"defaultSwapDelay", "defaultSettleDelay", "includeIndicatorStyles", "indicatorClass",
"requestClass", "addedClass", "swappingClass", "settlingClass", "allowEval",
Expand All @@ -161,7 +161,7 @@ public async Task ProcessAsync_SerializesOnlyHtmx1Options()
"selfRequestsOnly", "scrollBehavior", "defaultFocusScroll", "getCacheBusterParam",
"globalViewTransitions", "methodsThatUseUrlParams", "ignoreTitle", "scrollIntoViewOnBoost",
"triggerSpecsCache"
}));
]));
Assert.That(json["defaultSwapStyle"].GetString(), Is.EqualTo("outerHTML"));
Assert.That(json["wsBinaryType"].GetString(), Is.EqualTo("arraybuffer"));
Assert.That(json["scrollBehavior"].GetString(), Is.EqualTo("smooth"));
Expand Down Expand Up @@ -219,8 +219,8 @@ public async Task ProcessAsync_SerializesOnlyHtmx2Options_InResponseHandlingOrde

var json = await RenderJson(options);

Assert.That(json.Keys, Is.EquivalentTo(new[]
{
Assert.That(json.Keys, Is.EquivalentTo(
[
"historyEnabled", "historyCacheSize", "refreshOnHistoryMiss", "defaultSwapStyle",
"defaultSwapDelay", "defaultSettleDelay", "includeIndicatorStyles", "indicatorClass",
"requestClass", "addedClass", "swappingClass", "settlingClass", "allowEval",
Expand All @@ -230,7 +230,7 @@ public async Task ProcessAsync_SerializesOnlyHtmx2Options_InResponseHandlingOrde
"getCacheBusterParam", "globalViewTransitions", "methodsThatUseUrlParams", "ignoreTitle",
"scrollIntoViewOnBoost", "triggerSpecsCache", "responseHandling", "allowNestedOobSwaps",
"historyRestoreAsHxRequest", "reportValidityOfForms"
}));
]));
Assert.That(json["defaultSwapStyle"].GetString(), Is.EqualTo("innerHTML"));
Assert.That(json["scrollBehavior"].GetString(), Is.EqualTo("instant"));

Expand Down Expand Up @@ -270,14 +270,14 @@ public async Task ProcessAsync_SerializesOnlyHtmx4Options()

var json = await RenderJson(options);

Assert.That(json.Keys, Is.EquivalentTo(new[]
{
Assert.That(json.Keys, Is.EquivalentTo(
[
"logAll", "prefix", "history", "defaultSwap", "allowEmptySwapAfterOOB",
"defaultSettleDelay", "includeIndicatorCSS", "indicatorClass", "requestClass",
"inlineScriptNonce", "extensions", "implicitInheritance", "defaultTimeout", "mode",
"defaultFocusScroll", "transitions", "morphIgnore", "morphSkip", "morphSkipChildren",
"morphScanLimit", "noSwap"
}));
]));
Assert.That(json["history"].GetString(), Is.EqualTo("reload"));
Assert.That(json["defaultSwap"].GetString(), Is.EqualTo("outerMorph"));
Assert.That(json["mode"].GetString(), Is.EqualTo("no-cors"));
Expand Down
Loading