Remove In-tree C# Bindings (#1302)

Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1302

These C# bindings were contributed as part of ff8f17ac99. They have occasionally been refreshed, but has never really had validation it built continuously, or dedicated maintenance.

There has been a surge of work with https://github.com/facebook/yoga/pull/1207 to try to modernize the build for these, but checking with jkoritzinsky I'm not sure either of us have the time to commit to supporting these at the same level as other bindings.

Some well-known projects like Unity had already abandoned this set of bindings for their own. 016297e35c (diff-c85198aaac9095a5446ed00b0fba8025072d235b2b69dea8aad85abc64a83e1e)

So, as part of the work for an official OSS release, and really trying to define what is deprecated, and what we will try to support, I am removing the in-tree C# bindings from Yoga.

In the past, gaps in Yoga bindings we haven't supported have led to new bindings with dedicated maintainers e.g. [FlexLayout](https://github.com/layoutBox/FlexLayout), [yoga-rs](https://github.com/bschwind/yoga-rs), [yoga-wasm-web](https://github.com/shuding/yoga-wasm-web). My hope is that by removing the C# bindings that we are not supporting, we free up the opportunity for a new version to become the defacto.

Reviewed By: javache

Differential Revision: D46425886

fbshipit-source-id: df964c4d55adf93c4d1e82c104e74ca5ad181612
This commit is contained in:
Nick Gerleman
2023-06-05 10:48:10 -07:00
committed by Facebook GitHub Bot
parent 1ab0c7b493
commit 5e74e20a4d
194 changed files with 2 additions and 30985 deletions

View File

