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
{{ message }}
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
By adhering to the format used by MSBuild to output warnings and errors to the standard output (which give us for free the capacity to surface these warnings/errors inside IDEs such as Visual Studio), we are required to define (at least) the following items:
Origin: tool name or filename, more broadly what is producing the warning/error. I think that if we are to make the warnings actionable by the user, we should show the filename where the warning is coming from together with the line and column.
Code: list of error/warning codes specific to the illinker, these have to be prefixed with a string that identifies the linker. There's an ongoing discussion related to this in the Roslyn repo.
Some examples of the MSBuild message format together with the complete list of its parameters can be found here.
I suspect we'll have to create 2 code groups (similar to what csc does with CSxxxx and CAxxxx) to cover cases where linker produces error/warning and linker analyzer produces error/warning
Trying to move forward with this, here's a table with all different messages that we currently log via LogMessage inside the linker, together with a proposed set of category, subcategory and error/warning code to use for these.
Text
Proposed category
Proposed subcategory
Proposed code
Location in codebase
Could not resolve '{assemblyName}' assembly dependency
Warning
Unresolved dependency
6001
MarkStep
Could not resolve '{typeName}' type dependency
Warning
Unresolved dependency
6002
MarkStep
Could not resolve dependency member '{member}' declared in type '{td.FullName}'
Error
Unresolved dependency
0001
MarkStep
Could not resolve type '{fullname}' for substitution
Error
0002
BodySubstituterStep
Could not match assembly '{name.FullName}' for substitution
Error
0003
BodySubstituterStep
Could not find method '{signature}' for substitution
Error
0004
BodySubstituterStep
Could not find field '{name}' for substitution.
Error
0005
BodySubstituterStep
Invalid value for '{signature}' stub
Error
0006
BodySubstituterStep
Unknown body modification '{action}' for '{signature}'
Error
0007
BodySubstituterStep
Substituted field '{name}' needs to be static field.
Error
0008
BodySubstituterStep
Missing 'value' attribute for field '{field}'.
Error
0009
BodySubstituterStep
Invalid value for '{field}': '{value}'.
Error
0010
BodySubstituterStep
Unreachable IL reduction is not supported for method '{Body.Method.FullName}'
Warning
6003
RemoveUnreachableBlockStep
Reduced '{reducer.InstructionsReplaced}' instructions in conditional branches for [{method.DeclaringType.Module.Assembly.Name}] method {method.FullName}
There might need to be an extensibility mechanism for custom steps, but I would hesitate to expose the full string/id/subcategory combination as public API. With the current API it will be difficult to ensure that the error codes and messages are used consistently.
I think the proposed table is very restrictive. Most (if not all) errors are actually not even warnings but normal messages
Here is my "rules table"
Severity
Logic
Error
The end-user must take action and there is a clear message about what that should be.
Warning
Severe issue which will most likely cause unintended behaviour.
Normal
Progress like messages.
Diagnostics
Information which will help us to diagnose unexpected behaviour or confirm correct behaviour.
where the enums map error IDs to format strings?
I'm not sure this will help actually. Is it better to duplicate the strings instead of the numbers? I think we can for custom steps expose different APIs for Error and Warnings.
Something like
public static MessageContainer CreateErrorMessage (string text, Type customStepType, string subcategory = MessageSubCategory.None, MessageOrigin? origin = null)
It would use always the same code but we would somehow encode the step type name into the message.
Is it better to duplicate the strings instead of the numbers?
Sorry, I wasn't clear enough. My concern wasn't with the duplication of IDs, but with the potential for IDs to be used with unrelated strings.
If we we have messages that are sometimes warnings and sometimes errors, we could avoid duplication by using a single enum for both warnings and errors. What I meant to say was that this unifies the ID with the warning/error string. If we need to share error strings this could also look like:
We will be using IDs only for errors and warnings. I think it's a good idea to have an enum where we put a list of all the possible e/w the linker could log, and then map these to a string format. For e/w coming from custom steps, we could simply provide a specific ID where a plain string needs to be passed.
I think it's a good idea to have an enum where we put a list of all the possible e/w the linker could log
Why do you think this is a good idea?
For e/w coming from custom steps, we could simply provide a specific ID where a plain string needs to be passed.
Right so we would hide the id on the API but perhaps we can use custom step name instead of MessageOrigin which will probably not be used by custom steps
I think that having an enum and mapping it to a string format could help us have a cleaner API while avoiding any potential mistakes on the text/ID pairs. It can also be a good way to keep track of all the different messages that we know the illinker can log and the correspondence between these and the IDs.
perhaps we can use custom step name instead of MessageOrigin which will probably not be used by custom steps
Yes, I think that for custom steps we can receive its type as you proposed and use it as a kind of 'origin', and then provide a special ID for this scenario.
I think that having an enum and mapping it to a string format could help us have a cleaner API while avoiding any potential mistakes on the text/ID pairs.
How does using an enum as a definitive list of warnings/errors make it any harder to build documentation for that list? It seems to me that putting them in one place would make it easier if anything.
I can appreciate the desire to see the actual number in the code where it originates from. So what if the enum is the exact string something like:
enumCodes{IL6001=6001,// What is this forIL6002=6002,// What is this for second...}
I like the enum as it's easy to make sure when adding a new code that it's unique. And the code in this case would naturally act as developers documentation.
As for custom steps - I'm not sure we should restrict custom steps to exactly one code. The code acts as two things:
A short and specific way to identify the type of issue when looking it up in docs, discussing in issues, with support and so on.
A way to identify a type of issue for which to modify behavior - in case of warnings, to be able to disable the warning selectively.
If we restrict the custom steps to single code they have potentially issues like this:
If they need both errors and warnings, those would end up with the same code. While not unheard of (C# sometimes does this as well), it's relatively a bad practice I think
If they have a set of warnings for which it would be beneficial to disable them without disabling the rest of warnings from that custom step - there would be no way to do that - basically either all or nothing approach.
On the other hand, if we allow more than one, it creates a problem with assigning ranges. But we will have the problem of assigning numbers to custom steps even if they have just one anyway.
I like the enum as it's easy to make sure when adding a new code that it's unique. And the code in this case would naturally act as developers documentation.
I'd much rather not to have this documented in the code but in proper documentation .md file. If we go with the additional enum type people will probably update just that and not the documentation page so for that reason I'd rather avoid duplicating the information.
If they need both errors and warnings, those would end up with the same code.
We'd give unique number to custom warnings and custom errors (basically 2 different codes).
If they have a set of warnings for which it would be beneficial to disable them without disabling the rest of warnings from that custom step
Yep but is that bad thing? You can disable a warning in specific code region only.
On the other hand, if we allow more than one, it creates a problem with assigning ranges.
Thinking about it we should probably enable custom ids in specific ranges and have an additional page with codes documentation for custom steps. The risk of theoretically overlapping codes is not worth compromising on usability.
Ok, so we'll keep things as they currently are and create a MD file to track all the errors and warnings that could possibly be logged by the linker. I'll start by changing all current instances of LogMessage in places where we should report a warning to use the new MessageContainer and I'll create a markdown file to keep track of its IDs and messages. For the IDs I'll just start with 2001 for the warnings. We can later decide which range are we to reserve for custom steps.
I would actually leave out 4xxx and 9xxx - just to leave us some wiggle room for the future. 7K should be enough codes for everyone (famous last words ;-))
Reacted by Mateo Torres-Ruiz
Reacted by Sven Boemer and Tlakaelel Axayakatl Ceja
Activity
marek-safar commentedon Mar 11, 2020
I suspect we'll have to create 2 code groups (similar to what csc does with CSxxxx and CAxxxx) to cover cases where linker produces error/warning and linker analyzer produces error/warning
mateoatr commentedon Apr 3, 2020
Trying to move forward with this, here's a table with all different messages that we currently log via
LogMessageinside the linker, together with a proposed set ofcategory,subcategoryand error/warningcodeto use for these.Could not resolve '{assemblyName}' assembly dependencyCould not resolve '{typeName}' type dependencyCould not resolve dependency member '{member}' declared in type '{td.FullName}'Could not resolve type '{fullname}' for substitutionCould not match assembly '{name.FullName}' for substitutionCould not find method '{signature}' for substitutionCould not find field '{name}' for substitution.Invalid value for '{signature}' stubUnknown body modification '{action}' for '{signature}'Substituted field '{name}' needs to be static field.Missing 'value' attribute for field '{field}'.Invalid value for '{field}': '{value}'.Unreachable IL reduction is not supported for method '{Body.Method.FullName}'Reduced '{reducer.InstructionsReplaced}' instructions in conditional branches for [{method.DeclaringType.Module.Assembly.Name}] method {method.FullName}Output action: {action,8} assembly: {assembly}sbomer commentedon Apr 4, 2020
Regarding #968 and #1064:
This API allows arbitrary messages/subcategories with arbitrary error codes
and also seems a bit verbose.
Should we consider instead exposing methods that give a single source of truth for warnings and errors? Something like:
where the enums map error IDs to format strings?
There might need to be an extensibility mechanism for custom steps, but I would hesitate to expose the full string/id/subcategory combination as public API. With the current API it will be difficult to ensure that the error codes and messages are used consistently.
marek-safar commentedon Apr 6, 2020
I think the proposed table is very restrictive. Most (if not all) errors are actually not even warnings but normal messages
Here is my "rules table"
I'm not sure this will help actually. Is it better to duplicate the strings instead of the numbers? I think we can for custom steps expose different APIs for Error and Warnings.
Something like
It would use always the same code but we would somehow encode the step type name into the message.
sbomer commentedon Apr 6, 2020
Sorry, I wasn't clear enough. My concern wasn't with the duplication of IDs, but with the potential for IDs to be used with unrelated strings.
If we we have messages that are sometimes warnings and sometimes errors, we could avoid duplication by using a single enum for both warnings and errors. What I meant to say was that this unifies the ID with the warning/error string. If we need to share error strings this could also look like:
I think we should use an API where each ID maps to a specific format string, not one that can combine IDs/strings arbitrarily.
mateoatr commentedon Apr 6, 2020
We will be using IDs only for errors and warnings. I think it's a good idea to have an enum where we put a list of all the possible e/w the linker could log, and then map these to a string format. For e/w coming from custom steps, we could simply provide a specific ID where a plain string needs to be passed.
marek-safar commentedon Apr 6, 2020
Why do you think this is a good idea?
Right so we would hide the id on the API but perhaps we can use custom step name instead of MessageOrigin which will probably not be used by custom steps
mateoatr commentedon Apr 7, 2020
I think that having an enum and mapping it to a string format could help us have a cleaner API while avoiding any potential mistakes on the text/ID pairs. It can also be a good way to keep track of all the different messages that we know the illinker can log and the correspondence between these and the IDs.
Yes, I think that for custom steps we can receive its type as you proposed and use it as a kind of 'origin', and then provide a special ID for this scenario.
marek-safar commentedon Apr 7, 2020
I actually see that as bad practice. The goal of the error codes is for end-users and support to easily find them, understand them or refer to them at any point in time. What I think we should do instead is to use numbers in code (no enums to keep the code readable) and have table (documentation) with all codes for all versions at https://github.com/mono/linker/blob/master/src/linker/ErrorCodes.md
I don't think this is worth "optimizing" for it. We keep maintaining a page with all codes and descriptions instead.
sbomer commentedon Apr 7, 2020
How does using an enum as a definitive list of warnings/errors make it any harder to build documentation for that list? It seems to me that putting them in one place would make it easier if anything.
vitek-karas commentedon Apr 7, 2020
I can appreciate the desire to see the actual number in the code where it originates from. So what if the enum is the exact string something like:
I like the enum as it's easy to make sure when adding a new code that it's unique. And the code in this case would naturally act as developers documentation.
As for custom steps - I'm not sure we should restrict custom steps to exactly one code. The code acts as two things:
If we restrict the custom steps to single code they have potentially issues like this:
On the other hand, if we allow more than one, it creates a problem with assigning ranges. But we will have the problem of assigning numbers to custom steps even if they have just one anyway.
marek-safar commentedon Apr 8, 2020
I'd much rather not to have this documented in the code but in proper documentation .md file. If we go with the additional enum type people will probably update just that and not the documentation page so for that reason I'd rather avoid duplicating the information.
We'd give unique number to custom warnings and custom errors (basically 2 different codes).
Yep but is that bad thing? You can disable a warning in specific code region only.
Thinking about it we should probably enable custom ids in specific ranges and have an additional page with codes documentation for custom steps. The risk of theoretically overlapping codes is not worth compromising on usability.
vitek-karas commentedon Apr 8, 2020
I don't understand this. C# can disable warnings locally in the source code, but linker won't have that ability. All warnings will be "global".
OK - It's just a matter of style I guess. I'm perfectly fine if we agree on having a doc instead (and make sure it's up to date in code reviews).
marek-safar commentedon Apr 8, 2020
Good point, that's another reason to go with range of codes for custom steps
mateoatr commentedon Apr 10, 2020
Ok, so we'll keep things as they currently are and create a MD file to track all the errors and warnings that could possibly be logged by the linker. I'll start by changing all current instances of
LogMessagein places where we should report a warning to use the newMessageContainerand I'll create a markdown file to keep track of its IDs and messages. For the IDs I'll just start with 2001 for the warnings. We can later decide which range are we to reserve for custom steps.marek-safar commentedon Apr 10, 2020
Let's do it now, the code using the custom codes will be written shortly.
My suggestion is to go with the following ranges
Core Linker
Errors: 1000 - 1999
Warnings: 2000 - 3999
Custom Steps
Errors: 5000 - 6999
Warnings: 7000 - 9999
with a recommendation for SDK with custom steps to reserve a range of 99 codes
mateoatr commentedon Apr 10, 2020
Is there any reason to not use values in 4xxx?
vitek-karas commentedon Apr 10, 2020
I would actually leave out 4xxx and 9xxx - just to leave us some wiggle room for the future. 7K should be enough codes for everyone (famous last words ;-))
marek-safar commentedon Apr 11, 2020
Yep, the intention was to have some flexibility for the future
vitek-karas commentedon Jun 8, 2020
Already done in multiple different PRs. The list is in https://github.com/mono/linker/blob/master/docs/error-codes.md,