Skip to content

Conversation

@axunonb
Copy link
Collaborator

@axunonb axunonb commented Jun 26, 2025

Summary:
Changed the default encoding for all serializers to UTF-8 without BOM (new UTF8Encoding(false)). This ensures compatibility with iCalendar consumers that do not support BOM and provides consistent encoding across all serialization operations.

Affected serializers:
All serializers inheriting from SerializerBase, ComponentSerializer, EncodableDataTypeSerializer, or DataTypeSerializer now default to UTF-8 without BOM unless an explicit encoding is provided.

  • Directly from SerializerBase:

    • SimpleDeserializer
    • ComponentSerializer
    • DataMapSerializer
    • DataTypes.DataTypeSerializer
    • DataTypes.DateTimeSerializer
    • DataTypes.DurationSerializer
    • GenericListSerializer
    • ParameterSerializer
    • PropertySerializer
  • From ComponentSerializer:

    • CalendarSerializer
    • EventSerializer
    • SerializerFactory
  • From EncodableDataTypeSerializer or DataTypeSerializer:

    • DataTypes.AttachmentSerializer
    • DataTypes.EnumSerializer
    • DataTypes.GeographicLocationSerializer
    • DataTypes.IntegerSerializer
    • DataTypes.PeriodListSerializer
    • DataTypes.PeriodSerializer
    • DataTypes.RecurrencePatternSerializer
    • DataTypes.StringSerializer
    • DataTypes.UriSerializer
    • DataTypes.UtcOffsetSerializer
    • DataTypes.WeekDaySerializer

Rationale:
Ensures all iCalendar output is encoded in UTF-8 without BOM by default, as required by many consumers.

Resolves #823

@codecov
Copy link

codecov bot commented Jun 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

❌ Your project status has failed because the head coverage (68%) is below the target coverage (80%). You can increase the head coverage or adjust the target coverage.

Impacted file tree graph

@@         Coverage Diff         @@
##           main   #827   +/-   ##
===================================
  Coverage    68%    68%           
===================================
  Files       106    106           
  Lines      4216   4217    +1     
  Branches    941    942    +1     
===================================
+ Hits       2849   2850    +1     
  Misses     1039   1039           
  Partials    328    328           
Files with missing lines Coverage Δ
Ical.Net/Serialization/SerializerBase.cs 53% <100%> (+2%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Summary:
Changed the default encoding for all serializers to UTF-8 without BOM (`new UTF8Encoding(false)`). This ensures compatibility with iCalendar consumers that do not support BOM and provides consistent encoding across all serialization operations.

Affected serializers:
All serializers inheriting from `SerializerBase`, `ComponentSerializer`, `EncodableDataTypeSerializer`, or `DataTypeSerializer` now default to UTF-8 without BOM unless an explicit encoding is provided.

- **Directly from `SerializerBase`:**
  - `SimpleDeserializer`
  - `ComponentSerializer`
  - `DataMapSerializer`
  - `DataTypes.DataTypeSerializer`
  - `DataTypes.DateTimeSerializer`
  - `DataTypes.DurationSerializer`
  - `GenericListSerializer`
  - `ParameterSerializer`
  - `PropertySerializer`

- **From `ComponentSerializer`:**
  - `CalendarSerializer`
  - `EventSerializer`
  - `SerializerFactory`

- **From `EncodableDataTypeSerializer` or `DataTypeSerializer`:**
  - `DataTypes.AttachmentSerializer`
  - `DataTypes.EnumSerializer`
  - `DataTypes.GeographicLocationSerializer`
  - `DataTypes.IntegerSerializer`
  - `DataTypes.PeriodListSerializer`
  - `DataTypes.PeriodSerializer`
  - `DataTypes.RecurrencePatternSerializer`
  - `DataTypes.StringSerializer`
  - `DataTypes.UriSerializer`
  - `DataTypes.UtcOffsetSerializer`
  - `DataTypes.WeekDaySerializer`

**Rationale:**
Ensures all iCalendar output is encoded in UTF-8 without BOM by default, as required by many consumers.
@axunonb axunonb force-pushed the wip/axunonb/pr/utf8-no-bom branch from 6aee7a2 to 877568c Compare June 26, 2025 20:02
@axunonb axunonb requested a review from minichma June 26, 2025 20:04
@minichma
Copy link
Collaborator

minichma commented Jul 4, 2025

Not sure, I understand this correctly. As the method is only invoked from test cases, this only makes a difference when invoked from externally if omitting the encoding, right? Doesn't this also affect all the places where serialization is triggered internally? Were searching for UTF8 throughout the code base and found 17 matches. Do they require individual attention?

@axunonb
Copy link
Collaborator Author

axunonb commented Jul 4, 2025

this only makes a difference when invoked from externally

Yes. Without an encoding parameter we use UTF8 without BOM for serialization (writing).

Doesn't this also affect all the places where serialization is triggered internally

Yes, as far as writing is concerned. For reading, BOM-handling is transparent by .Net.

UTF8 throughout the code base and found 17 matches

All where writing is concerned should be covered.

@axunonb axunonb merged commit 4588209 into main Jul 4, 2025
4 checks passed
@axunonb axunonb deleted the wip/axunonb/pr/utf8-no-bom branch July 4, 2025 14:29
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jul 4, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iCalendar UTF8 Encoding with/without BOM

3 participants