@@ -1,265 +0,0 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
function toValueCs(value) {
var n = value.toString().replace('px','').replace('%','');
return n + (Number(n) == n && n % 1 !== 0 ? 'f' : '');
}
function toCsUnitValue(value) {
var methodName = '';
if (value.indexOf('%') >= 0){
methodName = '.Percent()';
}
if(value.indexOf('Auto') >= 0){
return 'YogaValue.Auto()';
}
return toValueCs(value) + methodName;
}
var CSEmitter = function() {
Emitter.call(this, 'cs', ' ');
};
CSEmitter.prototype = Object.create(Emitter.prototype, {
constructor:{value:CSEmitter},
emitPrologue:{value:function() {
this.push([
'using System;',
'using NUnit.Framework;',
'',
'namespace Facebook.Yoga',
'{',
]);
this.pushIndent();
this.push([
'[TestFixture]',
'public class YogaTest',
'{',
]);
this.pushIndent();
}},
emitTestPrologue:{value:function(name, experiments, disabled) {
this.push('[Test]');
if (disabled) {
this.push('[Ignore]');
}
this.push('public void Test_' + name + '()');
this.push('{');
this.pushIndent();
this.push('YogaConfig config = new YogaConfig();')
for (var i in experiments) {
this.push('config.SetExperimentalFeatureEnabled(YogaExperimentalFeature.' + experiments[i] +', true);');
}
this.push('');
}},
emitTestTreePrologue:{value:function(nodeName) {
this.push('YogaNode ' + nodeName + ' = new YogaNode(config);');
}},
emitTestEpilogue:{value:function(experiments) {
this.popIndent();
this.push([
'}',
'',
]);
}},
emitEpilogue:{value:function(lines) {
this.popIndent();
this.push('}');
this.popIndent();
this.push([
'}',
'',
]);
}},
AssertEQ:{value:function(v0, v1) {
this.push('Assert.AreEqual(' + v0 + 'f, ' + v1 + ');');
}},
YGAlignAuto:{value:'YogaAlign.Auto'},
YGAlignCenter:{value:'YogaAlign.Center'},
YGAlignFlexEnd:{value:'YogaAlign.FlexEnd'},
YGAlignFlexStart:{value:'YogaAlign.FlexStart'},
YGAlignStretch:{value:'YogaAlign.Stretch'},
YGAlignSpaceBetween:{value:'YogaAlign.SpaceBetween'},
YGAlignSpaceAround:{value:'YogaAlign.SpaceAround'},
YGAlignBaseline:{value:'YogaAlign.Baseline'},
YGDirectionInherit:{value:'YogaDirection.Inherit'},
YGDirectionLTR:{value:'YogaDirection.LTR'},
YGDirectionRTL:{value:'YogaDirection.RTL'},
YGEdgeBottom:{value:'Bottom'},
YGEdgeEnd:{value:'End'},
YGEdgeLeft:{value:'Left'},
YGEdgeRight:{value:'Right'},
YGEdgeStart:{value:'Start'},
YGEdgeTop:{value:'Top'},
YGGutterAll:{value:''},
YGGutterColumn:{value:'Column'},
YGGutterRow:{value:'Row'},
YGFlexDirectionColumn:{value:'YogaFlexDirection.Column'},
YGFlexDirectionColumnReverse:{value:'YogaFlexDirection.ColumnReverse'},
YGFlexDirectionRow:{value:'YogaFlexDirection.Row'},
YGFlexDirectionRowReverse:{value:'YogaFlexDirection.RowReverse'},
YGJustifyCenter:{value:'YogaJustify.Center'},
YGJustifyFlexEnd:{value:'YogaJustify.FlexEnd'},
YGJustifyFlexStart:{value:'YogaJustify.FlexStart'},
YGJustifySpaceAround:{value:'YogaJustify.SpaceAround'},
YGJustifySpaceBetween:{value:'YogaJustify.SpaceBetween'},
YGJustifySpaceEvenly:{value:'YogaJustify.SpaceEvenly'},
YGOverflowHidden:{value:'YogaOverflow.Hidden'},
YGOverflowVisible:{value:'YogaOverflow.Visible'},
YGPositionTypeAbsolute:{value:'YogaPositionType.Static'},
YGPositionTypeRelative:{value:'YogaPositionType.Relative'},
YGPositionTypeAbsolute:{value:'YogaPositionType.Absolute'},
YGUndefined:{value:'YogaConstants.Undefined'},
YGAuto:{value:'YogaConstants.Auto'},
YGDisplayFlex:{value:'YogaDisplay.Flex'},
YGDisplayNone:{value:'YogaDisplay.None'},
YGWrapNoWrap:{value:'YogaWrap.NoWrap'},
YGWrapWrap:{value:'YogaWrap.Wrap'},
YGWrapWrapReverse:{value: 'YogaWrap.WrapReverse'},
YGNodeCalculateLayout:{value:function(node, dir, experiments) {
this.push(node + '.StyleDirection = ' + dir + ';');
this.push(node + '.CalculateLayout();');
}},
YGNodeInsertChild:{value:function(parentName, nodeName, index) {
this.push(parentName + '.Insert(' + index + ', ' + nodeName + ');');
}},
YGNodeLayoutGetLeft:{value:function(nodeName) {
return nodeName + '.LayoutX';
}},
YGNodeLayoutGetTop:{value:function(nodeName) {
return nodeName + '.LayoutY';
}},
YGNodeLayoutGetWidth:{value:function(nodeName) {
return nodeName + '.LayoutWidth';
}},
YGNodeLayoutGetHeight:{value:function(nodeName) {
return nodeName + '.LayoutHeight';
}},
YGNodeStyleSetAlignContent:{value:function(nodeName, value) {
this.push(nodeName + '.AlignContent = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetAlignItems:{value:function(nodeName, value) {
this.push(nodeName + '.AlignItems = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetAlignSelf:{value:function(nodeName, value) {
this.push(nodeName + '.AlignSelf = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetBorder:{value:function(nodeName, edge, value) {
this.push(nodeName + '.Border' + edge + 'Width = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetDirection:{value:function(nodeName, value) {
this.push(nodeName + '.StyleDirection = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetDisplay:{value:function(nodeName, value) {
this.push(nodeName + '.Display = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetFlexBasis:{value:function(nodeName, value) {
this.push(nodeName + '.FlexBasis = ' + toCsUnitValue(value) + ';');
}},
YGNodeStyleSetFlexDirection:{value:function(nodeName, value) {
this.push(nodeName + '.FlexDirection = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetFlexGrow:{value:function(nodeName, value) {
this.push(nodeName + '.FlexGrow = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetFlexShrink:{value:function(nodeName, value) {
this.push(nodeName + '.FlexShrink = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetFlexWrap:{value:function(nodeName, value) {
this.push(nodeName + '.Wrap = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetHeight:{value:function(nodeName, value) {
this.push(nodeName + '.Height = ' + toCsUnitValue(value) + ';');
}},
YGNodeStyleSetJustifyContent:{value:function(nodeName, value) {
this.push(nodeName + '.JustifyContent = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetMargin:{value:function(nodeName, edge, value) {
this.push(nodeName + '.Margin' + edge + ' = ' + toCsUnitValue(value) + ';');
}},
YGNodeStyleSetMaxHeight:{value:function(nodeName, value) {
this.push(nodeName + '.MaxHeight = ' + toCsUnitValue(value) + ';');
}},
YGNodeStyleSetMaxWidth:{value:function(nodeName, value) {
this.push(nodeName + '.MaxWidth = ' + toCsUnitValue(value) + ';');
}},
YGNodeStyleSetMinHeight:{value:function(nodeName, value) {
this.push(nodeName + '.MinHeight = ' + toCsUnitValue(value) + ';');
}},
YGNodeStyleSetMinWidth:{value:function(nodeName, value) {
this.push(nodeName + '.MinWidth = ' + toCsUnitValue(value) + ';');
}},
YGNodeStyleSetOverflow:{value:function(nodeName, value) {
this.push(nodeName + '.Overflow = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetPadding:{value:function(nodeName, edge, value) {
this.push(nodeName + '.Padding' + edge + ' = ' + toCsUnitValue(value) + ';');
}},
YGNodeStyleSetPosition:{value:function(nodeName, edge, value) {
this.push(nodeName + '.' + edge + ' = ' + toCsUnitValue(value) + ';');
}},
YGNodeStyleSetPositionType:{value:function(nodeName, value) {
this.push(nodeName + '.PositionType = ' + toValueCs(value) + ';');
}},
YGNodeStyleSetWidth:{value:function(nodeName, value) {
this.push(nodeName + '.Width = ' + toCsUnitValue(value) + ';');
}},
YGNodeStyleSetGap:{value:function(nodeName, gap, value) {
this.push(nodeName + '.' + gap + 'Gap' + ' = ' + toCsUnitValue(value) + ';');
}},
});

View File

@@ -27,13 +27,6 @@ window.onload = function() {
document.body.children[1],
document.body.children[2]);
printTest(
new CSEmitter(),
'cs',
document.body.children[0],
document.body.children[1],
document.body.children[2]);
printTest(
new JavascriptEmitter(),
'js',

View File

@@ -50,14 +50,10 @@ Dir['fixtures/*.html'].each do |file|
f.write eval(logs[1].message.sub(/^[^"]*/, '')).sub('YogaTest', name)
f.close
f = File.open("../csharp/tests/Facebook.Yoga/#{name}.cs", 'w')
f.write eval(logs[2].message.sub(/^[^"]*/, '')).sub('YogaTest', name)
f.close
print logs[4]
print logs[3]
f = File.open("../javascript/tests/generated/#{name}.test.ts", 'w')
f.write eval(logs[3].message.sub(/^[^"]*/, '')).sub('YogaTest', name)
f.write eval(logs[2].message.sub(/^[^"]*/, '')).sub('YogaTest', name)
f.close
end
File.delete('test.html')

View File

@@ -6,7 +6,6 @@
<script src="gentest.js"></script>
<script src="gentest-cpp.js"></script>
<script src="gentest-java.js"></script>
<script src="gentest-cs.js"></script>
<script src="gentest-javascript.js"></script>
<style>