Framework WindowsForms

for DotNet environment

The way Julia handles this framework should reduce FieldAccess and CloseResource warnings related to graphical components of forms, together with Deadcode warnings on event handlers.

Required libraries: System.Windows.Forms.dll

Applicability

This specification gets automatically applied when:

  • the framework of the analysis contains the word dotnet (case insensitive)
  • a class whose name starts with System.Windows.Forms.Control is supertype of at least one application's class
  • a class whose name is equals to System.Windows.Forms.Form is supertype of at least one application's class


Implications between annotations

Some annotations of this framework get translated automatically into standard Julia annotations, such that the analysis engine can react accordingly. Namely:

  • if an element is annotated with Microsoft.Build.Framework.RunInMTAAttribute, Julia considers it to be annotated also with:
    • com.juliasoft.julia.extraction.EntryPoint
  • if an element is annotated with Microsoft.Build.Framework.RunInSTAAttribute, Julia considers it to be annotated also with:
    • com.juliasoft.julia.extraction.EntryPoint
  • if an element is annotated with System.MTAThreadAttribute, Julia considers it to be annotated also with:
    • com.juliasoft.julia.extraction.EntryPoint
  • if an element is annotated with System.STAThreadAttribute, Julia considers it to be annotated also with:
    • com.juliasoft.julia.extraction.EntryPoint


Predicates

Predicates are named conditions that can be used inside other conditions. This framework defines the following predicates:

  • predicate isControlClass is defined as follows:
      that is subtype of a class whose name is equal to System.ComponentModel.IComponent
  • predicate isControlFieldInsideControlClass is defined as follows:
      (has a type that is subtype of a class whose name is equal to System.ComponentModel.IComponent and is defined in a class satisfies predicate isControlClass)
  • predicate isDisposable is defined as follows:
      that is subtype of a class whose name is equal to System.IDisposable
  • predicate isDisposableFieldInsideControlClass is defined as follows:
      (has a type satisfies predicate isDisposable and is defined in a class satisfies predicate isControlClass)
  • predicate isGeneratedFormDisposeMethod is defined as follows:
      (that is defined in a class that is subtype of a class whose name is equal to System.Windows.Forms.ContainerControl and (has an accessor that is equal to protected and (whose name is equal to Dispose and (whose return type is equal to void and (that has a number of parameters is equal to 1 and that has a parameter (whose name is equal to disposing and whose type is equal to boolean))))))
  • predicate isGeneratedFormField is defined as follows:
      (is defined in a class that is subtype of a class whose name is equal to System.Windows.Forms.ContainerControl and (has an accessor that is equal to private and (whose name is equal to components and has a type that is subtype of a class whose name is equal to System.ComponentModel.IContainer)))
  • predicate isResourceGetterInsideControl is defined as follows:
      (that is defined in a class that is subtype of a class whose name is equal to System.Windows.Forms.Control and (that has a return type satisfies predicate isDisposable and whose name starts with get_))


Specifications on application code

These are conditions that, if satisfied on a given program component, will cause the specified annotations to be placed on such component. These will annotate only program components coming from the application under analysis, and not the libraries. This framework defines the following specifications:

  • annotate any method that satisfies the following:
      satisfies predicate isResourceGetterInsideControl
    with:
    • com.juliasoft.julia.checkers.closeWhereCreated.ResourceThatDoesNotNeedToBeClosed
  • annotate any method that satisfies the following:
      satisfies predicate isGeneratedFormDisposeMethod
    with:
    • com.juliasoft.julia.extraction.EntryPoint
  • annotate any field that satisfies the following:
      (satisfies predicate isDisposableFieldInsideControlClass or has a type that is subtype of a class whose name is equal to System.Windows.Forms.ContainerControl)
    with:
    • com.juliasoft.julia.checkers.closeWhereCreated.AutoClosedResource
  • annotate any field that satisfies the following:
      satisfies predicate isControlFieldInsideControlClass
    with:
    • com.juliasoft.julia.extraction.ExternallyRead
    • com.juliasoft.julia.extraction.Injected
  • annotate any field that satisfies the following:
      satisfies predicate isGeneratedFormField
    with:
    • com.juliasoft.julia.checkers.nullness.NonNull
    • com.juliasoft.julia.extraction.ExternallyRead
    • com.juliasoft.julia.extraction.Injected


Specifications on library code

These express the signature of program components that will be annotated with the specified annotations. These will annotate program components coming both from the application under analysis and the libraries. This framework defines the following library specifications:

  • annotate class System.Windows.Forms.Control with:
    • com.juliasoft.julia.checkers.closeWhereCreated.ResourceThatDoesNotNeedToBeClosed
  • annotate class System.Windows.Forms.Menu with:
    • com.juliasoft.julia.checkers.closeWhereCreated.ResourceThatDoesNotNeedToBeClosed
  • annotate class System.Windows.Forms.ToolStripItem with:
    • com.juliasoft.julia.checkers.closeWhereCreated.ResourceThatDoesNotNeedToBeClosed
  • annotate class System.Windows.Forms.ToolTip with:
    • com.juliasoft.julia.checkers.closeWhereCreated.ResourceThatDoesNotNeedToBeClosed
  • in class System.Diagnostics.Process, annotate methods whose name is GetCurrentProcess()LSystem/Diagnostics/Process; with:
    • com.juliasoft.julia.checkers.closeWhereCreated.ResourceThatDoesNotNeedToBeClosed
  • in class System.Drawing.Brushes, annotate methods whose name matches get_.*\(\)LSystem/Drawing/Brush; with:
    • com.juliasoft.julia.checkers.closeWhereCreated.ResourceThatDoesNotNeedToBeClosed
  • in class System.Drawing.Pens, annotate methods whose name matches get_.*\(\)LSystem/Drawing/Pen; with:
    • com.juliasoft.julia.checkers.closeWhereCreated.ResourceThatDoesNotNeedToBeClosed
  • in class System.Windows.Forms.Cursors, annotate methods whose name matches get_.*\(\)LSystem/Windows/Forms/Cursor; with:
    • com.juliasoft.julia.checkers.closeWhereCreated.ResourceThatDoesNotNeedToBeClosed
  • in class System.Environment, annotate methods whose name is Exit(I)V with:
    • com.juliasoft.julia.checkers.termination.Terminates
    • com.juliasoft.julia.methods.StopsExecution