Skip to content

Replace FileVersionInfo.GetVersionInfo with DecompilerVersionInfo.Version constant#3667

Merged
siegfriedpammer merged 2 commits intoicsharpcode:masterfrom
MattParkerDev:use-assembly-name
Feb 24, 2026
Merged

Replace FileVersionInfo.GetVersionInfo with DecompilerVersionInfo.Version constant#3667
siegfriedpammer merged 2 commits intoicsharpcode:masterfrom
MattParkerDev:use-assembly-name

Conversation

@MattParkerDev
Copy link
Contributor

Problem

FileVersionInfo.GetVersionInfo requires a path to an assembly on disk. This fails in cases where the assembly has been loaded as a stream, rather than from a file.

Solution

This PR replaces it with Assembly.GetName().Version, which I have verified returns the same string, in my case - "9.1.0.7988".

@siegfriedpammer
Copy link
Member

This is a good catch. I wonder why we are using FileVersionInfo in the first place, given that there is DecompilerVersionInfo, which is generated/updated on every build. So there should be no need for FileVersionInfo at runtime nor reflection.

Suggestion:

  • You could add public const string FileVersion = Major + "." + Minor + "." + Build + "." + Revision; to DecompilerVersionInfo.template.cs
  • Use it in AssemblyInfo.cs and PortablePdbWriter.cs

This would eliminate the need for a file path AND make it AOT-/single-file bundle compatible, since we don't rely on reflection.

@siegfriedpammer
Copy link
Member

siegfriedpammer commented Feb 22, 2026

Addendum: I think, I found another reason for not using reflection: #2691

Seems constructing System.Reflection.AssemblyName involves a lot more than one might think and may cause weird effects.

@MattParkerDev
Copy link
Contributor Author

Good idea, done! :)

@MattParkerDev MattParkerDev changed the title Use Assembly.GetName().Version instead of FileVersionInfo.GetVersionInfo Replace FileVersionInfo.GetVersionInfo with DecompilerVersionInfo.Version constant Feb 22, 2026
@siegfriedpammer siegfriedpammer merged commit 6965945 into icsharpcode:master Feb 24, 2026
5 checks passed
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.

2 participants