adamped / xamarin.flutter

Running Flutter on Xamarin
MIT License
250 stars 39 forks source link

CSharpWriter: Support for human-transpiled sections #42

Closed JeroMiya closed 5 years ago

JeroMiya commented 5 years ago

I'm seeing a couple places where automated transpiling may be impossible (or at least require a full program analysis). For instance: flutter/lib/src/foundation/annotations.dart includes attributes, which in Dart are just regular classes. Without looking around the code for references to those attributes, there's no way to tell that those classes should be rewritten as C# attributes.

So either we can spend time on the transpiler implementing that full program analysis or we can just have a map file that says, "when you see this file, use this hand-transpiled C# file from over here instead."

Something like this:

{
  "handTranspiledFiles": [
    { "dartFile": "flutter/lib/src/foundation/annotations.dart", "handTranspiledFile": "handTranspiled/lib/src/foundation/annotations.cs" },
    ...
  ]
}
adamped commented 5 years ago

We already do a full program analysis with the Dart Analyzer, that part is already done.

We are just creating the C# from the Semantic Model the Dart Analyzer provides us. Ideally we want it to be 100% automatically transpiled, as we don't want to maintain anything but the transpiler. However, we might do something like this, for a quick win early on, and we can setup the transpiler later for it.