-
Couldn't load subscription status.
- Fork 4.2k
Expand #error version output to include compiler assembly path and use full commit SHA everywhere #80894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: jcouv <[email protected]>
Co-authored-by: jcouv <[email protected]>
|
@copilot The existing output of |
Co-authored-by: jcouv <[email protected]>
Done! Switched to using the full commit SHA in commit 1fac3d9. Changes made:
The output now shows the full 40-character SHA (e.g., |
8724a59 to
1fac3d9
Compare
|
@copilot Let's replace all usages of shortened SHA with full SHA. We don't need to keep short SHA logic anymore |
Co-authored-by: jcouv <[email protected]>
Done! Removed all short SHA logic in commit 0d15c99. Changes made:
This simplifies the codebase by 43 net lines while ensuring all version outputs (both |
|
Could this break tools that parse the output? |
Possibly, if there's any. But I don't think the output is specified/locked. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (commit 5)

Summary
This PR enhances the C# compiler's
#error versiondirective to include the path of the current compiler assembly and consistently uses the full commit SHA throughout all version outputs, making it easier for developers to troubleshoot version-related issues.Changes
The implementation makes two key enhancements to the existing
ERR_CompilerAndLanguageVersiondiagnostic and simplifies the version string generation throughout the compiler:Before:
After:
Key Implementation Details
Added
GetAssemblyLocation(Type type)method inCommonCompiler.csthat retrieves the assembly location and returns<unknown>for edge cases like single-file deployments whereAssembly.Locationmay be emptyModified
GetProductVersion(Type type)method inCommonCompiler.csto use the full commit SHA directly fromCommitHashAttributeinstead of truncating to 8 charactersRemoved short SHA logic: Eliminated
ExtractShortCommitHash(),GetShortCommitHash(),GetFullCommitHash(), andGetProductVersionWithFullHash()methods to simplify the codebase and ensure consistent use of full commit SHA everywhereUpdated
DirectiveParser.csto callGetProductVersionandGetAssemblyLocation, passing both the full SHA and assembly path to the error diagnosticModified the error message format in
CSharpResources.resxto include a third placeholder for the compiler pathUpdated tests in
PreprocessorTests.csto validate the new output format with full SHARemoved the
ExtractShortCommitHashtest that's no longer applicableCode Simplification
This change results in a net reduction of 43 lines of code while improving consistency:
GetProductVersion()now handles all version string generation#error versionand/version)Testing
All existing tests pass, including:
TestErrorWithVersiontests across different language versionsCompatibility
This change only affects the diagnostic message text for
#error versionand version display output. It does not modify any APIs or change compiler behavior beyond the error message format and version string display. The change maintains backward compatibility while providing more detailed version information.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.