https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1001
CA1001: Types that own disposable fields should be disposable
Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
/// </remark>
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- internal class SlidingSwitchExtension : SwitchExtension
+ internal class SlidingSwitchExtension : SwitchExtension, IDisposable
{
+ private bool disposed = false;
private Animation slidingAnimation;
public SlidingSwitchExtension() : base()
slidingAnimation = null;
}
}
+
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposed)
+ {
+ return;
+ }
+
+ if (disposing)
+ {
+ slidingAnimation?.Dispose();
+ }
+ disposed = true;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Dispose()
+ {
+ Dispose(true);
+ global::System.GC.SuppressFinalize(this);
+ }
}
}
/// <summary>
/// Dispose ButtonStyle and all children on it.
/// </summary>
- /// <param name="type">Dispose type.</param>
+ /// <param name="disposing">true in order to free managed objects</param>
[EditorBrowsable(EditorBrowsableState.Never)]
- protected override void Dispose(DisposeTypes type)
+ protected override void Dispose(bool disposing)
{
- if (Disposed)
- {
- return;
- }
-
- if (type == DisposeTypes.Explicit)
+ if (disposing)
{
iconPadding?.Dispose();
textPadding?.Dispose();
}
- base.Dispose(type);
+ base.Dispose(disposing);
}
}
}
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public class ControlStyle : ViewStyle, global::System.IDisposable
+ public class ControlStyle : ViewStyle
{
- private bool isDisposeQueued = false;
-
static ControlStyle()
{
ThemeManager.AddPackageTheme(new DefaultThemeCreator());
{
}
- /// <summary>
- /// Dispose.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- ~ControlStyle()
- {
- if (!isDisposeQueued)
- {
- isDisposeQueued = true;
- DisposeQueue.Instance.Add(this);
- }
- }
-
- /// <summary>
- /// A Flag to check if it is already disposed.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected bool Disposed { get; set; }
-
- /// <summary>
- /// Dispose.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void Dispose()
- {
- //Throw excpetion if Dispose() is called in separate thread.
- if (!Window.IsInstalled())
- {
- throw new global::System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
- }
-
- if (isDisposeQueued)
- {
- Dispose(DisposeTypes.Implicit);
- }
- else
- {
- Dispose(DisposeTypes.Explicit);
- global::System.GC.SuppressFinalize(this);
- }
- }
-
- /// <summary>
- /// Dispose.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected virtual void Dispose(DisposeTypes type)
- {
- if (Disposed)
- {
- return;
- }
-
- if (type == DisposeTypes.Explicit)
- {
- //Called by User
- //Release your own managed resources here.
- //You should release all of your own disposable objects here.
- }
-
- Disposed = true;
- }
-
private void SubStyleCalledEvent(object sender, global::System.EventArgs e)
{
OnPropertyChanged();
/// <summary>
/// Dispose SliderStyle and all children on it.
/// </summary>
- /// <param name="type">Dispose type.</param>
+ /// <param name="disposing">true in order to free managed objects</param>
[EditorBrowsable(EditorBrowsableState.Never)]
- protected override void Dispose(DisposeTypes type)
+ protected override void Dispose(bool disposing)
{
- if (Disposed)
- {
- return;
- }
-
- if (type == DisposeTypes.Explicit)
+ if (disposing)
{
trackPadding?.Dispose();
}
- base.Dispose(type);
+ base.Dispose(disposing);
}
}
}
/// <summary>
/// Dispose CircularProgressStyle and all children on it.
/// </summary>
- /// <param name="type">Dispose type.</param>
+ /// <param name="disposing">true in order to free managed objects</param>
[EditorBrowsable(EditorBrowsableState.Never)]
- protected override void Dispose(DisposeTypes type)
+ protected override void Dispose(bool disposing)
{
- if (Disposed)
- {
- return;
- }
-
- if (type == DisposeTypes.Explicit)
+ if (disposing)
{
trackColor?.Dispose();
progressColor?.Dispose();
}
- base.Dispose(type);
+ base.Dispose(disposing);
}
private void Initialize()
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
namespace Tizen.NUI
{
+ [SuppressMessage("Microsoft.Design", "CA1001:Types that own disposable fields should be disposable", Justification = "This is a singleton class and is not disposed")]
internal class DisposeQueue
{
private static readonly DisposeQueue _disposableQueue = new DisposeQueue();
/// </summary>
// This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
[SuppressMessage("Microsoft.Design", "CA1724: Type names should not match namespaces")]
+ [SuppressMessage("Microsoft.Design", "CA1001:Types that own disposable fields should be disposable", Justification = "This is a singleton class and is not disposed")]
[EditorBrowsable(EditorBrowsableState.Never)]
public class Accessibility
{
/// </summary>
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public partial class ViewStyle : BindableObject
+ public partial class ViewStyle : BindableObject, IDisposable
{
+ private bool disposed = false;
private string styleName;
private View.States? state;
private View.States? subState;
{
Margin = new Extents(start, end, top, bottom);
}
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposed)
+ {
+ return;
+ }
+
+ if (disposing)
+ {
+ // Dispose managed state (managed objects).
+ cellIndex?.Dispose();
+ downFocusableView?.Dispose();
+ flexMargin?.Dispose();
+ leftFocusableView?.Dispose();
+ margin?.Dispose();
+ maximumSize?.Dispose();
+ minimumSize?.Dispose();
+ orientation?.Dispose();
+ padding?.Dispose();
+ parentOrigin?.Dispose();
+ pivotPoint?.Dispose();
+ position?.Dispose();
+ rightFocusableView?.Dispose();
+ scale?.Dispose();
+ size?.Dispose();
+ sizeModeFactor?.Dispose();
+ upFocusableView?.Dispose();
+ }
+
+ disposed = true;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Dispose()
+ {
+ Dispose(true);
+ global::System.GC.SuppressFinalize(this);
+ }
}
}
*/
using System;
+using System.ComponentModel;
using Tizen.NUI.Binding;
namespace Tizen.NUI
/// <summary>
/// KeyValue class.
/// </summary>
- public class KeyValue
+ public class KeyValue : IDisposable
{
+ private bool disposed = false;
/// <summary>
/// Int key.
/// </summary>
KeyString = Key;
}
}
+
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposed)
+ {
+ return;
+ }
+
+ if (disposing)
+ {
+ TrueValue?.Dispose();
+ }
+ disposed = true;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Dispose()
+ {
+ Dispose(true);
+ global::System.GC.SuppressFinalize(this);
+ }
}
}
/// For more information about the flex layout API and how to use it please refer to https://yogalayout.com/docs/
/// We implement the subset of the API in the class below.
/// </summary>
- public class FlexLayout : LayoutGroup, global::System.IDisposable
+ public class FlexLayout : LayoutGroup
{
/// <summary>
/// FlexItemProperty
/// <inheritdoc/>
/// <since_tizen> 6 </since_tizen>
- public void Dispose()
+ public new void Dispose()
{
Dispose(true);
System.GC.SuppressFinalize(this);
/// <param name="disposing">true in order to free managed objects</param>
// Protected implementation of Dispose pattern.
[EditorBrowsable(EditorBrowsableState.Never)]
- protected virtual void Dispose(bool disposing)
+ protected override void Dispose(bool disposing)
{
if (disposedThis)
{
// TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
// TODO: set large fields to null.
-
disposedThis = true;
+ base.Dispose(disposing);
}
/// <inheritdoc/>
/// [Draft] Base class for layouts. It is used to layout a View
/// It can be laid out by a LayoutGroup.
/// </summary>
- public class LayoutItem
+ public class LayoutItem : IDisposable
{
+ private bool disposed = false;
static bool LayoutDebugFrameData = false; // Debug flag
private MeasureSpecification OldWidthMeasureSpec; // Store measure specification to compare against later
private MeasureSpecification OldHeightMeasureSpec; // Store measure specification to compare against later
return changed;
}
+
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void Dispose(bool disposing)
+ {
+ if(disposed)
+ {
+ return;
+ }
+
+ if (disposing)
+ {
+ _margin?.Dispose();
+ _padding?.Dispose();
+ }
+ disposed = true;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Dispose()
+ {
+ Dispose(true);
+ global::System.GC.SuppressFinalize(this);
+ }
}
}
using System.Collections.Generic;
using System;
+using System.ComponentModel;
namespace Tizen.NUI
{
/// Parts of the transition that can be configured to provide a custom effect.
/// </summary>
/// <since_tizen> 6 </since_tizen>
- public class TransitionComponents
+ public class TransitionComponents : IDisposable
{
+ private bool disposed = false;
/// <summary>
/// TransitionComponents default constructor.
/// </summary>
/// </summary>
/// <since_tizen> 6 </since_tizen>
public AlphaFunction AlphaFunction;
+
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposed)
+ {
+ return;
+ }
+ if (disposing)
+ {
+ AlphaFunction?.Dispose();
+ }
+ disposed = true;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Dispose()
+ {
+ Dispose(true);
+ global::System.GC.SuppressFinalize(this);
+ }
}
/// <summary>
/// Transition animation effect
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public class TransitionAnimation
+ public class TransitionAnimation : IDisposable
{
+ private bool disposed = false;
private ImageViewStyle defaultImageStyle;
private List<TransitionAnimationData> animationDataList;
defaultImageStyle = value;
}
}
+
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposed)
+ {
+ return;
+ }
+ if (disposing)
+ {
+ defaultImageStyle?.Dispose();
+ }
+ disposed = true;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Dispose()
+ {
+ Dispose(true);
+ global::System.GC.SuppressFinalize(this);
+ }
}
/// <summary>
* limitations under the License.
*
*/
+using System;
+using System.ComponentModel;
namespace Tizen.NUI
{
/// <summary>
/// The class storing Background extra properties such as CornerRadius, ImageBorder.
/// </summary>
- internal class BackgroundExtraData
+ internal class BackgroundExtraData : IDisposable
{
+ private bool disposed = false;
internal BackgroundExtraData()
{
}
{
return CornerRadius == 0 && Rectangle.IsNullOrZero(BackgroundImageBorder);
}
+
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposed)
+ {
+ return;
+ }
+ if (disposing)
+ {
+ backgroundImageBorder?.Dispose();
+ }
+ disposed = true;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Dispose()
+ {
+ Dispose(true);
+ global::System.GC.SuppressFinalize(this);
+ }
}
}
/// The Text Shadow for TextLabel.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public class TextShadow : ICloneable
+ public class TextShadow : ICloneable, IDisposable
{
+ private bool disposed = false;
private readonly PropertyMap propertyMap = null;
internal delegate void PropertyChangedCallback(TextShadow instance);
return new PropertyValue(instance.propertyMap);
}
+
+
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposed)
+ {
+ return;
+ }
+ if (disposing)
+ {
+ propertyMap?.Dispose();
+ Color?.Dispose();
+ Offset?.Dispose();
+ }
+ disposed = true;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Dispose()
+ {
+ Dispose(true);
+ global::System.GC.SuppressFinalize(this);
+ }
}
}
* limitations under the License.
*
*/
+using System;
using System.ComponentModel;
using Tizen.NUI.BaseComponents;
/// A class encapsulating the transform map of the visual.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- public class VisualMap
+ public class VisualMap : IDisposable
{
+ private bool disposed = false;
/// <summary>
/// outputVisualMap.
/// </summary>
if (_visualOrigin != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.Origin, new PropertyValue((int)_visualOrigin)); }
if (_visualAnchorPoint != null) { _visualTransformMap.Add((int)VisualTransformPropertyType.AnchorPoint, new PropertyValue((int)_visualAnchorPoint)); }
}
+
+
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposed)
+ {
+ return;
+ }
+ if (disposing)
+ {
+ _commonlyUsedMap?.Dispose();
+ _mixColor?.Dispose();
+ _outputVisualMap?.Dispose();
+ _shader?.Dispose();
+ _visualOffset?.Dispose();
+ _visualOffsetPolicy?.Dispose();
+ _visualSize?.Dispose();
+ _visualSizePolicy?.Dispose();
+ _visualTransformMap?.Dispose();
+ }
+ disposed = true;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Dispose()
+ {
+ Dispose(true);
+ global::System.GC.SuppressFinalize(this);
+ }
}
}