Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"projects": ["src", "test/WebSites", "samples"]
"projects": ["src", "test/WebSites", "samples"],
"sdk": {
"version": "1.0.0-preview2-003154"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the SDK version the build downloads. Is it the correct one for the 1.0.3 milestone?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be good for now. @JunTaoLuo, we'll need to update the CLI to the version that's shipping in the release (if any). Could you file a tracking item for this?

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,14 @@ public static string GetExpressionText(LambdaExpression expression, ExpressionTe
// If parts start with "model", then strip that part away.
if (part == null || part.NodeType != ExpressionType.Parameter)
{
const string dotModel = ".model";
var dotModelLength = dotModel.Length;

var text = builder.ToString();
if (text.StartsWith(".model", StringComparison.OrdinalIgnoreCase))
if (text.StartsWith(dotModel, StringComparison.OrdinalIgnoreCase) &&
(text.Length == dotModelLength || text[dotModelLength] == '.' || text[dotModelLength] == '['))
{
// 6 is the length of the string ".model".
builder.Remove(0, 6);
builder.Remove(0, dotModelLength);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public static IEnumerable<object[]> ExpressionAndTexts
var Model = new TestModel();
var key = "TestModel";
var myModels = new List<TestModel>();
var models = new List<TestModel>();
var modelTest = new TestModel();
var modelType = typeof(TestModel);

return new TheoryData<Expression, string>
{
Expand Down Expand Up @@ -56,6 +59,18 @@ public static IEnumerable<object[]> ExpressionAndTexts
(Expression<Func<TestModel, TestModel>>)(m => Model),
string.Empty
},
{
(Expression<Func<TestModel, int>>)(model => models[0].SelectedCategory.CategoryId),
"models[0].SelectedCategory.CategoryId"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"s[0].SelectedCategory.CategoryId" before fix

},
{
(Expression<Func<TestModel, string>>)(model => modelTest.Name),
"modelTest.Name"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Test.Name" before fix

},
{
(Expression<Func<TestModel, Type>>)(model => modelType),
"modelType"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Type" before fix

},
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the expression uses something from a type or namespace called "Model" e.g m => MyApp.Model.Constants.CopyrightYear or some weird variant like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd have to test those cases. But, this goes beyond the reported problem. So we should focus the follow-up discussion on dev.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

(Expression<Func<IList<TestModel>, Category>>)(model => model[2].SelectedCategory),
"[2].SelectedCategory"
Expand Down Expand Up @@ -157,8 +172,8 @@ public static IEnumerable<object[]> EquivalentExpressions
(Expression<Func<TestModel, string>>)(m => value)
},
{
// These two expressions are not actually equivalent. However ExpressionHelper returns
// string.Empty for these two expressions and hence they are considered as equivalent by the
// These two expressions are not actually equivalent. However ExpressionHelper returns
// string.Empty for these two expressions and hence they are considered as equivalent by the
// cache.
(Expression<Func<TestModel, string>>)(m => Model),
(Expression<Func<TestModel, TestModel>>)(m => m)
Expand Down