Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Resolving type/command/event name clashes #1222

Merged
merged 14 commits into from
Nov 21, 2019
Merged

Resolving type/command/event name clashes #1222

merged 14 commits into from
Nov 21, 2019

Conversation

paulbalaji
Copy link
Contributor

@paulbalaji paulbalaji commented Nov 19, 2019

Description

It currently just does a basic log to stderr, and forwarding that to the Editor:
image

TODO:

  • changelog
  • move valid sample schema to test project

add tests for the illegal schema sample

UTY-2311 will implement logging in the codegen, which should provider a nicer way of outputting the information/errors that we've added in this PR. For now, how it currently logs can be left as an implementation detail.

Tests

Schema linked in #957 and #958 will no longer cause compilation errors, but codegen will log an error that gets picked up in the Editor

Primary reviewers

If your change will take a long time to review, you can name at most two primary reviewers who are ultimately responsible for reviewing this request. @ mention them.

Paul Balaji added 4 commits November 19, 2019 14:54
@improbable-prow-robot
Copy link

Corresponding JIRA ticket: https://improbableio.atlassian.net/browse/UTY-1416

@improbable-prow-robot improbable-prow-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. jira/UTY size/L Denotes a PR that changes 150-299 lines, ignoring generated files. labels Nov 19, 2019
@improbable-prow-robot improbable-prow-robot added A: playground Area: Playground A: tooling Area: Tooling labels Nov 19, 2019
@improbable-prow-robot improbable-prow-robot added size/M Denotes a PR that changes 40-149 lines, ignoring generated files. and removed size/L Denotes a PR that changes 150-299 lines, ignoring generated files. labels Nov 19, 2019
@paulbalaji paulbalaji marked this pull request as ready for review November 19, 2019 18:27
@improbable-prow-robot improbable-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 19, 2019
Paul Balaji added 3 commits November 19, 2019 18:27
Signed-off-by: Paul Balaji <paulbalaji@improbable.io>
Signed-off-by: Paul Balaji <paulbalaji@improbable.io>
isValid = false;
Console.Error.WriteLine(
$"Error in component \"{componentName}\". " +
$"Command \"{clashingCommand.RawCommandName}\" clashes with component name.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Prefer having a long line over concatentating strings. Also you can use single quotes and get rid of the escaping which aids readability

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was using single quotes before and I think it's not really that readable in the Editor

@@ -0,0 +1,27 @@
// Wait, that's illegal!
Copy link
Contributor

Choose a reason for hiding this comment

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

👏

Paul Balaji added 3 commits November 20, 2019 14:38
Signed-off-by: Paul Balaji <paulbalaji@improbable.io>
Signed-off-by: Paul Balaji <paulbalaji@improbable.io>
Signed-off-by: Paul Balaji <paulbalaji@improbable.io>
Copy link
Contributor

@zeroZshadow zeroZshadow left a comment

Choose a reason for hiding this comment

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

I think codegen needs to fail when running into clashes, not skip them.

@@ -12,8 +13,8 @@ public class UnityComponentDetails
public bool IsBlittable { get; }

public IReadOnlyList<UnityFieldDetails> FieldDetails { get; private set; }
public IReadOnlyList<UnityCommandDetails> CommandDetails { get; }
public IReadOnlyList<UnityEventDetails> EventDetails { get; }
public IReadOnlyList<UnityCommandDetails> CommandDetails { get; private set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these 2 private set now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice spot - these are relics from when the filtering was done in a separate method

return true;
}

Console.Error.WriteLine($"Error in component \"{ComponentName}\". Command \"{commandDetail.RawCommandName}\" clashes with component name.");
Copy link
Contributor

Choose a reason for hiding this comment

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

This should FAIL codegen. It shouldn't be possible to write schema that throws errors but still generates code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved offline

@jamiebrynes7
Copy link
Contributor

I think codegen needs to fail when running into clashes, not skip them.

The problem is until we have a way of surfacing these errors reliably, failing code generation (i.e. - outputting nothing) obscures the problem due to the avalanche of compile errors you will hit.

@paulbalaji
Copy link
Contributor Author

I think codegen needs to fail when running into clashes, not skip them.

The problem is until we have a way of surfacing these errors reliably, failing code generation (i.e. - outputting nothing) obscures the problem due to the avalanche of compile errors you will hit.

Discussed offline

Having heard both sides, I've decided to keep the messages as errors without failing the entire codegen step for now, and we can refine the idea further when we have better codegen logging. Once that is in place, we are likely to be able to surface these issues better to users and (maybe) cause the codegen step to fail in a way that doesn't stop users from A) knowing that the error was in codegen and B) knowing where to look to figure out where their error comes from.

Signed-off-by: Paul Balaji <paulbalaji@improbable.io>
@paulbalaji paulbalaji merged commit 5385d3c into develop Nov 21, 2019
@paulbalaji paulbalaji deleted the bugfix/uty-1416 branch November 21, 2019 16:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A: playground Area: Playground A: tooling Area: Tooling jira/UTY size/M Denotes a PR that changes 40-149 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants