-
Notifications
You must be signed in to change notification settings - Fork 564
[Xamarin.Android.Build.Tasks] New APT0000 msbuild errors are being reported from aapt output parsing #1047
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
| if (!string.IsNullOrEmpty (match.Groups["line"]?.Value)) | ||
| line = int.Parse (match.Groups["line"].Value) + 1; | ||
| var level = match.Groups["level"].Value; | ||
| var level = match.Groups["level"].Value.ToLower (); |
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.
Should it be ToLowerInvariant?
| ( # optional warning|error: | ||
| \s* | ||
| (?<level>(warning|error)[^:]*)\s* | ||
| (?<level>(warning|error|Error|ERROR)[^:]*)\s* |
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.
Maybe we could just use RegexOptions.IgnoreCase, and it would also handle if they decide to use Warning or WARNING?
|
|
||
| LogError ("APT0000", message, file, line); | ||
| return; | ||
| if (level.Contains ("error") || (line != 0 && !string.IsNullOrEmpty (file))) { |
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.
Once concern with this change is that previously, any message which wasn't a warning or fakeLogOpen was treated as an error.
Now, only messages which contain error are errors.
This sounds reasonable, but will there be any unexpected fallout? Will we "miss" any errors with this change?
Additionally, it looks like we won't log message at all if it's not explicitly a warning or an error. Is that desirable? (Presumably we should always log, no?)
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.
As stated google is not consistent with its labelling of errors/warnings. I went through the aapt code and added any additional ones to https://github.com/xamarin/xamarin-android/pull/1047/files#diff-97e1ab3c8027acfecf85b8bb5a88dd9aR409
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.
Should we always log the message? Or are there messages we should skip entirely?
It looks like the new version will only log messages which contain warning, fakeLogOpen, error, or contain a filename. Is that desirable?
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.
We fall through to https://github.com/dellis1972/xamarin-android/blob/79e432f32f08f4b2c867e07cdd225a5de2c9449a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt.cs#L405 if the regex does not match, or its not one of the KnownInvalidErrorMessages
That said, I'm sure we had an old bug where if we do log the error/warning using LogMessage as well as LogError or LogWarning we ended up with the same error appearing in the error list twice (sometimes). I think because msbuild does some parsing too.
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.
Looking at the aapt source google are not consistent with labelling.. but :) they are consistent with writing ALL errors/warnings to stderr.. so I will change this PR to log anything we get from stdout as a message. and only process the errors/warnings from stderr.
| // Handle additional errors that doesn't match the regex | ||
| foreach (var knownInvalidError in KnownInvalidErrorMessages) { | ||
| if (singleLine.Trim ().StartsWith (knownInvalidError, StringComparison.OrdinalIgnoreCase)) { | ||
| LogError ("APT0000", string.Format ("{0} \"{1}\".", knownInvalidError, singleLine.Substring (singleLine.LastIndexOfAny (new char [] { '\\', '/' }) + 1)), ToolName); |
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.
Why do we only provide the "rightmost" directory name, and not the entire path? Is it too long and noisy?
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.
no idea. its been that way for a long time from what I can see.
|
build |
| (?<message>.*) | ||
| $ | ||
| ", RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnorePatternWhitespace); | ||
| ", RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnorePatternWhitespace, RegexOptions.IgnoreCase); |
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.
@dellis1972 I think this needs | instead of ,
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.
…ported from aapt output parsing Fixes https://devdiv.visualstudio.com/DevDiv/_workitems?id=528572 The current RegEx was capturing output which was not and error or warning. It turns out that aapt is not very consistent with its error messaging. Sometimes they use `error`, sometimes then use `Error` or `ERROR`. Or in the worse case, they don't flag it as anything. This commit adds a few more tests to AndroidRegExTests as well as alters the logic in `Aapt` a bit as well. This logic will only log as an error if we have an error `level` or we have a `file` and `line`. This seems to be fairly consistent when looking at the `aapt` source code. We also added a few extra `Known` errors which the regex might not pick. This is because they do not contain a `level` or a `file` and `line` number.
3518475 to
bb8bb53
Compare

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems?id=528572
The current RegEx was capturing output which was not and error
or warning. It turns out that aapt is not very consistent with
its error messaging. Sometimes they use
error, sometimes thenuse
ErrororERROR. Or in the worse case, they don't flag itas anything.
This commit adds a few more tests to AndroidRegExTests as well
as alters the logic in
Aapta bit as well. This logic willonly log as an error if we have an error
levelor we havea
fileandline. This seems to be fairly consistent whenlooking at the
aaptsource code.We also added a few extra
Knownerrors which the regex might notpick. This is because they do not contain a
levelor afileand
linenumber.