internal static bool TryMakeUnresolvedInterfaceAnnotation(CCCheckExtraInfo extrainfo, Squiggle squiggle, ClousotSuggestion.Kind kind, out UnresolvedInterfaceAnnotation annotation) { #region CodeContracts Contract.Requires(extrainfo != null); Contract.Requires(extrainfo.CalleeDocumentId != null); Contract.Requires(extrainfo.TypeDocumentId != null); Contract.Requires(extrainfo.SuggestedCode != null); Contract.Requires(squiggle != null); Contract.Requires(kind == ClousotSuggestion.Kind.EnsuresNecessary); Contract.Ensures(!Contract.Result <bool>() || Contract.ValueAtReturn <UnresolvedInterfaceAnnotation>(out annotation) != null); #endregion CodeContracts annotation = null; var InterfaceMethod = extrainfo.CalleeDocumentId; var InterfaceName = extrainfo.TypeDocumentId; var ParametersString = ""; if (InterfaceName.Contains('<')) { var lastAngle = InterfaceName.LastIndexOf('<'); var beforeAngle = InterfaceName.Remove(lastAngle); var afterAngle = InterfaceName.Replace(beforeAngle, ""); if (string.IsNullOrEmpty(afterAngle)) { RBLogger.Error("Failed to parse interface name {0}", InterfaceName); return(false); } InterfaceName = beforeAngle; var parts = afterAngle.Trim('<', '>').Split(','); ParametersString = "<" + parts[0].Replace("type parameter.", ""); for (int i = 1; i < parts.Length; i++) { ParametersString += ',' + parts[i].Replace("type parameter.", ""); } ParametersString += ">"; } annotation = new UnresolvedInterfaceAnnotation(extrainfo.SuggestedCode, squiggle, kind, ParametersString, InterfaceName, InterfaceMethod); return(true); }
internal static bool TryMakeUnresolvedInterfaceAnnotation(CCCheckExtraInfo extrainfo, Squiggle squiggle, ClousotSuggestion.Kind kind, out UnresolvedInterfaceAnnotation annotation) { #region CodeContracts Contract.Requires(extrainfo != null); Contract.Requires(extrainfo.CalleeDocumentId != null); Contract.Requires(extrainfo.TypeDocumentId != null); Contract.Requires(extrainfo.SuggestedCode != null); Contract.Requires(squiggle != null); Contract.Requires(kind == ClousotSuggestion.Kind.EnsuresNecessary); Contract.Ensures(!Contract.Result<bool>() || Contract.ValueAtReturn<UnresolvedInterfaceAnnotation>(out annotation) != null); #endregion CodeContracts annotation = null; var InterfaceMethod = extrainfo.CalleeDocumentId; var InterfaceName = extrainfo.TypeDocumentId; var ParametersString = ""; if (InterfaceName.Contains('<')) { var lastAngle = InterfaceName.LastIndexOf('<'); var beforeAngle = InterfaceName.Remove(lastAngle); var afterAngle = InterfaceName.Replace(beforeAngle, ""); if (string.IsNullOrEmpty(afterAngle)) { RBLogger.Error("Failed to parse interface name {0}", InterfaceName); return false; } InterfaceName = beforeAngle; var parts = afterAngle.Trim('<', '>').Split(','); ParametersString = "<" + parts[0].Replace("type parameter.", ""); for (int i = 1; i < parts.Length; i++) { ParametersString += ',' + parts[i].Replace("type parameter.", ""); } ParametersString += ">"; } annotation = new UnresolvedInterfaceAnnotation(extrainfo.SuggestedCode, squiggle, kind, ParametersString, InterfaceName, InterfaceMethod); return true; }