Generated members
All members are public on an internal static partial class BuildInformation.
| Member | Type | Source | Example |
|---|---|---|---|
BuildAt |
static readonly DateTime (UTC) |
Time of compilation, or SOURCE_DATE_EPOCH |
2026-11-20T08:19:26.4210020Z |
Platform |
const string |
<PlatformTarget> |
AnyCpu, X64 |
WarningLevel |
const int |
<WarningLevel> |
10 |
Configuration |
const string |
<Configuration> |
Debug, Release, Staging |
IsReleaseBuild |
const bool |
<Optimize> |
false |
AssemblyVersion |
const string |
<AssemblyVersion> / <Version> |
1.0.0.0 |
AssemblyFileVersion |
const string |
<FileVersion> / <Version> |
1.0.0.0 |
AssemblyInformationalVersion |
const string |
<InformationalVersion> / <Version> + commit SHA |
1.0.0+f1e7437… |
AssemblyName |
const string |
<AssemblyName> |
MyApp |
AssemblyCompany |
const string |
<Company> |
LinkDotNet |
AssemblyCopyright |
const string |
<Copyright> |
LinkDotNet 2025 |
TargetFrameworkMoniker |
const string |
<TargetFramework> (per target when multi-targeting) |
net10.0 |
Nullability |
const string |
<Nullable> |
Enable, Disable, Warnings, Annotations |
Deterministic |
const bool |
<Deterministic> |
true |
AnalysisLevel |
const string |
<AnalysisLevel> |
10.0 |
ProjectDirectory |
const string |
Project directory, opt-in | /src/MyApp/ or empty |
Language |
const string |
Always C# | C# |
LanguageVersion |
const string |
<LangVersion> |
14.0 |
CompilerVersion |
const string |
Roslyn version used for the build | 5.12.0.0 |
DotNetSdkVersion |
const string |
Runtime hosting the compiler | .NET 11.0.0 |
DirectDependencies |
static readonly IReadOnlyList<Dependency> |
project.assets.json, opt-in |
Serilog.Sinks.Console 6.0.0 |
TransitiveDependencies |
static readonly IReadOnlyList<Dependency> |
project.assets.json, opt-in |
Serilog 4.0.0 |
DependenciesJson |
const string |
project.assets.json, opt-in |
{"direct":[…],"transitive":[…]} |
Dependency is a nested class with Name and Version properties; ToString() returns "Name Version".
What the generated file looks like
Abbreviated output of LinkDotNet.BuildInformation.g.cs:
// <auto-generated>
using System;
using System.Globalization;
internal static partial class BuildInformation
{
/// <summary>
/// Returns the build date (UTC) in ISO 8601 format.
/// </summary>
/// <remarks>Value is: 2026-11-20T08:19:26.4210020Z</remarks>
public static readonly DateTime BuildAt = DateTime.ParseExact("2026-11-20T08:19:26.4210020Z", "O", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
/// <summary>
/// Returns the configuration.
/// </summary>
/// <remarks>Value is: Debug</remarks>
public const string Configuration = "Debug";
// ...
}
To inspect the full file, add this to your project and build:
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
</PropertyGroup>
The file is written to obj/<Configuration>/<TargetFramework>/generated/LinkDotNet.BuildInformation/.
Using it as a constant
Because most members are const, the compiler can remove dead branches and you can use them where constants are required:
if (BuildInformation.IsReleaseBuild)
{
// removed from Debug builds
}
[Obsolete($"Built with {BuildInformation.Configuration}")]
public void Legacy() { }
BuildAt, DirectDependencies and TransitiveDependencies are static readonly and cannot be used this way.
Extending the class
The class is partial, so you can add your own members next to the generated ones:
internal static partial class BuildInformation
{
public static string Summary => $"{AssemblyName} {AssemblyInformationalVersion} ({Configuration})";
}