Skip to content
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

Testing break-initializers-early #8

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ HttpStatusCode statusCode
throw Error.ArgumentNull("request");
}

return new HttpResponseMessage { StatusCode = statusCode, RequestMessage = request };
return new HttpResponseMessage
{
StatusCode = statusCode,
RequestMessage = request
};
}

/// <summary>
Expand Down
30 changes: 26 additions & 4 deletions AspNetWebStack/src/System.Web.Helpers/Chart/Chart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,13 @@ public int Width
/// <param name="name">Legend name.</param>
public Chart AddLegend(string title = null, string name = null)
{
_legends.Add(new LegendData { Name = name, Title = title });
_legends.Add(
new LegendData
{
Name = name,
Title = title
}
);
return this;
}

Expand Down Expand Up @@ -257,7 +263,13 @@ public Chart AddSeries(
/// <param name="name">Title name.</param>
public Chart AddTitle(string text = null, string name = null)
{
_titles.Add(new TitleData { Name = name, Text = text });
_titles.Add(
new TitleData
{
Name = name,
Text = text
}
);
return this;
}

Expand All @@ -266,7 +278,12 @@ public Chart AddTitle(string text = null, string name = null)
/// <param name="max">The maximum value on X-axis. Default NaN</param>
public Chart SetXAxis(string title = "", double min = 0, double max = Double.NaN)
{
_xAxis = new ChartAxisData { Title = title, Minimum = min, Maximum = max };
_xAxis = new ChartAxisData
{
Title = title,
Minimum = min,
Maximum = max
};
return this;
}

Expand All @@ -275,7 +292,12 @@ public Chart SetXAxis(string title = "", double min = 0, double max = Double.NaN
/// <param name="max">The maximum value on Y-axis. Default NaN</param>
public Chart SetYAxis(string title = "", double min = 0, double max = Double.NaN)
{
_yAxis = new ChartAxisData { Title = title, Minimum = min, Maximum = max };
_yAxis = new ChartAxisData
{
Title = title,
Minimum = min,
Maximum = max
};
return this;
}

Expand Down
15 changes: 13 additions & 2 deletions AspNetWebStack/src/System.Web.Helpers/WebGrid/WebGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,14 @@ public SortDirection SortDirection

private SortInfo SortInfo
{
get { return new SortInfo { SortColumn = SortColumn, SortDirection = SortDirection }; }
get
{
return new SortInfo
{
SortColumn = SortColumn,
SortDirection = SortDirection
};
}
}

public string SortDirectionFieldName
Expand Down Expand Up @@ -1200,7 +1207,11 @@ private IEnumerable<WebGridColumn> GetDefaultColumns(IEnumerable<string> exclusi
}
return (
from n in names
select new WebGridColumn { ColumnName = n, CanSort = true }
select new WebGridColumn
{
ColumnName = n,
CanSort = true
}
).ToArray();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ public bool BindModel(HttpActionContext actionContext, ModelBindingContext bindi
ComplexModelDto dto = (ComplexModelDto)bindingContext.Model;
foreach (ModelMetadata propertyMetadata in dto.PropertyMetadata)
{
ModelBindingContext propertyBindingContext = new ModelBindingContext(bindingContext)
{
ModelBindingContext propertyBindingContext = new ModelBindingContext(
bindingContext
) {
ModelMetadata = propertyMetadata,
ModelName = ModelBindingHelper.CreatePropertyModelName(
bindingContext.ModelName,
Expand Down
6 changes: 5 additions & 1 deletion AspNetWebStack/src/System.Web.Http/Routing/RoutingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ public static RoutingContext Invalid()

public static RoutingContext Valid(List<string> pathSegments)
{
return new RoutingContext() { PathSegments = pathSegments, IsValid = true, };
return new RoutingContext()
{
PathSegments = pathSegments,
IsValid = true,
};
}

private RoutingContext() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ object container

// Per the WCF RIA Services team, instance can never be null (if you have
// no parent, you pass yourself for the "instance" parameter).
ValidationContext context = new ValidationContext(instance: container ?? metadata.Model)
{
ValidationContext context = new ValidationContext(
instance: container ?? metadata.Model
) {
DisplayName = metadata.GetDisplayName(),
MemberName = memberName,
};
Expand Down
7 changes: 6 additions & 1 deletion AspNetWebStack/src/System.Web.Mvc/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,12 @@ protected internal virtual ViewResult View(IView view, object model)
ViewData.Model = model;
}

return new ViewResult { View = view, ViewData = ViewData, TempData = TempData };
return new ViewResult
{
View = view,
ViewData = ViewData,
TempData = TempData
};
}

IAsyncResult IAsyncController.BeginExecute(
Expand Down
8 changes: 7 additions & 1 deletion AspNetWebStack/src/System.Web.Mvc/Html/EnumHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,13 @@ public static IList<SelectListItem> GetSelectList(Type type)
if (checkedType != type)
{
// Underlying type was non-null so handle Nullable<T>; ensure returned list has a spot for null
selectList.Add(new SelectListItem { Text = String.Empty, Value = String.Empty, });
selectList.Add(
new SelectListItem
{
Text = String.Empty,
Value = String.Empty,
}
);
}

// Populate the list
Expand Down
6 changes: 5 additions & 1 deletion AspNetWebStack/src/System.Web.Mvc/ViewDataDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,11 @@ private static ViewDataInfo GetIndexedPropertyValue(object indexableObject, stri

if (success)
{
return new ViewDataInfo() { Container = indexableObject, Value = value };
return new ViewDataInfo()
{
Container = indexableObject,
Value = value
};
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,13 @@ string optionText
if (optionText != null)
{
builder.AppendLine(
ListItemToOption(new SelectListItem { Text = optionText, Value = String.Empty })
ListItemToOption(
new SelectListItem
{
Text = optionText,
Value = String.Empty
}
)
);
}
if (selectList != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,27 @@ public void RadioButtonListWithDictionaryAttributesWithSelectListNameAndNullSele
private static SelectList GetRadioButtonListData(bool selectBaz)
{
List<RadioItem> list = new List<RadioItem>();
list.Add(new RadioItem { Text = "text-foo", Value = "foo" });
list.Add(new RadioItem { Text = "text-bar", Value = "bar" });
list.Add(new RadioItem { Text = "text-baz", Value = "baz" });
list.Add(
new RadioItem
{
Text = "text-foo",
Value = "foo"
}
);
list.Add(
new RadioItem
{
Text = "text-bar",
Value = "bar"
}
);
list.Add(
new RadioItem
{
Text = "text-baz",
Value = "baz"
}
);
return new SelectList(list, "value", "TEXT", selectBaz ? "baz" : "something-else");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ public class FormUrlEncodedMediaTypeFormatterTests
void CopyConstructor()
{
TestFormUrlEncodedMediaTypeFormatter formatter =
new TestFormUrlEncodedMediaTypeFormatter() { MaxDepth = 42, ReadBufferSize = 512 };
new TestFormUrlEncodedMediaTypeFormatter()
{
MaxDepth = 42,
ReadBufferSize = 512
};

TestFormUrlEncodedMediaTypeFormatter derivedFormatter =
new TestFormUrlEncodedMediaTypeFormatter(formatter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,31 @@ public static TheoryDataSet<object, string> SerializedJson
"\"4ed1cd44-11d7-4b27-b623-0b8b553c8906\""
},
// Structs
{ new Point() { x = 45, Y = -5 }, "{\"x\":45,\"Y\":-5}" },
{
new Point()
{
x = 45,
Y = -5
},
"{\"x\":45,\"Y\":-5}"
},
// Arrays
{ new object[] { }, "[]" },
{ new int[] { 1, 2, 3 }, "[1,2,3]" },
{ new string[] { "a", "b" }, "[\"a\",\"b\"]" },
{
new Point[]
{
new Point() { x = 10, Y = 10 },
new Point() { x = 20, Y = 20 }
new Point()
{
x = 10,
Y = 10
},
new Point()
{
x = 20,
Y = 20
}
},
"[{\"x\":10,\"Y\":10},{\"x\":20,\"Y\":20}]"
},
Expand All @@ -89,8 +104,16 @@ public static TheoryDataSet<object, string> SerializedJson
{
new List<Point>
{
new Point() { x = 10, Y = 10 },
new Point() { x = 20, Y = 20 }
new Point()
{
x = 10,
Y = 10
},
new Point()
{
x = 20,
Y = 20
}
},
"[{\"x\":10,\"Y\":10},{\"x\":20,\"Y\":20}]"
},
Expand All @@ -99,8 +122,16 @@ public static TheoryDataSet<object, string> SerializedJson
{
new MyList<Point>
{
new Point() { x = 10, Y = 10 },
new Point() { x = 20, Y = 20 }
new Point()
{
x = 10,
Y = 10
},
new Point()
{
x = 20,
Y = 20
}
},
"[{\"x\":10,\"Y\":10},{\"x\":20,\"Y\":20}]"
},
Expand All @@ -118,10 +149,22 @@ public static TheoryDataSet<object, string> SerializedJson
{ new { Anon1 = 56, Anon2 = "foo" }, "{\"Anon1\":56,\"Anon2\":\"foo\"}" },
// Classes
{
new DataContractType() { s = "foo", i = 49, NotAMember = "Error" },
new DataContractType()
{
s = "foo",
i = 49,
NotAMember = "Error"
},
"{\"s\":\"foo\",\"i\":49}"
},
{ new POCOType() { s = "foo", t = "Error" }, "{\"s\":\"foo\"}" },
{
new POCOType()
{
s = "foo",
t = "Error"
},
"{\"s\":\"foo\"}"
},
#if !NETFX_CORE // Only publics are serialized in portable library
{
new SerializableType("protected")
Expand Down Expand Up @@ -196,7 +239,13 @@ public static TheoryDataSet<object, string, Type> TypedSerializedJson
{ new ConsoleColor?(), "null", typeof(ConsoleColor?) },
{ new int?(45), "45", typeof(int?) },
{
new Point?(new Point() { x = 45, Y = -5 }),
new Point?(
new Point()
{
x = 45,
Y = -5
}
),
"{\"x\":45,\"Y\":-5}",
typeof(Point?)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,36 @@ public Task ClassWithFields()
[Fact]
public Task PrivateProperty()
{
var source2 = new PrivateProperty { FirstName = "John", LastName = "Smith" };
var source2 = new PrivateProperty
{
FirstName = "John",
LastName = "Smith"
};
source2.SetItem("shoes");
return SerializerConsistencyHepers.TestAsync(source2);
}

[Fact]
public Task NormalClass()
{
var source = new NormalClass { FirstName = "John", LastName = "Smith", Item = "Socks" };
var source = new NormalClass
{
FirstName = "John",
LastName = "Smith",
Item = "Socks"
};
return SerializerConsistencyHepers.TestAsync(source);
}

[Fact]
public Task InheritedProperties()
{
// Will we pick up inherited properties from a base object?
BaseClass source = new DerivedClass { Property = "base", DerivedProperty = "derived" };
BaseClass source = new DerivedClass
{
Property = "base",
DerivedProperty = "derived"
};
source.SetField("private");
return SerializerConsistencyHepers.TestAsync(source, typeof(DerivedClass));
}
Expand Down
Loading