Skip to content
This repository was archived by the owner on Nov 10, 2026. It is now read-only.

feat: add WhichAreReadOnly/WhichAreRefStructs filters and assertions for types - #277

Merged
vbreuss merged 3 commits into
mainfrom
feature/232-readonly-refstruct-types
May 31, 2026
Merged

vbreuss merged 3 commits into
mainfrom
feature/232-readonly-refstruct-types

Conversation

@vbreuss

@vbreuss vbreuss commented May 31, 2026

Copy link
Copy Markdown
Member

Add readonly-struct and ref-struct (IsByRefLike) support for types, paralleling the existing struct/sealed members:

  • Filters: WhichAreReadOnly/WhichAreNotReadOnly, WhichAreRefStructs/WhichAreNotRefStructs
  • Single assertions: IsReadOnly/IsNotReadOnly, IsARefStruct/IsNotARefStruct
  • Many assertions: AreReadOnly/AreNotReadOnly, AreRefStructs/AreNotRefStructs

Detection is attribute-based (IsReadOnlyAttribute / IsByRefLikeAttribute) via GetCustomAttributesData, so it works on netstandard2.0 where Type.IsByRefLike is unavailable.


@vbreuss vbreuss self-assigned this May 31, 2026
@vbreuss vbreuss added the enhancement New feature or request label May 31, 2026
@vbreuss
vbreuss enabled auto-merge (squash) May 31, 2026 19:03
@github-actions

github-actions Bot commented May 31, 2026 •

Copy link
Copy Markdown

Test Results

    13 files  ±  0      13 suites  ±0   6m 3s ⏱️ +37s
 4 970 tests + 79   4 967 ✅ + 79   3 💤 ±0  0 ❌ ±0 
29 800 runs  +474  29 787 ✅ +474  13 💤 ±0  0 ❌ ±0 

Results for commit 38fef89. ± Comparison against base commit a7541a3.

♻️ This comment has been updated with latest results.

@vbreuss
vbreuss disabled auto-merge May 31, 2026 19:09
@github-actions

github-actions Bot commented May 31, 2026 •

Copy link
Copy Markdown

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.4 LTS (Noble Numbat)
AMD EPYC 7763 2.99GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.300
[Host] : .NET 10.0.8 (10.0.8, 10.0.826.23019), X64 RyuJIT x86-64-v3
DefaultJob : .NET 10.0.8 (10.0.8, 10.0.826.23019), X64 RyuJIT x86-64-v3

Method Mean Error StdDev Gen0 Allocated
TypeIsNotStatic_aweXpect 208.0 ns 1.75 ns 1.64 ns 0.0386 648 B

@github-actions

github-actions Bot commented May 31, 2026 •

Copy link
Copy Markdown

👽 Mutation Results

Mutation testing badge

aweXpect.Reflection

Details
File Score Killed Survived Timeout No Coverage Ignored Compile Errors Total Detected Total Undetected Total Mutants
Filters/TypeFilters.WhichAreReadOnly.cs 100.00% 3 0 0 0 0 0 3 0 3
Filters/TypeFilters.WhichAreRefStructs.cs 100.00% 3 0 0 0 0 0 3 0 3
Helpers/TypeHelpers.cs 96.67% 203 5 0 2 63 14 203 7 287
ThatType.IsARefStruct.cs 100.00% 7 0 0 0 2 6 7 0 15
ThatType.IsReadOnly.cs 100.00% 10 0 0 0 3 6 10 0 19
ThatTypes.AreReadOnly.cs 100.00% 18 0 0 0 4 12 18 0 34
ThatTypes.AreRefStructs.cs 100.00% 18 0 0 0 4 12 18 0 34

The final mutation score is 97.40%

Coverage Thresholds: high:80 low:60 break:0

vbreuss added 3 commits May 31, 2026 21:15
…for types (#232)

Add readonly-struct and ref-struct (IsByRefLike) support for types,
paralleling the existing struct/sealed members:

- Filters: WhichAreReadOnly/WhichAreNotReadOnly,
  WhichAreRefStructs/WhichAreNotRefStructs
- Single assertions: IsReadOnly/IsNotReadOnly, IsARefStruct/IsNotARefStruct
- Many assertions: AreReadOnly/AreNotReadOnly, AreRefStructs/AreNotRefStructs

Detection is attribute-based (IsReadOnlyAttribute / IsByRefLikeAttribute)
via GetCustomAttributesData, so it works on netstandard2.0 where
Type.IsByRefLike is unavailable.
- Simplify HasNamedAttribute loop to a LINQ Any() call (S3267)
- Use collection-initializer TheoryData instead of collection-expression
  to avoid zero-length array allocation warning (CA1825)
@vbreuss
vbreuss force-pushed the feature/232-readonly-refstruct-types branch from 131a7b0 to 38fef89 Compare May 31, 2026 19:15
@vbreuss
vbreuss enabled auto-merge (squash) May 31, 2026 19:15
@sonarqubecloud

Copy link
Copy Markdown

@vbreuss
vbreuss disabled auto-merge May 31, 2026 19:21
@vbreuss
vbreuss merged commit c2ac4c1 into main May 31, 2026
11 checks passed
@vbreuss
vbreuss deleted the feature/232-readonly-refstruct-types branch May 31, 2026 19:21
@github-actions

Copy link
Copy Markdown

This is addressed in release v1.5.0.

@github-actions github-actions Bot added the state: released The issue is released label May 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WhichAreReadOnly() and WhichAreRefStructs() filters and assertions for types

1 participant