Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateo Torres-Ruiz <mateoatr@users.noreply.github.com>2020-05-13 09:58:58 +0300
committerGitHub <noreply@github.com>2020-05-13 09:58:58 +0300
commitdf72dcfc27e27735c84c68507426a568799b66e9 (patch)
treed8f6b31389735e578d6fb960cb955fefa834962d
parentffec224a2a69f0cde4c43d9c90090dcb294ca6c6 (diff)
Use MessageContainer for logging errors (#1155)
* Log errors via MessageContainer * Use LinkerErrorExceptions for all throws. Don't stop linker on first error found. * Move FoundErrors to LinkContext and clean exceptions. * Use same code for errors with same message. * Fix test and whitespace formatting * Update exit message Co-authored-by: Marek Safar <marek.safar@gmail.com> * Add error for unexpected scenarios. * Print all inner exceptions. * Update FeatureSubstitutionsInvalid test. * Update docs/error-codes.md Co-authored-by: Sven Boemer <sbomer@gmail.com> * Print all inner exceptions in LinkerFatalErrorException * Whitespace formatting Co-authored-by: Marek Safar <marek.safar@gmail.com> Co-authored-by: Sven Boemer <sbomer@gmail.com>
-rw-r--r--docs/error-codes.md46
-rw-r--r--src/linker/Linker.Dataflow/ReflectionMethodBodyScanner.cs6
-rw-r--r--src/linker/Linker.Steps/BlacklistStep.cs6
-rw-r--r--src/linker/Linker.Steps/BodySubstituterStep.cs10
-rw-r--r--src/linker/Linker.Steps/LoadReferencesStep.cs3
-rw-r--r--src/linker/Linker.Steps/MarkStep.cs23
-rw-r--r--src/linker/Linker.Steps/OutputStep.cs2
-rw-r--r--src/linker/Linker.Steps/ResolveFromXmlStep.cs13
-rw-r--r--src/linker/Linker/Driver.cs10
-rw-r--r--src/linker/Linker/InternalErrorException.cs26
-rw-r--r--src/linker/Linker/LinkContext.cs2
-rw-r--r--src/linker/Linker/LinkerFatalErrorException.cs36
-rw-r--r--src/linker/Linker/LoadException.cs17
-rw-r--r--src/linker/Linker/MarkException.cs27
-rw-r--r--src/linker/Linker/MessageContainer.cs2
-rw-r--r--src/linker/Linker/OutputException.cs17
-rw-r--r--test/Mono.Linker.Tests.Cases.Expectations/Assertions/NoLinkedOutputAttribute.cs9
-rw-r--r--test/Mono.Linker.Tests.Cases/Logging/CommonLogs.cs6
-rw-r--r--test/Mono.Linker.Tests.Cases/Substitutions/FeatureSubstitutionsInvalid.cs15
-rw-r--r--test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs35
-rw-r--r--test/Mono.Linker.Tests/Tests/MessageContainerTests.cs4
21 files changed, 189 insertions, 126 deletions
diff --git a/docs/error-codes.md b/docs/error-codes.md
index d6c469799..bfe2d823b 100644
--- a/docs/error-codes.md
+++ b/docs/error-codes.md
@@ -7,9 +7,49 @@ error and warning codes.
## Error Codes
-#### `IL1001`: TBA
+#### `IL1001`: Failed to process XML substitution: 'XML document location'. Feature 'feature' does not specify a "featurevalue" attribute
-- The explaination of the first error code.
+- The substitution in 'XML document location' with feature value 'feature' does not use the `featurevalue` attribute. These attributes have to be used together.
+
+#### `IL1002`: Failed to process XML substitution: 'XML document location'. Unsupported non-boolean feature definition 'feature'
+
+- The substitution in 'XML document location' with feature value 'feature' sets the attribute `featurevalue` to a non-boolean value. Only boolean values are supported for this attribute.
+
+#### `IL1003`: Error processing 'XML document name': 'XmlException'
+
+- There was an error processing a resource linker descriptor, embedded resource linker descriptor or external substitution XML (`ILLink.Substitutions.xml`). The most likely reason for this is that the descriptor file has syntactical errors.
+
+#### `IL1004`: Failed to process description file 'XML document location': 'XmlException'
+
+- There was an error processing an XML descriptor. The most likely reason for this is that the descriptor file has syntactical errors.
+
+#### `IL1005`: Error processing method 'method' in assembly 'assembly'
+
+- There was an error processing method 'method'. An exception with more details is printed.
+
+#### `IL1006`: Cannot stub constructor on 'type' when base type does not have default constructor
+
+- There was an error trying to create a new instance of type 'type'. Its construtor was marked for substitution in a substitution XML, but the base type of 'type' doesn't have a default constructor. Constructors of derived types marked for substitution require to have a default constructor in its base type.
+
+#### `IL1007`: Missing predefined 'type' type
+
+#### `IL1008`: Could not find constructor on 'type'
+
+#### `IL1009`: Assembly 'assembly' reference 'reference' could not be resolved
+
+- There was en error resolving the reference assembly 'reference'. An exception with more details is printed.
+
+#### `IL1010`: Assembly 'assembly' cannot be loaded due to failure in processing 'reference' reference
+
+- The assembly 'assembly' could not be loaded due to an error processing the reference assembly 'reference'. An exception with more details is printed.
+
+#### `IL1011`: Failed to write 'output'
+
+- There was an error writing the linked assembly 'output'. An exception with more details is printed.
+
+#### `IL1012`: IL Linker has encountered an unexpected error. Please report the issue at https://github.com/mono/linker/issues
+
+- There was an unexpected error while linking. An exception with more details is printed to the MSBuild log. Please share this stack trace with the IL Linker team to further investigate the cause and possible solution.
----
## Warning Codes
@@ -96,4 +136,4 @@ error and warning codes.
#### `IL2021`: Could not find the set accessor of property 'property' in type 'type' specified in 'XML document location'
-- The XML descriptor preserves the set accessor of property 'property' on type 'type', but the accessor was not found. \ No newline at end of file
+- The XML descriptor preserves the set accessor of property 'property' on type 'type', but the accessor was not found.
diff --git a/src/linker/Linker.Dataflow/ReflectionMethodBodyScanner.cs b/src/linker/Linker.Dataflow/ReflectionMethodBodyScanner.cs
index 686b28b1b..337da994f 100644
--- a/src/linker/Linker.Dataflow/ReflectionMethodBodyScanner.cs
+++ b/src/linker/Linker.Dataflow/ReflectionMethodBodyScanner.cs
@@ -482,9 +482,7 @@ namespace Mono.Linker.Dataflow
break;
default:
- Debug.Fail ("Unsupported member type");
- reflectionContext.RecordUnrecognizedPattern ($"Reflection call '{calledMethod.FullName}' inside '{callingMethodBody.Method.FullName}' is of unexpected member type.");
- break;
+ throw new InternalErrorException ($"Reflection call '{calledMethod.FullName}' inside '{callingMethodBody.Method.FullName}' is of unexpected member type.");
}
if (memberKind == null)
@@ -512,7 +510,7 @@ namespace Mono.Linker.Dataflow
reflectionContext.RecordHandledPattern ();
break;
default:
- throw new MarkException (string.Format ("Error processing reflection call: '{0}' inside {1}. Unexpected member kind.", calledMethod.FullName, callingMethodBody.Method.FullName));
+ throw new InternalErrorException ($"Error processing reflection call '{calledMethod.FullName}' inside {callingMethodBody.Method.FullName}. Unexpected member kind.");
}
} else {
RequireDynamicallyAccessedMembers (ref reflectionContext, (DynamicallyAccessedMemberTypes) memberKind, value, calledMethod.Parameters[0]);
diff --git a/src/linker/Linker.Steps/BlacklistStep.cs b/src/linker/Linker.Steps/BlacklistStep.cs
index dc8332933..065f4b2be 100644
--- a/src/linker/Linker.Steps/BlacklistStep.cs
+++ b/src/linker/Linker.Steps/BlacklistStep.cs
@@ -55,7 +55,7 @@ namespace Mono.Linker.Steps
steps_to_add.Push (GetResolveStep (name));
} catch (XmlException ex) {
/* This could happen if some broken XML file is included. */
- Context.LogMessage ($"Error processing {name}: {ex}");
+ Context.LogMessage (MessageContainer.CreateErrorMessage ($"Error processing {name}: {ex}", 1003));
}
}
@@ -72,7 +72,7 @@ namespace Mono.Linker.Steps
steps_to_add.Push (GetExternalResolveStep (rsc, asm));
} catch (XmlException ex) {
/* This could happen if some broken XML file is embedded. */
- Context.LogMessage ($"Error processing {rsc.Name}: {ex}");
+ Context.LogMessage (MessageContainer.CreateErrorMessage ($"Error processing {rsc.Name}: {ex}", 1003));
}
}
@@ -83,7 +83,7 @@ namespace Mono.Linker.Steps
Context.LogMessage ($"Processing embedded {rsc.Name} from {asm.Name}");
steps_to_add.Push (GetExternalSubstitutionStep (rsc, asm));
} catch (XmlException ex) {
- Context.LogMessage ($"Error processing {rsc.Name}: {ex}");
+ Context.LogMessage (MessageContainer.CreateErrorMessage ($"Error processing {rsc.Name}: {ex}", 1003));
}
}
}
diff --git a/src/linker/Linker.Steps/BodySubstituterStep.cs b/src/linker/Linker.Steps/BodySubstituterStep.cs
index 17cab82e1..abcc5d64c 100644
--- a/src/linker/Linker.Steps/BodySubstituterStep.cs
+++ b/src/linker/Linker.Steps/BodySubstituterStep.cs
@@ -37,11 +37,7 @@ namespace Mono.Linker.Steps
if (!string.IsNullOrEmpty (_resourceName) && Context.IgnoreSubstitutions)
return;
- try {
- ReadSubstitutions (_document);
- } catch (Exception ex) when (!(ex is XmlResolutionException)) {
- throw new XmlResolutionException ($"Failed to process XML substitution: '{_xmlDocumentLocation}'", ex);
- }
+ ReadSubstitutions (_document);
}
bool ShouldProcessSubstitutions (XPathNavigator nav)
@@ -52,12 +48,12 @@ namespace Mono.Linker.Steps
var value = GetAttribute (nav, "featurevalue");
if (string.IsNullOrEmpty (value)) {
- Context.LogMessage (MessageContainer.CreateErrorMessage ($"Feature {feature} does not specify a \"featurevalue\" attribute", 1001));
+ Context.LogMessage (MessageContainer.CreateErrorMessage ($"Failed to process XML substitution: '{_xmlDocumentLocation}'. Feature {feature} does not specify a 'featurevalue' attribute", 1001));
return false;
}
if (!bool.TryParse (value, out bool bValue)) {
- Context.LogMessage (MessageContainer.CreateErrorMessage ($"Unsupported non-boolean feature definition {feature}", 1002));
+ Context.LogMessage (MessageContainer.CreateErrorMessage ($"Failed to process XML substitution: '{_xmlDocumentLocation}'. Unsupported non-boolean feature definition {feature}", 1002));
return false;
}
diff --git a/src/linker/Linker.Steps/LoadReferencesStep.cs b/src/linker/Linker.Steps/LoadReferencesStep.cs
index a2272852c..59928adcb 100644
--- a/src/linker/Linker.Steps/LoadReferencesStep.cs
+++ b/src/linker/Linker.Steps/LoadReferencesStep.cs
@@ -52,7 +52,8 @@ namespace Mono.Linker.Steps
try {
ProcessReferences (referenceDefinition);
} catch (Exception ex) {
- throw new LoadException ($"Assembly '{assembly.FullName}' cannot be loaded due to failure in processing '{referenceDefinition.FullName}' reference", ex);
+ throw new LinkerFatalErrorException (
+ MessageContainer.CreateErrorMessage ($"Assembly '{assembly.FullName}' cannot be loaded due to failure in processing '{referenceDefinition.FullName}' reference", 1010), ex);
}
}
}
diff --git a/src/linker/Linker.Steps/MarkStep.cs b/src/linker/Linker.Steps/MarkStep.cs
index 96af89382..53997b441 100644
--- a/src/linker/Linker.Steps/MarkStep.cs
+++ b/src/linker/Linker.Steps/MarkStep.cs
@@ -370,8 +370,10 @@ namespace Mono.Linker.Steps
(MethodDefinition method, DependencyInfo reason) = _methods.Dequeue ();
try {
ProcessMethod (method, reason);
- } catch (Exception e) {
- throw new MarkException (string.Format ("Error processing method: '{0}' in assembly: '{1}'", method.FullName, method.Module.Name), e, method);
+ } catch (Exception e) when (!(e is LinkerFatalErrorException)) {
+ throw new LinkerFatalErrorException (
+ MessageContainer.CreateErrorMessage ($"Error processing method '{method.FullName}' in assembly '{method.Module.Name}'", 1005,
+ origin: MessageOrigin.TryGetOrigin (method, 0)), e);
}
}
}
@@ -2262,7 +2264,8 @@ namespace Mono.Linker.Steps
var baseType = method.DeclaringType.BaseType.Resolve ();
if (!MarkDefaultConstructor (baseType, new DependencyInfo (DependencyKind.BaseDefaultCtorForStubbedMethod, method)))
- throw new NotSupportedException ($"Cannot stub constructor on '{method.DeclaringType}' when base type does not have default constructor");
+ throw new LinkerFatalErrorException (MessageContainer.CreateErrorMessage ($"Cannot stub constructor on '{method.DeclaringType}' when base type does not have default constructor",
+ 1006, origin: MessageOrigin.TryGetOrigin (method, 0)));
break;
@@ -2279,12 +2282,13 @@ namespace Mono.Linker.Steps
var nse = BCL.FindPredefinedType ("System", "NotSupportedException", _context);
if (nse == null)
- throw new NotSupportedException ("Missing predefined 'System.NotSupportedException' type");
+ throw new LinkerFatalErrorException (MessageContainer.CreateErrorMessage ("Missing predefined 'System.NotSupportedException' type", 1007));
MarkType (nse, reason);
var nseCtor = MarkMethodIf (nse.Methods, KnownMembers.IsNotSupportedExceptionCtorString, reason);
- _context.MarkedKnownMembers.NotSupportedExceptionCtorString = nseCtor ?? throw new MarkException ($"Could not find constructor on '{nse.FullName}'");
+ _context.MarkedKnownMembers.NotSupportedExceptionCtorString = nseCtor ??
+ throw new LinkerFatalErrorException (MessageContainer.CreateErrorMessage ($"Could not find constructor on '{nse.FullName}'", 1008));
var objectType = BCL.FindPredefinedType ("System", "Object", _context);
if (objectType == null)
@@ -2293,7 +2297,8 @@ namespace Mono.Linker.Steps
MarkType (objectType, reason);
var objectCtor = MarkMethodIf (objectType.Methods, MethodDefinitionExtensions.IsDefaultConstructor, reason);
- _context.MarkedKnownMembers.ObjectCtor = objectCtor ?? throw new MarkException ($"Could not find constructor on '{objectType.FullName}'");
+ _context.MarkedKnownMembers.ObjectCtor = objectCtor ??
+ throw new LinkerFatalErrorException (MessageContainer.CreateErrorMessage ($"Could not find constructor on '{objectType.FullName}'", 1008));
}
bool MarkDisablePrivateReflectionAttribute ()
@@ -2303,12 +2308,14 @@ namespace Mono.Linker.Steps
var disablePrivateReflection = BCL.FindPredefinedType ("System.Runtime.CompilerServices", "DisablePrivateReflectionAttribute", _context);
if (disablePrivateReflection == null)
- throw new NotSupportedException ("Missing predefined 'System.Runtime.CompilerServices.DisablePrivateReflectionAttribute' type");
+ throw new LinkerFatalErrorException (MessageContainer.CreateErrorMessage ("Missing predefined 'System.Runtime.CompilerServices.DisablePrivateReflectionAttribute' type", 1007));
MarkType (disablePrivateReflection, DependencyInfo.DisablePrivateReflectionRequirement);
var ctor = MarkMethodIf (disablePrivateReflection.Methods, MethodDefinitionExtensions.IsDefaultConstructor, new DependencyInfo (DependencyKind.DisablePrivateReflectionRequirement, disablePrivateReflection));
- _context.MarkedKnownMembers.DisablePrivateReflectionAttributeCtor = ctor ?? throw new MarkException ($"Could not find constructor on '{disablePrivateReflection.FullName}'");
+ _context.MarkedKnownMembers.DisablePrivateReflectionAttributeCtor = ctor ??
+ throw new LinkerFatalErrorException (MessageContainer.CreateErrorMessage ($"Could not find constructor on '{disablePrivateReflection.FullName}'", 1010));
+
return true;
}
diff --git a/src/linker/Linker.Steps/OutputStep.cs b/src/linker/Linker.Steps/OutputStep.cs
index 8ade14a28..ae833303e 100644
--- a/src/linker/Linker.Steps/OutputStep.cs
+++ b/src/linker/Linker.Steps/OutputStep.cs
@@ -126,7 +126,7 @@ namespace Mono.Linker.Steps
try {
assembly.Write (outputName, writerParameters);
} catch (Exception e) {
- throw new OutputException ($"Failed to write '{outputName}", e);
+ throw new LinkerFatalErrorException (MessageContainer.CreateErrorMessage ($"Failed to write '{outputName}", 1011), e);
}
}
diff --git a/src/linker/Linker.Steps/ResolveFromXmlStep.cs b/src/linker/Linker.Steps/ResolveFromXmlStep.cs
index 4c419dc94..658a1fb31 100644
--- a/src/linker/Linker.Steps/ResolveFromXmlStep.cs
+++ b/src/linker/Linker.Steps/ResolveFromXmlStep.cs
@@ -38,15 +38,6 @@ using Mono.Cecil;
namespace Mono.Linker.Steps
{
-
- public class XmlResolutionException : Exception
- {
- public XmlResolutionException (string message, Exception innerException)
- : base (message, innerException)
- {
- }
- }
-
public class ResolveFromXmlStep : BaseStep
{
@@ -98,8 +89,8 @@ namespace Mono.Linker.Steps
try {
ProcessAssemblies (Context, nav.SelectChildren ("assembly", _ns));
- } catch (Exception ex) when (!(ex is XmlResolutionException)) {
- throw new XmlResolutionException (string.Format ("Failed to process XML description: {0}", _xmlDocumentLocation), ex);
+ } catch (Exception ex) when (!(ex is LinkerFatalErrorException)) {
+ throw new LinkerFatalErrorException (MessageContainer.CreateErrorMessage ($"Failed to process description file '{_xmlDocumentLocation}'", 1004), ex);
}
}
diff --git a/src/linker/Linker/Driver.cs b/src/linker/Linker/Driver.cs
index 6d41b770b..c6388bc57 100644
--- a/src/linker/Linker/Driver.cs
+++ b/src/linker/Linker/Driver.cs
@@ -32,7 +32,6 @@ using System.IO;
using System.Reflection;
using System.Text;
using System.Xml.XPath;
-
using Mono.Linker.Steps;
namespace Mono.Linker
@@ -674,6 +673,15 @@ namespace Mono.Linker
try {
p.Process (context);
+ } catch (Exception ex) {
+ if (ex is LinkerFatalErrorException lex) {
+ context.LogMessage (lex.MessageContainer);
+ Console.Error.WriteLine (ex.ToString ());
+ } else {
+ context.LogMessage (MessageContainer.CreateErrorMessage ($"IL Linker has encountered an unexpected error. Please report the issue at https://github.com/mono/linker/issues \n{ex}", 1012));
+ }
+
+ return false;
} finally {
context.Tracer.Finish ();
}
diff --git a/src/linker/Linker/InternalErrorException.cs b/src/linker/Linker/InternalErrorException.cs
new file mode 100644
index 000000000..da764a2fe
--- /dev/null
+++ b/src/linker/Linker/InternalErrorException.cs
@@ -0,0 +1,26 @@
+using System;
+
+namespace Mono.Linker
+{
+ public class InternalErrorException : Exception
+ {
+ /// <summary>
+ /// Represents an internal fatal error. Should be used in places that are not expected to be hit by the linker.
+ /// </summary>
+ /// <param name="message">Message description of what went wrong and why</param>
+ public InternalErrorException (string message)
+ : base (message)
+ {
+ }
+
+ /// <summary>
+ /// Represents an internal fatal error. Should be used in places that are not expected to be hit by the linker.
+ /// </summary>
+ /// <param name="message">Message description of what went wrong and why</param>
+ /// <param name="innerException"></param>
+ public InternalErrorException (string message, Exception innerException)
+ : base (message, innerException)
+ {
+ }
+ }
+}
diff --git a/src/linker/Linker/LinkContext.cs b/src/linker/Linker/LinkContext.cs
index 71afe4706..817b7e4b7 100644
--- a/src/linker/Linker/LinkContext.cs
+++ b/src/linker/Linker/LinkContext.cs
@@ -346,7 +346,7 @@ namespace Mono.Linker
if (definition != null)
references.Add (definition);
} catch (Exception e) {
- throw new LoadException ($"Assembly '{assembly.FullName}' reference '{reference.FullName}' could not be resolved", e);
+ throw new LinkerFatalErrorException (MessageContainer.CreateErrorMessage ($"Assembly '{assembly.FullName}' reference '{reference.FullName}' could not be resolved", 1009), e);
}
}
return references;
diff --git a/src/linker/Linker/LinkerFatalErrorException.cs b/src/linker/Linker/LinkerFatalErrorException.cs
new file mode 100644
index 000000000..47977124c
--- /dev/null
+++ b/src/linker/Linker/LinkerFatalErrorException.cs
@@ -0,0 +1,36 @@
+using System;
+
+namespace Mono.Linker
+{
+ public class LinkerFatalErrorException : Exception
+ {
+ public MessageContainer MessageContainer { get; }
+
+ /// <summary>
+ /// Represents a known error that occurred during link time which is solvable by the user.
+ /// </summary>
+ /// <param name="message">Error message with a description of what went wrong</param>
+ public LinkerFatalErrorException (MessageContainer message)
+ : base (message.ToString ())
+ {
+ if (message.Category != MessageCategory.Error)
+ throw new ArgumentException ($"'{nameof (LinkerFatalErrorException)}' ought to be used for errors only");
+
+ MessageContainer = message;
+ }
+
+ /// <summary>
+ /// Represents a known error that occurred during link time which is solvable by the user.
+ /// </summary>
+ /// <param name="message">Error message with a description of what went wrong</param>
+ /// <param name="innerException"></param>
+ public LinkerFatalErrorException (MessageContainer message, Exception innerException)
+ : base (message.ToString (), innerException)
+ {
+ if (message.Category != MessageCategory.Error)
+ throw new ArgumentException ($"'{nameof (LinkerFatalErrorException)}' ought to be used for errors only");
+
+ MessageContainer = message;
+ }
+ }
+}
diff --git a/src/linker/Linker/LoadException.cs b/src/linker/Linker/LoadException.cs
deleted file mode 100644
index c4ca8f67e..000000000
--- a/src/linker/Linker/LoadException.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System;
-
-namespace Mono.Linker
-{
- public class LoadException : Exception
- {
- public LoadException (string message)
- : base (message)
- {
- }
-
- public LoadException (string message, Exception innerException)
- : base (message, innerException)
- {
- }
- }
-}
diff --git a/src/linker/Linker/MarkException.cs b/src/linker/Linker/MarkException.cs
deleted file mode 100644
index fd8d6057c..000000000
--- a/src/linker/Linker/MarkException.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-
-using Mono.Cecil;
-
-namespace Mono.Linker
-{
- public class MarkException : Exception
- {
- public MethodDefinition Method { get; private set; }
-
- public MarkException (string message)
- : base (message)
- {
- }
-
- public MarkException (string message, Exception innerException)
- : base (message, innerException)
- {
- }
-
- public MarkException (string message, Exception innerException, MethodDefinition method)
- : base (message, innerException)
- {
- Method = method;
- }
- }
-}
diff --git a/src/linker/Linker/MessageContainer.cs b/src/linker/Linker/MessageContainer.cs
index 43269fbc4..c9b10303b 100644
--- a/src/linker/Linker/MessageContainer.cs
+++ b/src/linker/Linker/MessageContainer.cs
@@ -99,7 +99,7 @@ namespace Mono.Linker
public string ToMSBuildString ()
{
- const string originApp = "illinker";
+ const string originApp = "ILlinker";
string origin = Origin?.ToString () ?? originApp;
StringBuilder sb = new StringBuilder ();
diff --git a/src/linker/Linker/OutputException.cs b/src/linker/Linker/OutputException.cs
deleted file mode 100644
index a406625fa..000000000
--- a/src/linker/Linker/OutputException.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System;
-
-namespace Mono.Linker
-{
- public class OutputException : Exception
- {
- public OutputException (string message)
- : base (message)
- {
- }
-
- public OutputException (string message, Exception innerException)
- : base (message, innerException)
- {
- }
- }
-} \ No newline at end of file
diff --git a/test/Mono.Linker.Tests.Cases.Expectations/Assertions/NoLinkedOutputAttribute.cs b/test/Mono.Linker.Tests.Cases.Expectations/Assertions/NoLinkedOutputAttribute.cs
new file mode 100644
index 000000000..0537a62e1
--- /dev/null
+++ b/test/Mono.Linker.Tests.Cases.Expectations/Assertions/NoLinkedOutputAttribute.cs
@@ -0,0 +1,9 @@
+using System;
+
+namespace Mono.Linker.Tests.Cases.Expectations.Assertions
+{
+ public class NoLinkedOutputAttribute : Attribute
+ {
+ public NoLinkedOutputAttribute () { }
+ }
+}
diff --git a/test/Mono.Linker.Tests.Cases/Logging/CommonLogs.cs b/test/Mono.Linker.Tests.Cases/Logging/CommonLogs.cs
index d27cb48e6..b34bf11fa 100644
--- a/test/Mono.Linker.Tests.Cases/Logging/CommonLogs.cs
+++ b/test/Mono.Linker.Tests.Cases/Logging/CommonLogs.cs
@@ -11,10 +11,10 @@ namespace Mono.Linker.Tests.Cases.Logging
#endif
[SetupLinkerArgument ("--custom-step", "Log.LogStep,LogStep.dll")]
- [LogContains ("illinker: error IL1004: Error")]
+ [LogContains ("ILlinker: error IL1004: Error")]
[LogContains ("logtest(1,1): warning IL2001: Warning")]
- [LogContains ("illinker: Info")]
- [LogContains ("illinker: Diagnostics")]
+ [LogContains ("ILlinker: Info")]
+ [LogContains ("ILlinker: Diagnostics")]
public class CommonLogs
{
public static void Main ()
diff --git a/test/Mono.Linker.Tests.Cases/Substitutions/FeatureSubstitutionsInvalid.cs b/test/Mono.Linker.Tests.Cases/Substitutions/FeatureSubstitutionsInvalid.cs
index dc4e99d59..b1fb16d43 100644
--- a/test/Mono.Linker.Tests.Cases/Substitutions/FeatureSubstitutionsInvalid.cs
+++ b/test/Mono.Linker.Tests.Cases/Substitutions/FeatureSubstitutionsInvalid.cs
@@ -3,15 +3,16 @@ using Mono.Linker.Tests.Cases.Expectations.Metadata;
namespace Mono.Linker.Tests.Cases.Substitutions
{
+ [NoLinkedOutput]
[SetupLinkerSubstitutionFile ("FeatureSubstitutionsInvalid.xml")]
[SetupLinkerArgument ("--feature", "NoValueFeature", "true")]
- [LogContains ("Feature NoValueFeature does not specify a \"featurevalue\" attribute")]
- [LogContains ("illinker: warning IL2016: Could not find field 'NonExistentField' in type 'Mono.Linker.Tests.Cases.Substitutions.FeatureSubstitutionsInvalid/Foo'")]
- [LogContains ("illinker: warning IL2017: Could not find method 'NonExistentMethod' in type 'Mono.Linker.Tests.Cases.Substitutions.FeatureSubstitutionsInvalid/Foo'")]
- [LogContains ("illinker: warning IL2018: Could not find event 'NonExistentEvent' in type 'Mono.Linker.Tests.Cases.Substitutions.FeatureSubstitutionsInvalid/Foo'")]
- [LogContains ("illinker: warning IL2019: Could not find property 'NonExistentProperty' in type 'Mono.Linker.Tests.Cases.Substitutions.FeatureSubstitutionsInvalid/Foo'")]
- [LogContains ("illinker: warning IL2020: Could not find the get accessor of property 'NoGetter' in type 'Mono.Linker.Tests.Cases.Substitutions.FeatureSubstitutionsInvalid/Foo'")]
- [LogContains ("illinker: warning IL2021: Could not find the set accessor of property 'NoSetter' in type 'Mono.Linker.Tests.Cases.Substitutions.FeatureSubstitutionsInvalid/Foo'")]
+ [LogContains ("Feature NoValueFeature does not specify a 'featurevalue' attribute")]
+ [LogContains ("ILlinker: warning IL2016: Could not find field 'NonExistentField' in type 'Mono.Linker.Tests.Cases.Substitutions.FeatureSubstitutionsInvalid/Foo'")]
+ [LogContains ("ILlinker: warning IL2017: Could not find method 'NonExistentMethod' in type 'Mono.Linker.Tests.Cases.Substitutions.FeatureSubstitutionsInvalid/Foo'")]
+ [LogContains ("ILlinker: warning IL2018: Could not find event 'NonExistentEvent' in type 'Mono.Linker.Tests.Cases.Substitutions.FeatureSubstitutionsInvalid/Foo'")]
+ [LogContains ("ILlinker: warning IL2019: Could not find property 'NonExistentProperty' in type 'Mono.Linker.Tests.Cases.Substitutions.FeatureSubstitutionsInvalid/Foo'")]
+ [LogContains ("ILlinker: warning IL2020: Could not find the get accessor of property 'NoGetter' in type 'Mono.Linker.Tests.Cases.Substitutions.FeatureSubstitutionsInvalid/Foo'")]
+ [LogContains ("ILlinker: warning IL2021: Could not find the set accessor of property 'NoSetter' in type 'Mono.Linker.Tests.Cases.Substitutions.FeatureSubstitutionsInvalid/Foo'")]
public class FeatureSubstitutionsInvalid
{
public static void Main ()
diff --git a/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs b/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs
index 0fa22b3b1..bd5ec176d 100644
--- a/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs
+++ b/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs
@@ -42,27 +42,26 @@ namespace Mono.Linker.Tests.TestCasesRunner
public virtual void Check (LinkedTestCaseResult linkResult)
{
- Assert.IsTrue (linkResult.OutputAssemblyPath.FileExists (), $"The linked output assembly was not found. Expected at {linkResult.OutputAssemblyPath}");
-
InitializeResolvers (linkResult);
try {
var original = ResolveOriginalsAssembly (linkResult.ExpectationsAssemblyPath.FileNameWithoutExtension);
- var linked = ResolveLinkedAssembly (linkResult.OutputAssemblyPath.FileNameWithoutExtension);
+ if (!HasAttribute (original, nameof (NoLinkedOutputAttribute))) {
+ Assert.IsTrue (linkResult.OutputAssemblyPath.FileExists (), $"The linked output assembly was not found. Expected at {linkResult.OutputAssemblyPath}");
+ var linked = ResolveLinkedAssembly (linkResult.OutputAssemblyPath.FileNameWithoutExtension);
- InitialChecking (linkResult, original, linked);
+ InitialChecking (linkResult, original, linked);
- PerformOutputAssemblyChecks (original, linkResult.OutputAssemblyPath.Parent);
- PerformOutputSymbolChecks (original, linkResult.OutputAssemblyPath.Parent);
+ PerformOutputAssemblyChecks (original, linkResult.OutputAssemblyPath.Parent);
+ PerformOutputSymbolChecks (original, linkResult.OutputAssemblyPath.Parent);
- if (!original.MainModule.GetType (linkResult.TestCase.ReconstructedFullTypeName).CustomAttributes
- .Any (attr => attr.AttributeType.Name == nameof (SkipKeptItemsValidationAttribute))) {
- CreateAssemblyChecker (original, linked).Verify ();
+ if (!HasAttribute (original.MainModule.GetType (linkResult.TestCase.ReconstructedFullTypeName), nameof (SkipKeptItemsValidationAttribute))) {
+ CreateAssemblyChecker (original, linked).Verify ();
+ }
}
VerifyLinkingOfOtherAssemblies (original);
-
- AdditionalChecking (linkResult, original, linked);
+ AdditionalChecking (linkResult, original);
} finally {
_originalsResolver.Dispose ();
_linkedResolver.Dispose ();
@@ -162,7 +161,7 @@ namespace Mono.Linker.Tests.TestCasesRunner
}
}
- protected virtual void AdditionalChecking (LinkedTestCaseResult linkResult, AssemblyDefinition original, AssemblyDefinition linked)
+ protected virtual void AdditionalChecking (LinkedTestCaseResult linkResult, AssemblyDefinition original)
{
VerifyLoggedMessages (original, linkResult.Logger);
VerifyRecordedDependencies (original, linkResult.Customizations.DependencyRecorder);
@@ -904,5 +903,17 @@ namespace Mono.Linker.Tests.TestCasesRunner
{
return attr.AttributeType.Resolve ().DerivesFrom (nameof (BaseInAssemblyAttribute));
}
+
+ bool HasAttribute (ICustomAttributeProvider caProvider, string attributeName)
+ {
+ if (caProvider is AssemblyDefinition assembly && assembly.EntryPoint != null)
+ return assembly.EntryPoint.DeclaringType.CustomAttributes
+ .Any (attr => attr.AttributeType.Name == attributeName);
+
+ if (caProvider is TypeDefinition type)
+ return type.CustomAttributes.Any (attr => attr.AttributeType.Name == attributeName);
+
+ return false;
+ }
}
} \ No newline at end of file
diff --git a/test/Mono.Linker.Tests/Tests/MessageContainerTests.cs b/test/Mono.Linker.Tests/Tests/MessageContainerTests.cs
index e9c016dfa..fa69cb62f 100644
--- a/test/Mono.Linker.Tests/Tests/MessageContainerTests.cs
+++ b/test/Mono.Linker.Tests/Tests/MessageContainerTests.cs
@@ -9,13 +9,13 @@ namespace Mono.Linker.Tests
public void MSBuildFormat ()
{
var msg = MessageContainer.CreateErrorMessage ("text", 1000);
- Assert.AreEqual ("illinker: error IL1000: text", msg.ToMSBuildString ());
+ Assert.AreEqual ("ILlinker: error IL1000: text", msg.ToMSBuildString ());
msg = MessageContainer.CreateWarningMessage ("message", 2001, origin: new MessageOrigin ("logtest", 1, 1));
Assert.AreEqual ("logtest(1,1): warning IL2001: message", msg.ToMSBuildString ());
msg = MessageContainer.CreateInfoMessage ("log test");
- Assert.AreEqual ("illinker: log test", msg.ToMSBuildString ());
+ Assert.AreEqual ("ILlinker: log test", msg.ToMSBuildString ());
}
}
}