Skip to content

Commit

Permalink
[generator] Fix BI0000 from FormatException when no arguments are pro…
Browse files Browse the repository at this point in the history
…vided for an error (#7078)

Add new overloads so we can skip `String.Format` calls when relaying
messages without any arguments. Solve cases like

```
error BI0000: Unexpected error - Please file a bug report at https://github.com/xamarin/xamarin-macios/issues/new
System.FormatException: Input string was not in a correct format.
  at System.Text.StringBuilder.AppendFormatHelper (System.IFormatProvider provider, System.String format, System.ParamsArray args) [0x000b2] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-06/external/bockbuild/builds/mono-x64/external/corefx/src/Common/src/CoreLib/System/Text/StringBuilder.cs:1445
...
```

because we failed compilation due to an (hidden) syntax error like:

```
foundation.cs(3627,3): error CS1519: Invalid token '{' in class, struct, or interface member declaration
```

where the `{` character is causing the `FormatException` inside the
generator sources.

This is now more properly reported as

```
error BI0002: bgen: Could not compile the API bindings.
	foundation.cs(3627,3): error CS1519: Invalid token '{' in class, struct, or interface member declaration
```
  • Loading branch information
spouliot committed Sep 24, 2019
1 parent 2adecee commit 80e6e63
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/error.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@

public class BindingException : Exception {

public BindingException (int code, bool error, string message) :
base (message)
{
Code = code;
Error = error || ErrorHelper.GetWarningLevel (code) == ErrorHelper.WarningLevel.Error;
}

public BindingException (int code, string message, params object[] args) :
this (code, false, message, args)
{
Expand Down Expand Up @@ -62,11 +69,21 @@ public enum WarningLevel {
[ThreadStatic]
static Dictionary<int, WarningLevel> warning_levels;

public static ProductException CreateError (int code, string message)
{
return new ProductException (code, true, message);
}

public static ProductException CreateError (int code, string message, params object[] args)
{
return new ProductException (code, true, message, args);
}

public static void Warning (int code, string message)
{
Show (new ProductException (code, false, message));
}

public static void Warning (int code, string message, params object[] args)
{
Show (new ProductException (code, false, message, args));
Expand Down

6 comments on commit 80e6e63

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 Device tests completed (Failed) on iOS on Azure DevOps(iOS): Html Report 🔥

Test results

5 tests failed, 108 tests passed.

Failed tests

  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug): Failed
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Failed
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Failed
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/Release: Failed
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Failed

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

Build was (probably) aborted

🔥 Jenkins job (on internal Jenkins) failed in stage(s) 'Test run, Test run' 🔥

Build succeeded
✅ Packages:

API Diff (from stable)
API Diff (from PR only) (no change)
Generator Diff (no change)
🔥 Test run failed 🔥

Test results

1 tests failed, 162 tests passed.

Failed tests

  • monotouch-test/watchOS 32-bits - simulator/Debug: Crashed

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 Device tests completed (Failed) on iOS on Azure DevOps(iOS): Html Report 🔥

Test results

3 tests failed, 110 tests passed.

Failed tests

  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/Release: Failed
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Failed
  • mscorlib/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Failed

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 Device tests completed (Failed) on TvOS on Azure DevOps(TvOS): Html Report 🔥

Test results

11 tests failed, 102 tests passed.

Failed tests

  • [NUnit] Mono BCL tests group 2/tvOS - device/Debug: Failed
  • monotouch-test/tvOS - device/AssemblyBuildTarget: SDK framework (debug): Failed (Install failed, exit code: 137.)
  • dont link/tvOS - device/AssemblyBuildTarget: SDK framework (release): Failed (Install failed, exit code: 137.)
  • [NUnit] Mono BCL tests group 1/tvOS - device/AssemblyBuildTarget: SDK framework (release): Failed (Install failed, exit code: 137.)
  • [NUnit] Mono BCL tests group 2/tvOS - device/AssemblyBuildTarget: SDK framework (release): Failed (Install failed, exit code: 137.)
  • [xUnit] Mono BCL tests group 3/tvOS - device/AssemblyBuildTarget: SDK framework (release): Failed (Install failed, exit code: 137.)
  • [xUnit] Mono BCL tests group 4/tvOS - device/Release: Failed (Install failed, exit code: 137.)
  • [xUnit] Mono BCL tests group 4/tvOS - device/AssemblyBuildTarget: SDK framework (release): Failed (Install failed, exit code: 137.)
  • mscorlib/tvOS - device/Release: Failed (Install failed, exit code: 137.)
  • mscorlib/tvOS - device/AssemblyBuildTarget: SDK framework (release): Failed (Install failed, exit code: 137.)
  • [xUnit] Mono BCL tests group 6/tvOS - device/AssemblyBuildTarget: dylib (debug): Failed (Install failed, exit code: 137.)

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 Device tests completed (Canceled) on iOS32b on Azure DevOps(iOS32b): Html Report 🔥

🔥 Tests failed catastrophically on iOS32b (no summary found)

Please sign in to comment.