You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Version Used:
How can I get compiler's version? Steps to Reproduce:
Create a new .Net 8.0 WinFrom application
Add below method in above application
public static DateTime? GetBuildDateTime(this Assembly assembly)
{
var location = assembly.Location;
var buildDateTime = default(DateTime?);
try
{
using var fileStream = new FileStream(location, FileMode.Open, FileAccess.Read);
using var peReader = new PEReader(fileStream);
buildDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc)
.AddSeconds(peReader.PEHeaders.CoffHeader.TimeDateStamp)
.ToLocalTime();
}
finally
{
}
return buildDateTime;
}
Call above method and pass 'Assembly.GetEntryAssembly()' in
Diagnostic Id:
Expected Behavior:
I hope this method will read a correct compile time from PEHeaders.CoffHeader.TimeDateStamp;
Actual Behavior:
I got a negative integer from PEHeaders.CoffHeader.TimeDateStamp, and incorrect compile time;
Some details:
Bytes wrotten in binary program file:
Hex value readed from PEReader:
Got build date time:
The text was updated successfully, but these errors were encountered:
CuteLeon
changed the title
Roslyn wrote icorrect timedatestime to PE Coff Header of a .Net 8.0 program file
Roslyn wrote incorrect timedatestime to PE Coff Header of a .Net 8.0 program file
Jun 28, 2024
The value of field TimeDateStamp in COFF File Header of a deterministic PE/COFF file does not indicate the date and time when the file was produced and should not be interpreted that way. Instead the value of the field is derived from a hash of the file content.
I implement another solution is that: Create a new AssemblyCompileDateTimeAttribute class and a SourceGenerator project to inject AssemblyCompileDateTimeAttribute declaretion into each project.
Version Used:
How can I get compiler's version?
Steps to Reproduce:
Diagnostic Id:
Expected Behavior:
I hope this method will read a correct compile time from PEHeaders.CoffHeader.TimeDateStamp;
Actual Behavior:
I got a negative integer from PEHeaders.CoffHeader.TimeDateStamp, and incorrect compile time;
Some details:
![image](https://private-user-images.githubusercontent.com/17419770/344093201-e53b8859-8b6a-49a7-b620-6df1393b5f05.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXV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JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.RnuuoShObdCwAq2rM0JEcoHVDOjS6w3XOTY0QNFGMfw)
Bytes wrotten in binary program file:
Hex value readed from PEReader:
Got build date time:
The text was updated successfully, but these errors were encountered: