Giter Club home page Giter Club logo

xamarin.flutter's People

Contributors

adamped avatar adolfo-marinucci avatar brainoffline avatar jeromiya avatar krdmllr avatar mihamarkic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

adospace pajama

xamarin.flutter's Issues

Add exclusions for all dart annotations

I don't think Dart annotations really translate well to C# automatically. Add exclusions to the transpiler for all the annotations in the Flutter framework and hand port these.

One namespace per flutter directory rather than one per file

Currently the transpiler creates a new namespace for each file rather than the directory it's in. Maybe it should be an option, but I think it would be better to just have one namespace per directory.

Example, instead of this:

using FlutterSDK.Widgets.Pages;
using FlutterSDK.Widgets.Performanceoverlay;
using FlutterSDK.Widgets.Automatickeepalive;
using FlutterSDK.Widgets.Scrollcontroller;
using FlutterSDK.Widgets.Widgetinspector;
using FlutterSDK.Widgets.Icon;
using FlutterSDK.Widgets.Scrollcontext;
using FlutterSDK.Widgets.Inheritedmodel;
using FlutterSDK.Widgets.Annotatedregion;
// etc...

Just this:

using FlutterSDK.Widgets;

Of course, this may result in name resolution issues, so close this issue if that happens in the flutter namespace itself (I don't believe it does).

TASK: Take a second pass on the output for issues.

I did a quick pass for issues in the output towards the beginning of the fork. Now with a few fixes in place, I should do a more comprehensive review pass on the output and create issues that are found.

Check in code-gen output

At least temporarily, add the code-gen output to the git repository. It's going to be a while before the code gen is fully functional or stable, and being able to review output diffs and make hand-written overrides may get the project closer to "functioning flutter.net framework" faster that relying 100% on the code-gen to generate correct output.

As part of this: document a convention for implementing hand-written overrides to generated output that allow for more reliable diff review.

Review @brainoffline's work and merge it in

It looks like @brainoffline did some work in their fork that was never merged upstream into @adamped's original repository. Review and merge the changes.

NOTE: not sure what happened after it was forked by @brainoffline but attempting to merge in @adamped's later changes causes all sorts of havok to the git history. Going to have to carefully cherry pick commits manually and make sure they get propper attribution.

Use the real FlutterEngine

IMHO in order for this to be successful, you need to continue to transpile the flutter SDK, but instead of re-writing the flutter engine in C# it should bind/pinvoke into the real engine.

Return statements in sync methods need to be "yield break;" instead of "return;"

In sync functions in Dart, you can just return; without yielding a value to break the function. In C# the equivalent is yield break.

https://github.com/JeroMiya/xamarin.flutter/blob/master/FlutterSDK/src/Foundation/Diagnostics.cs#L1097-L1098

{
if (message.Length+startOffset<width){
yield message;
return ;
}

Note: Implementing this implies that the code outputting the return statement can be aware of whether the return statement is within a sync function or a regular function. That is not currently the case - so part of solving this issue is to pass down the method and/or function context (or some stripped down version of same) into the entity processing functions that need it.

Transpile value types (int, double, bool, etc...) as nullable in C#

All types are nullable in the current version of Dart (though in the future this will not be the case), but value types are not by default in C#. A number of syntax errors in the transpiler output are a result of this difference. For now, let's output all of these types as nullable by default until the analyzer can tell us whether or not any given instance is nullable or not:
https://dart.dev/null-safety

Prefix core Dart types with 'Dart' when they conflict with built-in .NET types

Lots of the dart code uses Dart types like Dictionary<,>. There are custom subclasses of .net collections with Dart methods added in Globals.cs but in many cases these cause type ambiguity errors in the transpiler output. For example:

https://github.com/JeroMiya/xamarin.flutter/blob/master/FlutterSDK/src/Foundation/Diagnostics.cs#L809

Prefix these conflicting types with Dart, e.g. DartDictionary so that they don't result in ambiguity errors.

Implement spread operator in list literals.

There's currently a workaround implemented which comments out spread elements in list literal initializers. However, the spread operator is used extensively throughout Flutter and it needs to be fully implemented.

I'm going to hazard a guess that we'll want to implement two versions of the list literal processor - one for list literals without spread and one with spread, in case the C# implementation with spread has some runtime overhead that we could avoid if there's no spread operator in a literal.

I think the C# implementation of the spread will be to use a helper function that constructs the list, instead of a new expression. Something along these lines:

// Original Dart code: return <string>['item 1', ...spreadOperand];
return DartUtils.MakeListWithSpreads<string>(list => {
    list.Add('item 1');
    foreach(var i in spreadOperand) {
        list.Add(i);
    }
});

Static property references (and static methods) from Dart namespace are garbled, ':' character, bad function name

Static references (looks like particularly ones from the dart namespace) are getting garbled by the transpiler. For example:
https://github.com/JeroMiya/xamarin.flutter/blob/master/FlutterSDK/src/Animation/Animationcontroller.cs#L438

            else if (target == Value)
            {
                simulationDuration = Dart:coreDefaultClass.Duration.Zero;
            }

Here's the equivalent dart code:

    } else if (target == value) {
      // Already at target, don't animate.
      simulationDuration = Duration.zero;
    }

Exclude "web" versions of flutter framework implementation

There are a few places, such as the Foundation folder, where the flutter project has a "web" version of a class and a "native" version. Exclude the web version from the generated output, as any future Flutter.Net for the web is going to be based on WASM, and if there are any differences in implementation needed for .net wasm they will probably be completely unrelated to the Dart ones.

Re-enable comments and test

Looks like <summary> comments were disabled at some point. Try to re-enable them and test the output. See if there are any issues caused and create issues as necessary.

let VSCode format all the AST code so it doesn't barf diffs every change

It appears the auto-format-on-save option in vscode is reformatting the code every time a change is made. Rather than fight the setting, just auto format all the code and check it in as one diff so result in lots of diffs every time a change is made to a file that hasn't been formatted.

Some properties still have NotImplementedExceptions

Even with method bodies turned on in config, some properties still get transpiled to throw NotImplementedException, for example:

https://github.com/JeroMiya/xamarin.flutter/blob/master/FlutterSDK/src/Foundation/Diagnostics.cs#L798

    public virtual int SubtreeDepth { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } }
    public virtual bool IncludeProperties { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } }
    public virtual bool ExpandPropertyValues { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } }

