Skip to content

Allow external warnings to use codes >= 6001#1609

Merged
mateoatr merged 5 commits intodotnet:masterfrom
mateoatr:externalWanings
Nov 6, 2020
Merged

Allow external warnings to use codes >= 6001#1609
mateoatr merged 5 commits intodotnet:masterfrom
mateoatr:externalWanings

Conversation

@mateoatr
Copy link
Contributor

@mateoatr mateoatr commented Nov 5, 2020

Fixes #1596.

/cc @rolfbjarne

Ignore in mono
Mateo Torres Ruiz added 2 commits November 6, 2020 10:02
@mateoatr mateoatr merged commit ebc6155 into dotnet:master Nov 6, 2020
/// <returns>Custom MessageContainer of 'Error' category</returns>
public static MessageContainer CreateCustomErrorMessage (string text, int code, string subcategory = MessageSubCategory.None, MessageOrigin? origin = null)
{
var callingAssembly = Assembly.GetCallingAssembly ();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is redundant

var callingAssembly = Assembly.GetCallingAssembly ();
#if DEBUG
Debug.Assert (!(Assembly.GetCallingAssembly () == typeof (MessageContainer).Assembly),
"Internal error: 'CreateCustomErrorMessage' is intended to be used by external assemblies only. Use 'CreateErrorMessage' instead.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to prefix Assert with Internal error:

{
var callingAssembly = Assembly.GetCallingAssembly ();
#if DEBUG
Debug.Assert (!(Assembly.GetCallingAssembly () == typeof (MessageContainer).Assembly),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just use != instead

"Internal error: 'CreateCustomWarningMessage' is intended to be used by external assemblies only. Use 'CreateWarningMessage' instead.");
#endif
if (code <= 6000)
throw new ArgumentException ($"The provided code '{code}' does not fall into the permitted range for external warnings. To avoid possible collisions " +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be ArgumentOutOfRangeException

mateoatr added a commit that referenced this pull request Nov 9, 2020
* Follow up

* Add parameter to exception

* Fix formatting
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
* Allow external warnings and errors to have codes >= 6001

* Fix whitespace formatting
Ignore in mono

* Add CreateCustomWarningMessage

* Fix assert

* Fix formatting

Commit migrated from dotnet/linker@ebc6155
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
* Follow up

* Add parameter to exception

* Fix formatting

Commit migrated from dotnet/linker@1ce464d
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.

Custom steps can't use error codes outside [1000, 2000]

4 participants