Permalink
Browse files

Fix fxcop issue

  • Loading branch information...
LaylaLiu committed Nov 15, 2016
1 parent a2af8c6 commit dc9632b686e47dba8a0bbeffb5cc8c5850e27c8b
@@ -57,8 +57,8 @@ protected override void ReadWithExpectedType(IEdmTypeReference expectedClientTyp
}
Type underlyingExpectedType = Nullable.GetUnderlyingType(this.ExpectedType) ?? this.ExpectedType;
bool isClrCollection = WebUtil.IsCLRTypeCollection(underlyingExpectedType, this.MaterializerContext.Model);
Debug.Assert(isClrCollection || (SingleResult.HasValue && !SingleResult.Value), "expected type must be collection or single result must be false");
Debug.Assert(WebUtil.IsCLRTypeCollection(underlyingExpectedType, this.MaterializerContext.Model)
|| (SingleResult.HasValue && !SingleResult.Value), "expected type must be collection or single result must be false");
// We are here for two cases:
// (1) Something like Execute<ICollection<T>>, in which case the underlyingExpectedType is ICollection<T>
@@ -347,13 +347,17 @@ private void PopScope(ODataDeltaReaderState state)
{
Debug.Assert(this.scopes.Count > 1, "Stack must have more than 1 items in order to pop an item.");
#if DEBUG
Scope scope = this.scopes.Pop();
Debug.Assert(scope.State == state, "scope.State == state");
#else
this.scopes.Pop();
#endif
}
#endregion
#endregion
#region Verify Methods
#region Verify Methods
/// <summary>
/// Verifies that calling Read is valid.
@@ -396,9 +400,9 @@ private void VerifyCallAllowed(bool synchronousCall)
}
}
#endregion
#endregion
#region Exception Methods
#region Exception Methods
/// <summary>
/// Catch any exception thrown by the action passed in; in the exception case move the reader into
@@ -425,9 +429,9 @@ private T InterceptException<T>(Func<T> action)
}
}
#endregion
#endregion
#region Read<...>Value Methods
#region Read<...>Value Methods
/// <summary>
/// Read value as Uri in Json reader.
@@ -447,9 +451,9 @@ private string ReadStringValue()
return this.jsonLightResourceDeserializer.JsonReader.ReadStringValue();
}
#endregion
#endregion
#region Read Sync/Async Methods
#region Read Sync/Async Methods
/// <summary>
/// Reads the next <see cref="ODataItem"/> from the message payload.
@@ -572,9 +576,9 @@ private Task<bool> ReadAsynchronously()
}
#endif
#endregion
#endregion
#region ReadAt<...>Implementation Methods
#region ReadAt<...>Implementation Methods
/// <summary>
/// Handle some thing before reading at Start.
@@ -652,9 +656,9 @@ private bool ReadAtNestedResourceInfoImplementation()
return this.ReadAtNestedResourceInfoImplementationSynchronously();
}
#endregion
#endregion
#region ReadAt<...>ImplementationAsync Methods
#region ReadAt<...>ImplementationAsync Methods
#if PORTABLELIB
/// <summary>
@@ -720,9 +724,9 @@ private Task<bool> ReadAtNestedResourceInfoImplementationAsync()
}
#endif
#endregion
#endregion
#region ReadAt<...>ImplementationSynchronously Methods
#region ReadAt<...>ImplementationSynchronously Methods
/// <summary>
/// Implementation of the reader logic when in state 'Start'.
@@ -1055,9 +1059,9 @@ private void ReadAtDeltaDeletedLinkImplementationSynchronously()
this.jsonLightResourceDeserializer.JsonReader.Read();
}
#endregion
#endregion
#region ReadDeltaResourceSet<...> Methods
#region ReadDeltaResourceSet<...> Methods
/// <summary>
/// Reads the start of the JSON array for the content of the resource set and sets up the reader state correctly.
@@ -1092,9 +1096,9 @@ private void ReadResourceSetEnd()
this.ReplaceScope(ODataDeltaReaderState.DeltaResourceSetEnd);
}
#endregion
#endregion
#region ReadDeltaResource<...> Methods
#region ReadDeltaResource<...> Methods
/// <summary>
/// Reads the start of a delta item and sets up the reader state correctly
@@ -1204,9 +1208,9 @@ private void ReadDeltaResourceId()
this.jsonLightResourceDeserializer.AssertJsonCondition(JsonNodeType.Property, JsonNodeType.EndObject);
}
#endregion
#endregion
#region ReadDeltaDeletedEntry<...> Methods
#region ReadDeltaDeletedEntry<...> Methods
/// <summary>
/// Reads the delta deleted resource id.
@@ -1283,9 +1287,9 @@ private void ReadDeltaDeletedEntryReason()
this.jsonLightResourceDeserializer.AssertJsonCondition(JsonNodeType.Property, JsonNodeType.EndObject);
}
#endregion
#endregion
#region ReadDeltaLink<...> Methods
#region ReadDeltaLink<...> Methods
/// <summary>
/// Reads the delta link source.
@@ -1383,9 +1387,9 @@ private void ReadDeltaLinkTarget()
this.jsonLightResourceDeserializer.AssertJsonCondition(JsonNodeType.Property, JsonNodeType.EndObject);
}
#endregion
#endregion
#region ReadDeltaDeletedLink<...> Methods
#region ReadDeltaDeletedLink<...> Methods
/// <summary>
/// Reads the delta deleted link source.
@@ -1483,9 +1487,9 @@ private void ReadDeltaDeletedLinkTarget()
this.jsonLightResourceDeserializer.AssertJsonCondition(JsonNodeType.Property, JsonNodeType.EndObject);
}
#endregion
#endregion
#region Start<...> Methods
#region Start<...> Methods
/// <summary>
/// Starts the resource, initializing the scopes and such. This method starts a non-null resource only.
@@ -1532,9 +1536,9 @@ private void StartDeltaLink(ODataDeltaReaderState state, PropertyAndAnnotationCo
this.CurrentScope.ODataUri));
}
#endregion
#endregion
#region Others
#region Others
/// <summary>
/// If an entity type name is found in the payload this method is called to apply it to the current scope.
@@ -1584,11 +1588,11 @@ private void ApplyEntityTypeNameFromPayload(string entityTypeNameFromPayload)
this.CurrentEntityType = targetEntityType;
}
#endregion
#endregion
#endregion
#endregion
#region Private Static Methods
#region Private Static Methods
/// <summary>
/// Creates a new delta (deleted) resource to return to the user.
@@ -1644,9 +1648,9 @@ private static Scope CreateExceptionScope()
return new Scope(ODataDeltaReaderState.Exception, null, null, null, null);
}
#endregion
#endregion
#region Scope Classes
#region Scope Classes
/// <summary>
/// A reader scope; keeping track of the current reader state and an item associated with this state.
@@ -2002,6 +2006,6 @@ public JsonLightTopLevelScope(IEdmNavigationSource navigationSource, IEdmEntityT
public PropertyAndAnnotationCollector PropertyAndAnnotationCollector { get; set; }
}
#endregion
#endregion
}
}
@@ -986,17 +986,15 @@ private void WriteEndImplementation()
{
case WriterState.DeltaResource:
{
ODataResource resource = (ODataResource)currentScope.Item;
Debug.Assert(resource != null, "resource == null");
Debug.Assert((ODataResource)currentScope.Item != null, "resource == null");
this.EndDeltaResource();
}
break;
case WriterState.DeltaDeletedEntry:
{
ODataDeltaDeletedEntry resource = (ODataDeltaDeletedEntry)currentScope.Item;
Debug.Assert(resource != null, "resource == null");
Debug.Assert((ODataDeltaDeletedEntry)currentScope.Item != null, "resource == null");
this.EndDeltaResource();
}
@@ -188,8 +188,7 @@ public static bool TryParseNullableTokens(string text, out SegmentArgumentParser
public bool TryConvertValues(IEdmEntityType targetEntityType, out IEnumerable<KeyValuePair<string, object>> keyPairs, ODataUriResolver resolver)
{
Debug.Assert(!this.IsEmpty, "!this.IsEmpty -- caller should check");
IList<IEdmStructuralProperty> keyProperties = targetEntityType.Key().ToList();
Debug.Assert(keyProperties.Count == this.ValueCount || resolver.GetType() != typeof(ODataUriResolver), "type.KeyProperties.Count == this.ValueCount -- will change with containment");
Debug.Assert(targetEntityType.Key().Count() == this.ValueCount || resolver.GetType() != typeof(ODataUriResolver), "type.KeyProperties.Count == this.ValueCount -- will change with containment");
if (this.NamedValues != null)
{
@@ -198,7 +197,7 @@ public bool TryConvertValues(IEdmEntityType targetEntityType, out IEnumerable<Ke
else
{
Debug.Assert(this.positionalValues != null, "positionalValues != null -- otherwise this is Empty");
Debug.Assert(this.PositionalValues.Count == keyProperties.Count || resolver.GetType() != typeof(ODataUriResolver), "Count of positional values does not match.");
Debug.Assert(this.PositionalValues.Count == targetEntityType.Key().Count() || resolver.GetType() != typeof(ODataUriResolver), "Count of positional values does not match.");
keyPairs = resolver.ResolveKeys(targetEntityType, this.PositionalValues, this.ConvertValueWrapper);
}

0 comments on commit dc9632b

Please sign in to comment.