Class Cs.FixedStatement

java.lang.Object
org.openrewrite.csharp.tree.Cs.FixedStatement
All Implemented Interfaces:
Cs, org.openrewrite.java.tree.J, org.openrewrite.java.tree.Statement, org.openrewrite.Tree
Enclosing interface:
Cs

public static final class Cs.FixedStatement extends Object implements Cs, org.openrewrite.java.tree.Statement
Represents a C# fixed statement which pins a moveable variable at a memory location. The fixed statement prevents the garbage collector from relocating a movable variable and declares a pointer to that variable.

For example:

     // Fixed statement with array
     fixed (int* p = array) {
         // use p
     }

     // Fixed statement with string
     fixed (char* p = str) {
         // use p
     }

     // Multiple pointers in one fixed statement
     fixed (byte* p1 = &b1, p2 = &b2) {
         // use p1 and p2
     }

     // Fixed statement with custom type
     fixed (CustomStruct* ptr = &struct) {
         // use ptr
     }
 
  • Constructor Details

    • FixedStatement

      public FixedStatement()
  • Method Details

    • acceptCSharp

      public <P> org.openrewrite.java.tree.J acceptCSharp(CSharpVisitor<P> v, P p)
      Specified by:
      acceptCSharp in interface Cs
    • getCoordinates

      public org.openrewrite.java.tree.CoordinateBuilder.Statement getCoordinates()
      Specified by:
      getCoordinates in interface org.openrewrite.java.tree.Statement