{
Log.Error("NUI", $"[ERROR] Fail to initialize Feedback: {e}");
}
- catch (NullReferenceException e)
- {
- Log.Error("NUI", $"[ERROR] Null reference error in Feedback: {e}");
- }
}
else
{
startScrollOffset = (int)pickerStyle.StartScrollOffset.Height;
}
- if (pickerStyle.ItemTextLabel?.Size != null)
+ if (pickerStyle.ItemTextLabel?.Size is var itemSize && itemSize != null)
{
- itemHeight = (int)pickerStyle.ItemTextLabel.Size.Height;
+ itemHeight = (int)itemSize.Height;
}
- if (pickerStyle.Size != null)
+ if (pickerStyle.Size is var pSize && pSize != null)
{
- Size = new Size(-1, pickerStyle.Size.Height);
+ Size = new Size(-1, pSize.Height);
}
}
else if (collectionView.SelectionMode is ItemSelectionMode.Multiple)
{
var selectedList = collectionView.SelectedItems;
- if (selectedList != null)
+ if (selectedList != null && context != null)
{
bool contains = selectedList.Contains(context);
if (newSelected && !contains)
/// <since_tizen> 8 </since_tizen>
public void ScrollToIndex(int index)
{
- if (ContentContainer.ChildCount - 1 < index || index < 0)
+ if ((int)ContentContainer.ChildCount - 1 < index || index < 0)
{
return;
}
{
if (description == field.Name)
{
- return (T)field.GetValue(null);
+ var fvalue = field.GetValue(null);
+ return fvalue != null ? (T)fvalue : default(T);
}
var attributes = (DescriptionAttribute[])field.GetCustomAttributes(typeof(DescriptionAttribute), true);
{
if (description == attributes.First().Description)
{
- return (T)field.GetValue(null);
+ var fvalue = field.GetValue(null);
+ return fvalue != null ? (T)fvalue : default(T);
}
}
}
- return (T)type.GetFields(BindingFlags.Public | BindingFlags.Static).FirstOrDefault().GetValue(null);
+ var value = type.GetFields(BindingFlags.Public | BindingFlags.Static).FirstOrDefault().GetValue(null);
+ return value != null ? (T)value : default(T);
//throw new ArgumentException($"{description} can't be found.", "Description");
}
Values[node] = value;
}
- if (value is BindableObject)
+ if (value != null && value is BindableObject)
NameScope.SetNameScope(value as BindableObject, node.Namescope);
}
object sourceObject;
if (_weakSource != null && _weakSource.TryGetTarget(out sourceObject))
{
- if (_parts.Count > 1)
+ for (var i = 0; i < _parts.Count; i++)
{
- for (var i = 0; i < _parts.Count - 1; i++)
- {
- BindingExpressionPart part = _parts[i];
+ if (i + 1 == _parts.Count) //do not handle the last.
+ break;
- if (!part.IsSelf)
- {
- part.TryGetValue(sourceObject, out sourceObject);
- }
+ BindingExpressionPart part = _parts[i];
- part.Unsubscribe();
+ if (!part.IsSelf)
+ {
+ part.TryGetValue(sourceObject, out sourceObject);
}
+
+ part.Unsubscribe();
}
}
/// You can get the bind IDs in RenderCallbackInput in the glRenderFrame callback.
/// </summary>
/// <param name="textures">List of Textures</param>
+ /// <exception cref="OverflowException"> Thrown when length of textures list is overflow. </exception>
public void BindTextureResources(List<Texture> textures)
{
unsafe
{
- if (textures != null && textures.Count > 0)
+ if (textures != null && sizeof(IntPtr) * textures.Count > 0)
{
- IntPtr unmanagedPointer = Marshal.AllocHGlobal(sizeof(IntPtr) * textures.Count);
+ IntPtr unmanagedPointer = Marshal.AllocHGlobal(checked(sizeof(IntPtr) * textures.Count));
IntPtr[] texturesArray = new IntPtr[textures.Count];
for (int i = 0; i < textures.Count; i++)
{
if (widthMeasureSpec.Mode != MeasureSpecification.ModeType.Exactly)
{
- totalWidth = Math.Min(Math.Max(naturalSize.Width, minSize.Width), maxSize.Width);
+ float width = naturalSize != null ? naturalSize.Width : 0;
+ totalWidth = Math.Min(Math.Max(width, minSize.Width), maxSize.Width);
}
if (heightMeasureSpec.Mode != MeasureSpecification.ModeType.Exactly)
{
- totalHeight = Math.Min(Math.Max(naturalSize.Height, minSize.Height), maxSize.Height);
+ float height = naturalSize != null ? naturalSize.Height : 0;
+ totalHeight = Math.Min(Math.Max(height, minSize.Height), maxSize.Height);
}
widthMeasureSpec = new MeasureSpecification(new LayoutLength(totalWidth), MeasureSpecification.ModeType.Exactly);
if (widthMeasureSpec.Mode != MeasureSpecification.ModeType.Exactly)
{
- totalWidth = Math.Min(Math.Max(naturalSize.Width, minSize.Width), maxSize.Width);
+ float width = naturalSize != null ? naturalSize.Width : 0;
+ totalWidth = Math.Min(Math.Max(width, minSize.Width), maxSize.Width);
}
if (heightMeasureSpec.Mode != MeasureSpecification.ModeType.Exactly)
{
- totalHeight = Math.Min(Math.Max(naturalSize.Height, minSize.Height), maxSize.Height);
+ float height = naturalSize != null ? naturalSize.Height : 0;
+ totalHeight = Math.Min(Math.Max(height, minSize.Height), maxSize.Height);
}
widthMeasureSpec = new MeasureSpecification(new LayoutLength(totalWidth), MeasureSpecification.ModeType.Exactly);
if (heightMeasureSpec.Mode == MeasureSpecification.ModeType.Exactly)
{
// GetWidthForHeight is not implemented.
- totalWidth = Math.Min(Math.Max(naturalSize.Width, minSize.Width), (maxSize.Width < 0 ? Int32.MaxValue : maxSize.Width));
+ float width = naturalSize != null ? naturalSize.Width : 0;
+ totalWidth = Math.Min(Math.Max(width, minSize.Width), (maxSize.Width < 0 ? Int32.MaxValue : maxSize.Width));
widthMeasureSpec = new MeasureSpecification(new LayoutLength(totalWidth), MeasureSpecification.ModeType.Exactly);
}
else
{
- totalWidth = Math.Min(Math.Max(naturalSize.Width, minSize.Width), (maxSize.Width < 0 ? Int32.MaxValue : maxSize.Width));
- totalHeight = Math.Min(Math.Max(naturalSize.Height, minSize.Height), (maxSize.Height < 0 ? Int32.MaxValue : maxSize.Height));
+ float width = naturalSize != null ? naturalSize.Width : 0;
+ float height = naturalSize != null ? naturalSize.Height : 0;
+ totalWidth = Math.Min(Math.Max(width, minSize.Width), (maxSize.Width < 0 ? Int32.MaxValue : maxSize.Width));
+ totalHeight = Math.Min(Math.Max(height, minSize.Height), (maxSize.Height < 0 ? Int32.MaxValue : maxSize.Height));
heightMeasureSpec = new MeasureSpecification(new LayoutLength(totalHeight), MeasureSpecification.ModeType.Exactly);
widthMeasureSpec = new MeasureSpecification(new LayoutLength(totalWidth), MeasureSpecification.ModeType.Exactly);
/// </summary>
/// <param name="vertices">The vertex data that will be copied to the buffer.</param>
/// <exception cref="ArgumentNullException"> Thrown when vertices is null or length of the vertices is 0. </exception>
+ /// <exception cref="OverflowException"> Thrown when length of the vertices is overflow. </exception>
/// <since_tizen> 8 </since_tizen>
public void SetData<VertexType>(VertexType[] vertices) where VertexType : struct
}
int structSize = Marshal.SizeOf<VertexType>();
- global::System.IntPtr buffer = Marshal.AllocHGlobal(structSize * vertices.Length);
+ global::System.IntPtr buffer = Marshal.AllocHGlobal(checked(structSize * vertices.Length));
for (int i = 0; i < vertices.Length; i++)
{
type = xamlStyle.TargetType;
}
else if (parentValuesProvider.TargetObject is Trigger)
- type = (parentValuesProvider.TargetObject as Trigger).TargetType;
+ type = (parentValuesProvider.TargetObject as Trigger)?.TargetType;
else if (parentValuesProvider.TargetObject is XamlPropertyCondition && (parent as TriggerBase) != null)
type = (parent as TriggerBase).TargetType;