-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Introducing .NET version of css-layout using P/Invoke #220
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks! |
@mattpodwysocki updated the pull request - view changes |
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.
Could you remove the non-native version and its code dependencies. You don't need to mirror the java version which has a an interface backed by both a java implementation and a native implementation, that is being removed very soon.
@@ -0,0 +1,265 @@ | |||
## Ignore Visual Studio temporary files, build results, and |
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.
please mirror this in a corresponding .hgignore
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.
@emilsjolander ok, will do
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.
@emilsjolander done
@@ -6,3 +6,6 @@ | |||
/.buckd | |||
/lib/gtest/googletest-*/ | |||
/gentest/test.html | |||
|
|||
# Visual studio code |
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.
Please mirror this in .hgignore
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.
@emilsjolander done
@@ -0,0 +1,206 @@ | |||
/** |
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.
This seems annoying to maintain. Can we make this use the same .h file as the C version?
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.
@emilsjolander we could if you want pragma comments for checking if Windows, sure
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.
Or some macro magic?
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.
@emilsjolander should we update it as such? https://gist.github.com/mattpodwysocki/c48da3dd668708ee227263b2ae382815
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.
perfect!
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.
@emilsjolander removed as per request
@@ -0,0 +1,12 @@ | |||
namespace Facebook.CSSLayout | |||
{ | |||
public class CSSCachedMeasurement |
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.
This class should not be needed as it is not part of the public api
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.
@emilsjolander removed as per request
namespace Facebook.CSSLayout | ||
{ | ||
public class CSSLayout | ||
{ |
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.
This class should not be needed as it is handled in the C code.
@@ -0,0 +1,8 @@ | |||
namespace Facebook.CSSLayout | |||
{ | |||
public class CSSLayoutContext |
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.
This class should not be needed as the C version does not have it.
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.
@emilsjolander is the intent then not to implement the regular CSSNode
class and only implement the native class?
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.
yup!
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.
@emilsjolander removed as per request
@mattpodwysocki updated the pull request - view changes |
@mattpodwysocki updated the pull request - view changes |
@mattpodwysocki updated the pull request - view changes |
@mattpodwysocki updated the pull request - view changes |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Everything is looking great. Thanks for being so responsive! Only thing I see missing is integrating this with buck. You can find more info on building csharp with buck here https://buckbuild.com/rule/csharp_library.html |
@mattpodwysocki updated the pull request - view changes |
I chatted with @mattpodwysocki and there are a couple things that are blocking proper buck support for this so we will skip getting this working on this pull request and instead we plan on fixing this afterwards. |
@mattpodwysocki updated the pull request - view changes |
Looking great! Thanks for the super quick response times. I'll try to merge this today. |
Thanks for importing. If you are a Facebook employee, you can view this diff on Phabricator. |
facebook/react-native@2da0888
Summary: This version of the css-layout project includes support for .NET projects. Up in the air is how many configurations of .NET projects we allow for, such as Portable Class Libraries, Universal Windows Platform, .NET Core, etc. Still needs integration with Buck. Closes #220 Reviewed By: lucasr Differential Revision: D3909367 Pulled By: emilsjolander fbshipit-source-id: aaaa9c4ff2d3452649f256c3268cf873cf33a0b9
Can you clarify goodness? It's nothing in code, only confused me more.. |
Pavel, what are you referring to?
|
The C stuff looks a bit Windows-specific; it would be good to get a build working on Linux too so this could be used on .NET Core or on Mono 😄 |
@@ -0,0 +1,265 @@ | |||
## Ignore Visual Studio temporary files, build results, and |
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.
I wonder if .hgignore
could just be a symlink to .gitignore
?
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.
Yeah probably
{ | ||
public class CSSLayoutContext | ||
{ | ||
public MeasureOutput measureOutput { get; } = new MeasureOutput(); |
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.
Uppercase first character of property name (measureOutput
-> MeasureOutput
)?
{ | ||
if (_isDisposed) | ||
{ | ||
throw new ObjectDisposedException("CSSNode"); |
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.
nameof(CSSNode)
assuming you're using C# 6.0 😄
CheckDisposed(); | ||
Native.CSSNodeStyleSetFlex(_cssNode, value); | ||
} | ||
} |
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.
All these properties feel like a lot of boilerplate, I wonder if they could be autogenerated?
{ | ||
private const string DllName = "CSSLayout.dll"; | ||
|
||
[DllImport(DllName)] |
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.
I think this should omit the .dll
suffix so it could potentially work on Linux in the future.
@Daniel15 Feel free to open a pull request with further platform support 👍 |
This version of the css-layout project includes support for .NET projects. Up in the air is how many configurations of .NET projects we allow for, such as Portable Class Libraries, Universal Windows Platform, .NET Core, etc. Still needs integration with Buck.