don't use C#6 language features for the time being

This commit is contained in:
Armin Sander
2015-09-25 10:48:46 +02:00
parent cefd6ccb96
commit 2e908bfdee
7 changed files with 92 additions and 35 deletions

View File

@@ -9,7 +9,6 @@
using System; using System;
using NUnit.Framework; using NUnit.Framework;
using static Facebook.CSSLayout.CSSLayout;
namespace Facebook.CSSLayout.Tests namespace Facebook.CSSLayout.Tests
{ {
@@ -19,6 +18,13 @@ namespace Facebook.CSSLayout.Tests
*/ */
public class LayoutEngineTest public class LayoutEngineTest
{ {
const int POSITION_LEFT = CSSLayout.POSITION_LEFT;
const int POSITION_TOP = CSSLayout.POSITION_TOP;
const int POSITION_RIGHT = CSSLayout.POSITION_RIGHT;
const int POSITION_BOTTOM = CSSLayout.POSITION_BOTTOM;
const int DIMENSION_HEIGHT = CSSLayout.DIMENSION_HEIGHT;
const int DIMENSION_WIDTH = CSSLayout.DIMENSION_WIDTH;
static readonly MeasureFunction sTestMeasureFunction = (node, width) => static readonly MeasureFunction sTestMeasureFunction = (node, width) =>
{ {
if (CSSConstants.IsUndefined(width)) { if (CSSConstants.IsUndefined(width)) {

View File

@@ -10,7 +10,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using static Facebook.CSSLayout.CSSLayout;
namespace Facebook.CSSLayout namespace Facebook.CSSLayout
{ {
@@ -27,6 +26,13 @@ namespace Facebook.CSSLayout
public class CSSNode public class CSSNode
{ {
const int POSITION_LEFT = CSSLayout.POSITION_LEFT;
const int POSITION_TOP = CSSLayout.POSITION_TOP;
const int POSITION_RIGHT = CSSLayout.POSITION_RIGHT;
const int POSITION_BOTTOM = CSSLayout.POSITION_BOTTOM;
const int DIMENSION_WIDTH = CSSLayout.DIMENSION_WIDTH;
const int DIMENSION_HEIGHT = CSSLayout.DIMENSION_HEIGHT;
enum LayoutState enum LayoutState
{ {
/** /**
@@ -62,13 +68,19 @@ namespace Facebook.CSSLayout
LayoutState mLayoutState = LayoutState.DIRTY; LayoutState mLayoutState = LayoutState.DIRTY;
public int ChildCount public int ChildCount
=> mChildren.Count; {
get { return mChildren.Count; }
}
public CSSNode this[int i] public CSSNode this[int i]
=> mChildren[i]; {
get { return mChildren[i]; }
}
public IEnumerable<CSSNode> Children public IEnumerable<CSSNode> Children
=> mChildren; {
get { return mChildren; }
}
public void AddChild(CSSNode child) public void AddChild(CSSNode child)
{ {
@@ -124,7 +136,9 @@ namespace Facebook.CSSLayout
} }
public bool IsMeasureDefined public bool IsMeasureDefined
=> mMeasureFunction != null; {
get { return mMeasureFunction != null; }
}
internal MeasureOutput measure(MeasureOutput measureOutput, float width) internal MeasureOutput measure(MeasureOutput measureOutput, float width)
{ {
@@ -152,14 +166,18 @@ namespace Facebook.CSSLayout
*/ */
public bool IsDirty public bool IsDirty
=> mLayoutState == LayoutState.DIRTY; {
get { return mLayoutState == LayoutState.DIRTY; }
}
/** /**
* See {@link LayoutState#HAS_NEW_LAYOUT}. * See {@link LayoutState#HAS_NEW_LAYOUT}.
*/ */
public bool HasNewLayout public bool HasNewLayout
=> mLayoutState == LayoutState.HAS_NEW_LAYOUT; {
get { return mLayoutState == LayoutState.HAS_NEW_LAYOUT; }
}
internal protected void dirty() internal protected void dirty()
{ {
@@ -395,11 +413,30 @@ namespace Facebook.CSSLayout
set { updateFloatValue(ref style.maxHeight, value); } set { updateFloatValue(ref style.maxHeight, value); }
} }
public float LayoutX => layout.position[POSITION_LEFT]; public float LayoutX
public float LayoutY => layout.position[POSITION_TOP]; {
public float LayoutWidth => layout.dimensions[DIMENSION_WIDTH]; get { return layout.position[POSITION_LEFT]; }
public float LayoutHeight => layout.dimensions[DIMENSION_HEIGHT]; }
public CSSDirection LayoutDirection => layout.direction;
public float LayoutY
{
get { return layout.position[POSITION_TOP]; }
}
public float LayoutWidth
{
get { return layout.dimensions[DIMENSION_WIDTH]; }
}
public float LayoutHeight
{
get { return layout.dimensions[DIMENSION_HEIGHT]; }
}
public CSSDirection LayoutDirection
{
get { return layout.direction; }
}
/** /**
* Set a default padding (left/top/right/bottom) for this node. * Set a default padding (left/top/right/bottom) for this node.

View File

@@ -24,6 +24,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<LangVersion>5</LangVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType> <DebugType>none</DebugType>

View File

@@ -9,7 +9,6 @@
using System; using System;
using boolean = System.Boolean; using boolean = System.Boolean;
using static Facebook.CSSLayout.CSSLayout;
namespace Facebook.CSSLayout namespace Facebook.CSSLayout
{ {
@@ -20,6 +19,13 @@ namespace Facebook.CSSLayout
static class LayoutEngine static class LayoutEngine
{ {
const int POSITION_LEFT = CSSLayout.POSITION_LEFT;
const int POSITION_TOP = CSSLayout.POSITION_TOP;
const int POSITION_RIGHT = CSSLayout.POSITION_RIGHT;
const int POSITION_BOTTOM = CSSLayout.POSITION_BOTTOM;
const int DIMENSION_WIDTH = CSSLayout.DIMENSION_WIDTH;
const int DIMENSION_HEIGHT = CSSLayout.DIMENSION_HEIGHT;
const int CSS_FLEX_DIRECTION_COLUMN = const int CSS_FLEX_DIRECTION_COLUMN =
(int)CSSFlexDirection.Column; (int)CSSFlexDirection.Column;
const int CSS_FLEX_DIRECTION_COLUMN_REVERSE = const int CSS_FLEX_DIRECTION_COLUMN_REVERSE =

View File

@@ -23,7 +23,14 @@ namespace Facebook.CSSLayout
public readonly float Width; public readonly float Width;
public readonly float Height; public readonly float Height;
internal float width => Width; internal float width
internal float height => Height; {
get { return Width; }
}
internal float height
{
get { return Height; }
}
} }
} }