Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 13 additions & 4 deletions Ical.Net/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,21 @@ public static class LibraryMetadata

private static string GetAssemblyVersion()
{
string? version;
var assembly = typeof(LibraryMetadata).Assembly;
var fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);

// Prefer the file version, but fall back to the assembly version if it's not available.
return fileVersionInfo.FileVersion
?? assembly.GetName().Version?.ToString() // will only change for major versions
?? "1.0.0.0";
try
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code introduced in this GitHub comment doesn't work for WebAssembly? The advantage was that we wouldn't need the try/catch. In both cases, caching the value would be advantageous.

Copy link
Contributor Author

@b-straub b-straub Jun 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, was too fast with my fix. Working indeed, so you can throw away the pull request and replace with the suggested code.

{
var fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
version = fileVersionInfo.FileVersion;
}
catch (Exception)
{
version = assembly.GetName().Version?.ToString();
}

return version ?? "2.0";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see below regarding "2.0"

}
}

Expand Down
1 change: 1 addition & 0 deletions Ical.Net/Ical.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<AssemblyOriginatorKeyFile>..\IcalNetStrongnameKey.snk</AssemblyOriginatorKeyFile>
<nullable>enable</nullable>
<LangVersion>latest</LangVersion>
<AssemblyVersion>2.0</AssemblyVersion>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All version attributes get set during publishing with the CI workflow.
Mixing up 2.0 with the iCalendar version defined in RFC 5545 Section 3.7.4?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. Anyway obsolete see comment above.

</PropertyGroup>
<ItemGroup>
<PackageReference Include="NodaTime" Version="3.2.2" />
Expand Down
Loading