Garbled list literals

I'm seeing some garbled list literals in the transpiler output:
https://github.com/JeroMiya/xamarin.flutter/blob/master/FlutterSDK/src/Foundation/Diagnostics.cs#L761

        public new List<FlutterSDK.Foundation.Diagnostics.DiagnosticsNode> DebugDescribeChildren() => new List, <DiagnosticsNode>(};

Looks to be related to instantiating generic types maybe? Or it could be related to method body expressions like => {method body}.

This should be a high priority bug because the garbled method bodies are breaking {} pairs in the output causing a number of unrelated syntax errors.

Hand-port Mixin base classes for now

Mixins are going to be a tricky feature to implement in the code gen for the following reasons:

  • C# doesn't support them natively.
  • We can port "Mixin" classes from Dart into C# 8.0 interfaces with default implementations, but we'd need to know how a class ends up being used before switching from a class output to an interface-with-default-implementations output.

It's going to be a long time before the generator is able to support mixins, so for now, hand-port or override the generator output for mixin base classes and use interfaces with default implementations.

Currently I'm aware of some defined in Diagnostics.dart in the Foundation section. There may be more.

Reduce default verbosity of the analyzer

The analyzer currently spits out a console message for each file it converts. However, I'd like to start outputting warnings and such, e.g. for files that are skipped, unsupported Dart syntax, etc... and the current output is too verbose for that to be useful.

For now, just disable the current verbose file conversion messages. If it's useful, we can add them back later as an option.

Sometimes "@Object" is used as a type name instead of "Object" or maybe "DartObject"

For example, see FlutterSDK/Cupertino/Colors.cs in the generated output, you'll see for example this line:

internal static FlutterSDK.Foundation.Diagnostics.DiagnosticsProperty<Color> CreateCupertinoColorProperty(string name,FlutterBinding.UI.Color value,bool showName = true,@Object defaultValue = default(@Object),FlutterSDK.Foundation.Diagnostics.DiagnosticsTreeStyle style = default(FlutterSDK.Foundation.Diagnostics.DiagnosticsTreeStyle),DiagnosticLevel level = default(DiagnosticLevel)){
throw new NotImplementedException();
}

}

Without doing too deep of a dive into the code, I'm going to guess the generator is prefixing @Object because it's generated a class called Object (probably the dart base object class?), in which case it would probably be better to rename this DartObject and add a type name rewriting rule to make this more clear.

Async function support

Async functions currently get garbled in the transpiled output. Also, yield* <exp>; statements need to be translated to async foreach(var enumItem in (<exp>)) { yield return enumItem; }.

Named constructors are incorrectly transpiled

Named constructors in dart are actual constructors. While we have to transpile them into static methods in C#, we also have to generate the corresponding constructor. Otherwise, we'll get syntax errors if there is no default constructor or if fields are readonly fields or properties.

The named constructor in Dart should be transpiled into a regular private constructor in C#, followed by a static method representing the named constructor which forwards the parameters to the internal constructor.

Run dotnet format on generated output

Rather than spend a bunch of time making sure the code generator outputs properly indented and formatted code, just run dotnet format on the output at the end.

Also update the readme with instructions on installing the dotnet-format tool.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.