diff --git a/.github/workflows/ValidatePullRequest.yml b/.github/workflows/ValidatePullRequest.yml
index 278deda58..5e86dc811 100644
--- a/.github/workflows/ValidatePullRequest.yml
+++ b/.github/workflows/ValidatePullRequest.yml
@@ -15,6 +15,14 @@ jobs:
--logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true"
--
RunConfiguration.CollectSourceInformation=true
+ no_warnings:
+ runs-on: ubuntu-latest
+ name: No Warnings
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-dotnet@v3
+ - run: >
+ dotnet build CSharpier.slnx -c release -p:TreatWarningsAsErrors=true
builds_playground:
runs-on: ubuntu-latest
name: Builds Playground
diff --git a/.run/Debug msbuild.run.xml b/.run/Debug CLI.run.xml
similarity index 84%
rename from .run/Debug msbuild.run.xml
rename to .run/Debug CLI.run.xml
index b63cd2d2a..794c565a8 100644
--- a/.run/Debug msbuild.run.xml
+++ b/.run/Debug CLI.run.xml
@@ -1,17 +1,12 @@
-
+
@@ -19,10 +14,10 @@
+
-
diff --git a/.run/Playground.run.xml b/.run/Playground.run.xml
index 62c87a7f2..e6a7e03eb 100644
--- a/.run/Playground.run.xml
+++ b/.run/Playground.run.xml
@@ -9,7 +9,7 @@
name="LAUNCH_PROFILE_PROJECT_FILE_PATH"
value="$PROJECT_DIR$/Src/CSharpier.Playground/CSharpier.Playground.csproj"
/>
-
+
@@ -18,6 +18,7 @@
+
diff --git a/Directory.Build.props b/Directory.Build.props
index f9ad552f0..70bfa8023 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -6,7 +6,6 @@
enableCS8032;CS8033;
- truetruetrueRecommended
diff --git a/Shell/BuildProject.psm1 b/Shell/BuildProject.psm1
index 5a6410925..7e94f43be 100644
--- a/Shell/BuildProject.psm1
+++ b/Shell/BuildProject.psm1
@@ -1,10 +1,14 @@
-function CSH-BuildProject
-{
+function CSH-BuildProject {
+ param (
+ [switch]$doNotExit = $false
+ )
+
+
$repositoryRoot = Join-Path $PSScriptRoot ".."
$csProjectPath = Join-Path $repositoryRoot "Src/CSharpier.Cli/CSharpier.Cli.csproj"
& dotnet build $csProjectPath -c release
- if ($lastExitCode -gt 0) {
+ if ($lastExitCode -gt 0 -and -not $doNotExit) {
exit $lastExitCode;
}
}
diff --git a/Shell/ReviewBranch.psm1 b/Shell/ReviewBranch.psm1
index 534291e43..106da88ca 100644
--- a/Shell/ReviewBranch.psm1
+++ b/Shell/ReviewBranch.psm1
@@ -2,7 +2,8 @@ function CSH-ReviewBranch {
param (
[string]$folder,
[string]$pathToTestingRepo,
- [switch]$skipValidation = $true
+ [switch]$skipValidation = $true,
+ [switch]$onlyXml = $false
)
$repositoryRoot = Join-Path $PSScriptRoot ".."
@@ -60,15 +61,14 @@ function CSH-ReviewBranch {
if ($firstRun) {
Set-Location $repositoryRoot
-# try {
- & git checkout main #2>&1 | Out-String
-# }
-# catch {
-# Write-Host "Could not checkout main on csharpier, working directory is probably not clean"
-# return
-# }
-
- CSH-BuildProject
+
+ & git checkout main #2>&1 | Out-String
+
+ CSH-BuildProject -doNotExit
+
+ if ($lastExitCode -gt 0) {
+ return
+ }
Set-Location $pathToTestingRepo
@@ -76,6 +76,10 @@ function CSH-ReviewBranch {
& git reset --hard
& git checkout -b $preBranch
+ if ($onlyXml) {
+ Add-Content -Path "$pathToTestingRepo/.csharpierignore" -Value "**/*.cs"
+ }
+
dotnet $csharpierDllPath format . $skipValidationParam --no-cache
# there is some weirdness with a couple files with #if where
# they need to be formatted twice to get them stable
diff --git a/Src/CSharpier.Benchmarks/CodeSamples/Type.xml b/Src/CSharpier.Benchmarks/CodeSamples/Type.xml
new file mode 100644
index 000000000..042382ab1
--- /dev/null
+++ b/Src/CSharpier.Benchmarks/CodeSamples/Type.xml
@@ -0,0 +1,15105 @@
+
+
+
+
+
+ BCL
+
+ mscorlib
+ [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ]
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+ This type is safe for multithreaded operations.
+
+ System.Reflection.MemberInfo
+ System.Reflection.MemberInfo
+ Reflection
+
+
+
+ System.Reflection.IReflect
+
+
+ System.Runtime.InteropServices._Type
+
+
+
+
+ System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)
+
+
+ System.Runtime.InteropServices.ComDefaultInterface(typeof(System.Runtime.InteropServices._Type))
+
+
+ System.Runtime.InteropServices.ComVisible(true)
+
+
+
+
+
+ Type is the root of thefunctionality and is the primary way to access metadata. Use the members of Type to get information about a type declaration, such as the constructors, methods, fields, properties, and events of a class, as well as the module and the assembly in which the class is deployed.
+ The C# typeof operator (GetType operator in Visual Basic, typeid operator in Visual C++) returns a Type object.
+ A Type object that represents a type is unique; that is, two Type object references refer to the same object if and only if they represent the same type. This allows for comparison of Type objects using reference equality.
+ No permissions are required for code to use reflection to get information about types and their members, regardless of their access levels. No permissions are required for code to use reflection to access public members, or other members whose access levels would make them visible during normal compilation. However, in order for your code to use reflection to access members that would normally be inaccessible, such as private or internal methods, or protected fields of a type your class does not inherit, your code must have. See
+ Security Considerations for Reflection
+ .
+ Type is an abstract base class that allows multiple implementations. The system will always provide the derived class RuntimeType. In reflection, all classes beginning with the word Runtime are created only once per object in the system and support comparison operations.
+
+ In multithreading scenarios, do not lockobjects in order to synchronize access to static data. Other code, over which you have no control, might also lock your class type. This might result in a deadlock. Instead, synchronize access to static data by locking a private static object.
+
+ This class is thread safe; multiple threads can concurrently read from an instance of this type. An instance of Type can represent any of the following types:
+
+
+ Classes
+
+
+ Value types
+
+
+ Arrays
+
+
+ Interfaces
+
+
+ Pointers
+
+
+ Enumerations
+
+
+ Constructed generic types and generic type definitions
+
+
+ Type arguments and type parameters of constructed generic types, generic type definitions, and generic method definitions
+
+
+ A reference to the Type object associated with a type can be obtained in the following ways:
+
+
+ Themethod returns a Type object that represents the type of an instance.
+
+
+ The static GetType methods return a Type object that represents a type specified by its fully qualified name.
+
+
+ The,, andmethods return Type objects that represent the types defined in a module. The first method can be used to obtain an array of Type objects for all the public and private types defined in a module. (You can obtain an instance of Module through theormethod, or through theproperty.)
+
+
+ Theobject contains a number of methods to retrieve the classes defined in an assembly, including,, and.
+
+
+ Themethod returns a filtered list of interface types supported by a type.
+
+
+ Themethod returns a Type object that represents the element.
+
+
+ Theandmethods return Type objects representing the interface types supported by a type.
+
+
+ Themethod returns an array of Type objects representing the types specified by an arbitrary set of objects. The objects are specified with an array of type Object.
+
+
+ Theandmethods are provided for COM interoperability. They return a Type object that represents the type specified by a ProgID or CLSID.
+
+
+ Themethod is provided for interoperability. It returns a Type object that represents the type specified by a class handle.
+
+
+ The C# typeof operator, the C++ typeid operator, and the Visual Basic GetType operator obtain the Type object for a type.
+
+
+ Themethod returns aobject representing a constructed generic type, which is an open constructed type if itsproperty returns true, and a closed constructed type otherwise. A generic type can be instantiated only if it is closed.
+
+
+ The,, andmethods returnobjects that represent, respectively, an array of a specified type, a pointer to a specified type, and the type of a reference parameter (ref in C#, ByRef in Visual Basic).
+
+
+
+ A derived class can access protected members of the calling code's base classes. Also, access is allowed to assembly members of the calling code's assembly. As a rule, if you are allowed access in early-bound code, then you are also allowed access in late-bound code.
+
+
+ Interfaces that extend other interfaces do not inherit the methods defined in the extended interfaces.
+
+
+
+
+ Represents type declarations: class types, interface types, array types, value types, enumeration types, type parameters, generic type definitions, and open or closed constructed generic types.
+
+
+
+
+
+
+
+ Constructor
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+
+
+
+
+ This constructor is invoked by derived classes during the construction of type objects.
+
+
+
+ Initializes a new instance of theclass.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.Assembly
+
+
+
+
+ Ainstance that describes the assembly containing the current type. For generic types, the instance describes the assembly that contains the definition of the generic type.
+
+
+
+ If the currentobject represents a constructed generic type, this property returns the assembly that contains the generic type definition. For example, suppose you create an assembly named MyGenerics.dll that contains the generic type definition MyGenericStack<T> (MyGenericStack(Of T) in Visual Basic, generic<T> ref class MyGenericStack in C++). If you create an instance of MyGenericStack<int> (MyGenericStack(Of Integer) in Visual Basic) in another assembly, theproperty for the constructed type returns anobject that represents MyGenerics.dll.
+ Similarly, if the currentobject represents an unassigned generic parameter, this property returns the assembly that contains the generic type that defines.
+ This property is read-only.
+
+
+
+ Gets thein which the type is declared. For generic types, gets thein which the generic type is defined.
+
+
+ 1
+ RuntimeInfrastructure
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.String
+
+
+
+
+ The assembly-qualified name of the, including the name of the assembly from which thewas loaded. If the currentobject represents a generic parameter, this property returns.
+
+
+
+ The assembly-qualified name of a type consists of the type name, including its namespace, followed by a comma, followed by the display name of the assembly. The display name of an assembly is obtained using theproperty.
+
+ In the .NET Framework version 2.0, processor architecture is added to assembly identity, and can be specified as part of assembly name strings. For example, "ProcessorArchitecture=msil". However, it is not included in the string returned by theproperty, for compatibility reasons. See.
+
+ All compilers that support the common language runtime emit the simple name of a nested class, and reflection constructs a mangled name when queried, in accordance with the following conventions.
+
+
+
+
+ Delimiter
+
+
+ Meaning
+
+
+
+
+
+ Backslash (\)
+
+
+ Escape character.
+
+
+
+
+ Comma (,)
+
+
+ Precedes the Assembly name.
+
+
+
+
+ Plus sign (+)
+
+
+ Precedes a nested class.
+
+
+
+
+ Period (.)
+
+
+ Denotes namespace identifiers.
+
+
+
+
+ Brackets ([])
+
+
+ After a type name, denotes an array of that type.
+ -or-
+ For a generic type, encloses the generic type argument list.
+ -or-
+ Within a type argument list, encloses an assembly-qualified type.
+
+
+
+ For example, the assembly-qualified name for a class might look like this:
+ TopNamespace.SubNameSpace.ContainingClass+NestedClass, MyAssembly, Version=1.3.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089
+ If the namespace contained a plus sign, for example TopNamespace.Sub+Namespace, then the plus sign (+) would be preceded by an escape character (\) to prevent it from being interpreted as a nesting separator. Reflection would emit this string as follows:
+ TopNamespace.Sub\+Namespace.ContainingClass+NestedClass, MyAssembly, Version=1.3.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089
+ A "++" becomes "\+\+", and a "\" becomes "\\".
+ This qualified name can be persisted and later used to load the. To search for and load a, useeither with the type name only or with the assembly qualified type name.with the type name only will look for thein the caller's assembly and then in the System assembly.with the assembly qualified type name will look for thein any assembly.
+ Type names may include trailing characters that denote additional information about the type, such as whether the type is a reference type, a pointer type or an array type. To retrieve the type name without these trailing characters, use t.GetElementType().ToString(), whereis the type.
+ Spaces are relevant in all type name components except the assembly name. In the assembly name, spaces before the ',' separator are relevant, but spaces after the ',' separator are ignored.
+ Generic arguments of generic types are themselves qualified by assembly name. For example, in the assembly-qualified type name for MyGenericClass<int> (MyGenericClass(Of Integer) in Visual Basic), int is expanded to the assembly-qualified type name for.
+ If the currentobject represents a generic parameter, this property returns null.
+
+
+
+ Gets the assembly-qualified name of the, which includes the name of the assembly from which thewas loaded.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.TypeAttributes
+
+
+
+
+ Aobject representing the attribute set of the.
+
+
+
+ If the currentrepresents a constructed generic type, this property returns the attributes of the generic type definition. For example, the attributes returned for MyGenericClass<int> (MyGenericClass(Of Integer) in Visual Basic) are the attributes of MyGenericClass<T> (MyGenericClass(Of T) in Visual Basic).
+ If the currentrepresents a generic type parameter — that is, if theproperty returns true — thevalue returned by this property is unspecified.
+
+
+
+ Gets the attributes associated with the.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+ Aobject
+ representing the type from which the currentdirectly inherits, orif the currentrepresents theclass.
+
+
+ The following example demonstrates using theproperty.
+ using System;
+class TestType {
+ public static void Main() {
+ Type t = typeof(int);
+ Console.WriteLine("{0} inherits from {1}", t,t.BaseType);
+ }
+}
+ The output is
+
+ System.Int32
+ inherits from System.ValueType
+
+
+
+
+ The base type is the type from which the current type directly inherits.is the only type that does not have a base type, therefore null is returned as the base type of.
+ Interfaces inherit from zero or more base interfaces; therefore, this property returns null if the Type object represents an interface. The base interfaces can be determined withor.
+ If the currentrepresents a constructed generic type, the base type reflects the generic arguments. For example, consider the following declarations:
+ code reference: System.Type.BaseType#1
+ For the constructed type C<int> (C(Of Integer) in Visual Basic), theproperty returns B<int>.
+ If the currentrepresents a type parameter of a generic type definition,returns the class constraint, that is, the class the type parameter must inherit. If there is no class constraint,returns.
+ This property is read-only.
+
+
+
+ Gets the type from which the currentdirectly inherits.
+
+
+ 0
+
+
+
+
+ Property
+
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+ if aobject contains unassigned generic parameters; otherwise.
+
+
+
+ For an example of using this method, see the example for.
+
+
+
+ In order to create an instance of a type, there must be no generic type definitions or open constructed types in the type arguments of the type itself, in any enclosing generic types, or in any elements of the type. Another way of saying this is that when examined recursively, the type must contain no generic type parameters.
+ Since types can be arbitrarily complex, making this determination is difficult. For convenience and to reduce the chance of error, theproperty provides a standard way to distinguish between closed constructed types, which can be instantiated, and open constructed types, which cannot. If theproperty returns true, the type cannot be instantiated.
+ Theproperty searches recursively for type parameters. For example, it returns true for an array whose elements are type A<T> (A(Of T) in Visual Basic), even though the array is not itself generic. Contrast this with the behavior of theproperty, which returns false for arrays.
+ For a set of example classes and a table showing the values of theproperty, see.
+
+
+
+ Gets a value indicating whether the currentobject has type parameters that have not been replaced by specific types.
+
+
+
+
+
+
+ Property
+
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MethodBase
+
+
+
+ If the currentrepresents a type parameter of a generic method, athat represents the declaring method; otherwise.
+
+
+
+
+ The declaring method is a generic method definition. That is, ifdoes not return null, then DeclaringMethod.IsGenericMethodDefinition returns true.
+ Theandproperties identify the generic type definition or generic method definition in which the generic type parameter was originally defined:
+
+
+ If theproperty returns a, thatrepresents a generic method definition, and the currentobject represents a type parameter of that generic method definition.
+
+
+ If theproperty returns null, then theproperty always returns aobject representing a generic type definition, and the currentobject represents a type parameter of that generic type definition.
+
+
+ Getting theproperty on a type whoseproperty is false throws an.
+
+
+ Thethat is returned by theproperty is either ain the case of a generic method, or ain the case of a generic constructor.
+
+ In the .NET Framework version 2.0, generic constructors are not supported.
+
+ For a list of the invariant conditions for terms used in generic reflection, see theproperty remarks.
+
+
+
+ Gets athat represents the declaring method, if the currentrepresents a type parameter of a generic method.
+
+
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+ Theobject for
+ the class that declares the type represented by the current
+ instance. If the type is a nested type, this property returns the enclosing type; otherwise, returns
+ the current instance.
+
+
+ The following example demonstrates theproperty.
+ using System;
+using System.Reflection;
+
+public abstract class DeclaringTypeTest{
+ public abstract class MyClassA {
+ public abstract int m();
+ }
+ public abstract class MyClassB : MyClassA {
+ }
+ public static void Main() {
+ Console.WriteLine("Declaring type of m is {0}",
+ typeof(MyClassB).GetMethod("m").DeclaringType);
+ }
+}
+ The output is
+
+ Declaring type of m is DeclaringTypeTest+MyClassA
+
+
+
+
+ If the currentobject represents a type parameter of a generic type, this property returns the generic type definition.
+ If the currentobject represents a type parameter of a generic method, this property returns the type that contains the generic method definition. If the type is generic, the generic type definition is returned. That is, the following code returns the generic type definition of thegeneric class, which contains thegeneric method:
+ code reference: System.Type.DeclaringType#1
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, theandproperties identify the generic type definition or generic method definition where the generic type parameter was originally defined:
+
+
+ If theproperty returns a, thatrepresents a generic method definition, and the currentobject represents a type parameter of that generic method definition.
+
+
+ If theproperty returns null, then theproperty always returns aobject representing a generic type definition, and the currentobject represents a type parameter of that generic type definition.
+
+
+ Getting theproperty on a type whoseproperty is false throws an.
+
+
+
+
+
+ Gets the type that declares the current nested type or generic type parameter.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.Binder
+
+
+
+
+ The defaultused by the system.
+
+
+
+ The default binder provided with the common language runtime is applicable in all but the most specialized circumstances. If you need a binder that follows rules that differ from those of the supplied default binder, define a type derived from theclass and pass an instance of that type using theparameter of one of theoverloads.
+ Reflection models the accessibility rules of the common type system. For example, if the caller is in the same assembly, the caller does not need special permissions for internal members. Otherwise, the caller needs. This is consistent with lookup of members that are protected, private, and so on.
+ The general principle is thatshould perform only widening conversions, which never lose data. An example of a widening conversion is converting a value that is a 32-bit signed integer to a value that is a 64-bit signed integer. This is distinguished from a narrowing conversion, which may lose data. An example of a narrowing conversion is converting a 64-bit signed integer to a 32-bit signed integer.
+ The following table lists the conversions supported by the default binder.
+
+
+
+
+ Source Type
+
+
+ Target Type
+
+
+
+
+
+ Any type
+
+
+ Its base type.
+
+
+
+
+ Any type
+
+
+ The interface it implements.
+
+
+
+
+ Char
+
+
+ Unt16, UInt32, Int32, UInt64, Int64, Single, Double
+
+
+
+
+ Byte
+
+
+ Char, Unt16, Int16, UInt32, Int32, UInt64, Int64, Single, Double
+
+
+
+
+ SByte
+
+
+ Int16, Int32, Int64, Single, Double
+
+
+
+
+ UInt16
+
+
+ UInt32, Int32, UInt64, Int64, Single, Double
+
+
+
+
+ Int16
+
+
+ Int32, Int64, Single, Double
+
+
+
+
+ UInt32
+
+
+ UInt64, Int64, Single, Double
+
+
+
+
+ Int32
+
+
+ Int64, Single, Double
+
+
+
+
+ UInt64
+
+
+ Single, Double
+
+
+
+
+ Int64
+
+
+ Single, Double
+
+
+
+
+ Single
+
+
+ Double
+
+
+
+
+ Non-reference
+
+
+ By-reference.
+
+
+
+
+
+
+ Gets a reference to the default binder, which implements internal rules for selecting the appropriate members to be called by.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Field
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Char
+
+
+
+
+ This field is read-only.
+
+
+
+ Separates names in the namespace of the. This field is read-only.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Field
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type[]
+
+
+
+
+ This field is read-only.
+ The emptyarray returned by this field is used to specify that
+ lookup methods in theclass, such asand,
+ search for members that do not take parameters.For example, to locate the public instance constructor that takes no
+ parameters, invoke(|,,,).
+
+
+
+
+ Represents an empty array of type. This field is read-only.
+
+
+ 1
+ Reflection
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+
+
+ This method overrides.
+
+
+
+ Determines if the underlying system type of the currentis the same as the underlying system type of the specified.
+
+
+
+ true if the underlying system type ofis the same as the underlying system type of the current; otherwise, false. This method also returns false if the object specified by theparameter is not a Type.
+
+
+ The object whose underlying system type is to be compared with the underlying system type of the current.
+
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ To be added.
+
+
+ Determines if the underlying system type of the currentis the same as the underlying system type of the specified.
+
+
+
+ true if the underlying system type ofis the same as the underlying system type of the current; otherwise, false.
+
+
+ The object whose underlying system type is to be compared with the underlying system type of the current.
+
+ 1
+ Reflection
+
+
+
+
+ Field
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MemberFilter
+
+
+
+
+ This field holds a reference to the delegate used by themethod. The method encapsulated by this delegate takes two parameters: the first is aobject and the second is an Object. The method determines whether the MemberInfo object matches the criteria specified by the Object. The Object may be assigned the value of any one of the fields on the classes,, or.
+ For example, the Object can be assigned the value of a field from FieldAttributes such as Public. In that case, when the FilterAttribute delegate is invoked, it will return true only if the method represented by the MemberInfo object is decorated with the public field attribute in metadata.
+
+
+
+ Represents the member filter used on attributes. This field is read-only.
+
+
+
+
+
+
+ Field
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MemberFilter
+
+
+
+
+ This field holds a reference to the delegate used by themethod. The method encapsulated by this delegate takes two parameters: the first is aobject and the second is an Object. The method determines whether the MemberInfo object matches the criteria specified by the Object. The Object is assigned a string value, which may include a trailing "*" wildcard character. Only wildcard end string matching is supported.
+ For example, the Object may be assigned the value "Byte*". In that case, when the FilterName delegate is invoked, it will return true only if the method represented by the MemberInfo object has a name that begins with "Byte".
+
+
+
+ Represents the case-sensitive member filter used on names. This field is read-only.
+
+
+
+
+
+
+ Field
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MemberFilter
+
+
+
+
+ This field holds a reference to the delegate used by themethod. The method encapsulated by this delegate takes two parameters: the first is aobject and the second is an Object. The method determines whether the MemberInfo object matches the criteria specified by the Object. The Object is assigned a string value, which may include a trailing "*" wildcard character. Only wildcard end string matching is supported.
+ For example, the Object may be assigned the value "ByTe*". In that case, when the FilterName delegate is invoked, it will return true only if the method represented by the MemberInfo object has a name that begins with "byte", ignoring case.
+
+
+
+ Represents the case-insensitive member filter used on names. This field is read-only.
+
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type[]
+
+
+
+
+
+
+
+
+ This method can be overridden by a derived class.
+ Theanddelegates supplied by theclass may also be used, in lieu of thedelegate.
+ All of the interfaces implemented by this class are considered during the search, whether declared by a base class or this class itself.
+ This method searches the base class hierarchy, returning each of the matching interfaces each class implements as well as all the matching interfaces each of those interfaces implements (that is, the transitive closure of the matching interfaces is returned). No duplicate interfaces are returned.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method,searches all the interfaces declared in the constraints on the type parameter, and all interfaces inherited through the interfaces declared in the constraints. If the currentrepresents a type argument of a generic type,searches all the interfaces implemented by the type, whether or not they match constraints.
+
+
+ can return generic interfaces, even on types that are not generic. For example, a nongeneric type might implement IEnumerable<int> (IEnumerable(Of Integer) in Visual Basic).
+
+
+
+
+ Returns an array ofobjects representing a filtered list of interfaces implemented or inherited by the current.
+
+
+
+ An array ofobjects representing a filtered list of the interfaces implemented or inherited by the current, or an empty array of typeif no interfaces matching the filter are implemented or inherited by the current.
+
+
+ The delegate that compares the interfaces against.
+
+ The search criteria that determines whether an interface should be included in the returned array.
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MemberInfo[]
+
+
+
+
+
+
+
+
+
+
+ This method can be overridden by a derived class.
+ Members include properties, methods, fields, events, and so on.
+ The followingfilter flags can be used to define which members to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Instance to include instance members in the search.
+
+
+ Specify BindingFlags.Static to include static members in the search.
+
+
+ Specify BindingFlags.Public to include public members in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public members (that is, private, internal, and protected members) in the search.
+
+
+ The followingmodifier flags can be used to change how the search works:
+
+
+ BindingFlags.DeclaredOnly to search only the members declared on the, not members that were simply inherited.
+
+
+ Seefor more information.
+ Valid values forare defined in. If no such members are found, an empty array is returned.
+ To get the class initializer (.cctor) using this method, you must specify|(Orin Visual Basic). You can also get the class initializer using theproperty.
+ If the currentrepresents a type parameter of a generic type or generic method,processes any members declared by the class constraint and the interface constraints of the type parameter.
+
+
+
+ Returns a filtered array ofobjects of the specified member type.
+
+
+
+ A filtered array ofobjects of the specified member type.
+ -or-
+ An empty array of type, if the currentdoes not have members of typethat match the filter criteria.
+
+
+ An object that indicates the type of member to search for.
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ The delegate that does the comparisons, returning true if the member currently being inspected matches theand false otherwise. You can use the FilterAttribute, FilterName, and FilterNameIgnoreCase delegates supplied by this class. The first uses the fields of FieldAttributes, MethodAttributes, and MethodImplAttributes as search criteria, and the other two delegates use String objects as the search criteria.
+
+ The search criteria that determines whether a member is returned in the array of MemberInfo objects.
+
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.String
+
+
+
+
+ Acontaining the fully qualified name of the.
+
+
+ The following example demonstrates using theproperty.
+ using System;
+class TestType {
+ public static void Main() {
+ Type t = typeof(Array);
+ Console.WriteLine("Full name of Array type is {0}",t.FullName);
+ }
+}
+ The output is
+
+ Full name of
+ Array type is System.Array
+
+
+
+
+ For example, the fully qualified name of the C# string type is System.String. Contrast this with the assembly-qualified name, which is the full name plus the assembly, provided by theproperty.
+ If the currentrepresents a generic type, the type arguments in the string returned byare qualified by their assembly, version, and so on, even though the string representation of the generic type itself is not qualified by assembly. Thus, concatenating t.FullName + ", " + t.Assembly.FullName produces a result that is equivalent to t.AssemblyQualifiedName, as is the case with types that are not generic.
+ If the currentrepresents a type parameter of a generic type, or an array type, pointer type, or byref type based on a type parameter, this property returns null.
+ If the current type contains generic type parameters that have not been replaced by specific types (that is, theproperty returns true), but the type is not a generic type definition (that is, theproperty returns false), this property returns null. For example, consider the classes Base and Derived in the following code.
+ code reference: System.Type.FullName#1
+ If you use theproperty to obtain the base type of Derived, theproperty of the resultingobject returns null. To get a non-null, you can use themethod to get the generic type definition.
+ This property is read-only.
+
+
+
+ Gets the fully qualified name of the, including the namespace of thebut not the assembly.
+
+
+ 0
+
+
+
+
+ Property
+
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.GenericParameterAttributes
+
+
+
+ Avalue that describes the variance and special constraints of the current generic type parameter.
+
+
+ The currentobject is not a generic type parameter. That is, theproperty returns.
+
+
+ The value of this property contains flags that describe whether the current generic type parameter is covariant, and flags that describe any special constraints. Use thevalue to select the covariance flags, and use thevalue to select the constraint flags.
+ For a list of the invariant conditions for terms used in generic reflection, see theproperty remarks.
+
+
+
+ Gets a combination offlags that describe the covariance and special constraints of the current generic type parameter.
+
+
+
+
+
+
+ Property
+
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Int32
+
+
+
+ A zero-based integer representing the position of a type parameter in the type parameter list of the generic type or generic method that declared the parameter.
+
+
+ The current type does not represent a type parameter. That is,returns.
+
+ The following example defines a generic class with two type parameters, and a generic class that derives from it. The base class of the derived type has one unbound type parameter and one type parameter bound to. The example displays information about these generic classes, including the positions reported by.
+ using System;
+using System.Reflection;
+using System.Collections.Generic;
+// Define a base class with two type parameters.
+public class Base<T, U> { }
+
+// Define a derived class. The derived class inherits from a constructed
+// class that meets the following criteria:
+// (1) Its generic type definition is Base<T, U>.
+// (2) It specifies int for the first type parameter.
+// (3) For the second type parameter, it uses the same type that is used
+// for the type parameter of the derived class.
+// Thus, the derived class is a generic type with one type parameter, but
+// its base class is an open constructed type with one type argument and
+// one type parameter.
+public class Derived<V>: Base<int,V> { }
+
+public class Test
+{
+ public static void Main()
+ {
+ Console.WriteLine("\n--- Display a generic type and the open constructed");
+ Console.WriteLine(" type from which it is derived.");
+
+ // Create a Type object representing the generic type Derived.
+ //
+ Type derivedType = Type.GetType("Derived");
+
+ DisplayGenericTypeInfo(derivedType);
+
+ // Display its open constructed base type.
+ DisplayGenericTypeInfo(derivedType.BaseType);
+ }
+
+ private static void DisplayGenericTypeInfo(Type t)
+ {
+ Console.WriteLine("\n{0}", t);
+ Console.WriteLine("\tIs this a generic type definition? {0}", t.IsGenericTypeDefinition);
+ Console.WriteLine("\tDoes it have generic arguments? {0}", t.HasGenericArguments);
+ Console.WriteLine("\tDoes it have unbound generic parameters? {0}", t.ContainsGenericParameters);
+ if (t.HasGenericArguments)
+ {
+ // If the type is a generic type definition or a
+ // constructed type, display the type arguments.
+ //
+ Type[] typeArguments = t.GetGenericArguments();
+
+ Console.WriteLine("\tList type arguments ({0}):", typeArguments.Length);
+ foreach (Type tParam in typeArguments)
+ {
+ // IsGenericParameter is true only for generic type
+ // parameters.
+ //
+ if (tParam.IsGenericParameter)
+ {
+ Console.WriteLine("\t\t{0} (unbound - parameter position {1})", tParam, tParam.GenericParameterPosition);
+ }
+ else
+ {
+ Console.WriteLine("\t\t{0}", tParam);
+ }
+ }
+ }
+ else
+ {
+ Console.WriteLine("\tThis is not a generic or constructed type.");
+ }
+ }
+}
+
+/* This example produces the following output:
+
+--- Display a generic type and the open constructed
+ type from which it is derived.
+
+Derived[V]
+ Is this a generic type definition? True
+ Does it have generic arguments? True
+ Does it have unbound generic parameters? True
+ List type arguments (1):
+ V (unbound - parameter position 0)
+
+Base[System.Int32, V]
+ Is this a generic type definition? False
+ Does it have generic arguments? True
+ Does it have unbound generic parameters? True
+ List type arguments (2):
+ System.Int32
+ V (unbound - parameter position 0)
+ */
+
+
+
+ Theproperty returns the position of a type parameter in the parameter list of the generic type definition or generic method definition where the type parameter was originally defined. Theandproperties identify the generic type or method definition:
+
+
+ If theproperty returns a, thatrepresents a generic method definition, and the currentobject represents a type parameter of that generic method definition.
+
+
+ If theproperty returns null, then theproperty always returns aobject representing a generic type definition, and the currentobject represents a type parameter of that generic type definition.
+
+
+ To provide the correct context for the value of theproperty, it is necessary to identify the generic type or method a type parameter belongs to. For example, consider the return value of the generic method GetSomething in the following code:
+ code reference: System.Type.GenericParameterPosition#1
+ The type returned by GetSomething depends on the type arguments supplied to class A and to GetSomething itself. You can obtain afor GetSomething, and from that you can obtain the return type. When you examine the type parameters of the return type,returns 0 for both. The position of V is 0 because V is the first type parameter in the type parameter list for class A. The position of X is 0 because X is the first type parameter in the type parameter list for GetSomething.
+
+ Calling theproperty causes an exception if the currentdoes not represent a type parameter. When you examine the type arguments of an open constructed type, use theproperty to tell which are type parameters and which are types. Theproperty returns true for a type parameter; you can then use themethod to obtain its position and use theandproperties to determine the generic method or type definition that defines it.
+
+
+
+
+ Gets the position of the type parameter in the type parameter list of the generic type or method that declared the parameter, when theobject represents a type parameter of a generic type or a generic method.
+
+
+
+
+
+
+ Property
+
+ 4.0.0.0
+
+
+ System.Type[]
+
+
+ To be added.
+
+
+ This property gets only the generic type arguments; that is, the types that have been specified for the generic type parameters of the current type. If the current type is a generic type definition, this property returns an empty array.
+
+ If a generic type is used in a generic method or in another generic type, some of its generic type arguments might be generic type parameters of the enclosing method or type.
+
+ To get the generic type parameters of a type that represents a generic type definition, use theproperty. To get aobject for the currentobject, use theextension method.
+
+
+
+ Gets an array of the generic type arguments for this type.
+
+
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Int32
+
+
+
+ To be added.
+ The currentis not an array.
+
+
+ Gets the number of dimensions in an.
+
+
+
+ Ancontaining the number of dimensions in the current Type.
+
+
+ 0
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.TypeAttributes
+
+
+
+
+
+ This property is read-only.
+ This method returns avalue that indicates the attributes set in
+ the metadata of the type represented by the current
+ instance.
+
+
+ Use this property to determine the
+ visibility, semantics, and layout format of the type represented by the
+ current instance. Also use this property to determine if the type represented by
+ the current instance has a special name.
+
+
+
+
+ When overridden in a derived class, implements theproperty and gets a bitmask indicating the attributes associated with the.
+
+
+
+ Aobject representing the attribute set of the.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+
+ System.Runtime.InteropServices.ComVisible(true)
+
+
+
+ System.Reflection.ConstructorInfo
+
+
+
+
+
+
+
+ is, or at least one of the elements inis.
+
+
+ has more than one dimension.
+
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+
+ This method overload looks for public instance constructors and cannot be used to obtain a class initializer (.cctor). To get a class initializer, use an overload that takes, and specify|(Orin Visual Basic). You can also get the class initializer using theproperty.
+ If the requested constructor is non-public, this method returns null.
+
+ You cannot omit parameters when looking up constructors and methods. You can only omit parameters when invoking.
+
+ If the currentrepresents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments. If the currentrepresents a type parameter in the definition of a generic type or generic method, this method always returns null.
+
+
+
+ Searches for a public instance constructor whose parameters match the types in the specified array.
+
+
+
+ An object representing the public instance constructor whose parameters match the types in the parameter type array, if found; otherwise, null.
+
+
+ An array ofobjects representing the number, order, and type of the parameters for the desired constructor.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+
+ System.Runtime.InteropServices.ComVisible(true)
+
+
+
+ System.Reflection.ConstructorInfo
+
+
+
+
+
+
+
+
+
+
+ is, or at least one of the elements inis.
+
+
+ has more than one dimension.
+
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+
+ If an exact match does not exist, thewill attempt to coerce the parameter types specified in thearray in order to select a match. If theis unable to select a match, then null is returned.
+ The followingfilter flags can be used to define which constructors to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Public to include public constructors in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public constructors (that is, private, internal, and protected constructors) in the search.
+
+
+ Seefor more information.
+ To get the class initializer (.cctor) using this method overload, you must specify|(Orin Visual Basic). You can also get the class initializer using theproperty.
+
+ You cannot omit parameters when looking up constructors and methods. You can only omit parameters when invoking.
+
+ If the currentrepresents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments. If the currentrepresents a type parameter in the definition of a generic type or generic method, this method always returns null.
+
+
+
+ Searches for a constructor whose parameters match the specified argument types and modifiers, using the specified binding constraints.
+
+
+
+ Aobject representing the constructor that matches the specified requirements, if found; otherwise, null.
+
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ An object that defines a set of properties and enables binding, which can involve selection of an overloaded method, coercion of argument types, and invocation of a member through reflection.
+
+ An array ofobjects representing the number, order, and type of the parameters for the constructor to get.
+
+ An array ofobjects representing the attributes associated with the corresponding element in the parameter type array. The default binder does not process this parameter.
+
+ 1
+ Reflection
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+
+ System.Runtime.InteropServices.ComVisible(true)
+
+
+
+ System.Reflection.ConstructorInfo
+
+
+
+
+
+
+
+
+
+
+
+ Although the default binder does not process(theparameter), you can use the abstractclass to write a custom binder that does process. ParameterModifier is only used when calling through COM interop, and only parameters that are passed by reference are handled.
+ If an exact match does not exist, thewill attempt to coerce the parameter types specified in thearray in order to select a match. If theis unable to select a match, then null is returned.
+ The followingfilter flags can be used to define which constructors to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Public to include public constructors in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public constructors (that is, private, internal, and protected constructors) in the search.
+
+
+ Seefor more information.
+ To get the class initializer (.cctor) using this method, you must specify|(Orin Visual Basic). You can also get the class initializer using theproperty.
+ The following table shows what members of a base class are returned by the Get methods when reflecting on a type.
+
+
+
+
+ Member Type
+
+
+ Static
+
+
+ Non-Static
+
+
+
+
+
+ Constructor
+
+
+ No
+
+
+ No
+
+
+
+
+ Field
+
+
+ No
+
+
+ Yes. A field is always hide-by-name-and-signature.
+
+
+
+
+ Event
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+ Method
+
+
+ No
+
+
+ Yes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.
+
+
+
+
+ Nested Type
+
+
+ No
+
+
+ No
+
+
+
+
+ Property
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+
+ Hide-by-name-and-signature considers all of the parts of the signature, including custom modifiers, return types, parameter types, sentinels, and unmanaged calling conventions. This is a binary comparison.
+
+
+ For reflection, properties and events are hide-by-name-and-signature. If you have a property with both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and you will not be able to access the setter on the base class.
+
+
+ Custom attributes are not part of the common type system.
+
+
+
+ You cannot omit parameters when looking up constructors and methods. You can only omit parameters when invoking.
+
+ If the currentrepresents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments. If the currentrepresents a type parameter in the definition of a generic type or generic method, this method always returns null.
+
+
+
+ Searches for a constructor whose parameters match the specified argument types and modifiers, using the specified binding constraints and the specified calling convention.
+
+
+
+ An object representing the constructor that matches the specified requirements, if found; otherwise, null.
+
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ An object that defines a set of properties and enables binding, which can involve selection of an overloaded method, coercion of argument types, and invocation of a member through reflection.
+
+ The object that specifies the set of rules to use regarding the order and layout of arguments, how the return value is passed, what registers are used for arguments, and the stack is cleaned up.
+
+ An array ofobjects representing the number, order, and type of the parameters for the constructor to get.
+
+ An array ofobjects representing the attributes associated with the corresponding element in thearray. The default binder does not process this parameter.
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.ConstructorInfo
+
+
+
+
+
+
+
+
+
+
+
+ Although the default binder does not process(theparameter), you can use the abstractclass to write a custom binder that does process. ParameterModifier is only used when calling through COM interop, and only parameters that are passed by reference are handled.
+ If an exact match does not exist, thewill attempt to coerce the parameter types specified in thearray in order to select a match. If theis unable to select a match, then null is returned.
+ The followingfilter flags can be used to define which constructors to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Public to include public constructors in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public constructors (that is, private, internal, and protected constructors) in the search.
+
+
+ Seefor more information.
+ This method implements.
+
+
+
+ When overridden in a derived class, searches for a constructor whose parameters match the specified argument types and modifiers, using the specified binding constraints and the specified calling convention.
+
+
+
+ Aobject representing the constructor that matches the specified requirements, if found; otherwise, null.
+
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ An object that defines a set of properties and enables binding, which can involve selection of an overloaded method, coercion of argument types, and invocation of a member through reflection.
+
+ The object that specifies the set of rules to use regarding the order and layout of arguments, how the return value is passed, what registers are used for arguments, and the stack is cleaned up.
+
+ An array ofobjects representing the number, order, and type of the parameters for the constructor to get.
+
+ An array ofobjects representing the attributes associated with the corresponding element in thearray. The default binder does not process this parameter.
+
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+
+ System.Runtime.InteropServices.ComVisible(true)
+
+
+
+ System.Reflection.ConstructorInfo[]
+
+
+
+
+
+ Themethod does not return constructors in a particular order, such as declaration order. Your code must not depend on the order in which constructors are returned, because that order varies.
+ The following table shows what members of a base class are returned by the Get methods when reflecting on a type.
+
+
+
+
+ Member Type
+
+
+ Static
+
+
+ Non-Static
+
+
+
+
+
+ Constructor
+
+
+ No
+
+
+ No
+
+
+
+
+ Field
+
+
+ No
+
+
+ Yes. A field is always hide-by-name-and-signature.
+
+
+
+
+ Event
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+ Method
+
+
+ No
+
+
+ Yes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.
+
+
+
+
+ Nested Type
+
+
+ No
+
+
+ No
+
+
+
+
+ Property
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+
+ Hide-by-name-and-signature considers all of the parts of the signature, including custom modifiers, return types, parameter types, sentinels, and unmanaged calling conventions. This is a binary comparison.
+
+
+ For reflection, properties and events are hide-by-name-and-signature. If you have a property with both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and you will not be able to access the setter on the base class.
+
+
+ Custom attributes are not part of the common type system.
+
+
+ This method overload calls themethod overload, with|(Orin Visual Basic). It will not find class initializers (.cctor). To find class initializers, use an overload that takes, and specify|(Orin Visual Basic). You can also get the class initializer using theproperty.
+ If the currentrepresents a constructed generic type, this method returns theobjects with the type parameters replaced by the appropriate type arguments. For example, if class C<T> has a constructor C(T t1) (Sub New(ByVal t1 As T) in Visual Basic), callingon C<int> returns athat represents C(int t1) in C# (Sub New(ByVal t1 As Integer) in Visual Basic).
+ If the currentrepresents a generic type parameter, themethod returns an empty array.
+
+
+
+ Returns all the public constructors defined for the current.
+
+
+
+ An array ofobjects representing all the public instance constructors defined for the current, but not including the type initializer (static constructor). If no public instance constructors are defined for the current, or if the currentrepresents a type parameter in the definition of a generic type or generic method, an empty array of typeis returned.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+
+ System.Runtime.InteropServices.ComVisible(true)
+
+
+
+ System.Reflection.ConstructorInfo[]
+
+
+
+
+
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+
+ Themethod does not return constructors in a particular order, such as declaration order. Your code must not depend on the order in which constructors are returned, because that order varies.
+
+ can be used to specify whether to return only public constructors or both public and non-public constructors.
+ If an exact match does not exist, thewill attempt to coerce the parameter types specified in thearray in order to select a match. If theis unable to select a match, then null is returned.
+ The followingfilter flags can be used to define which constructors to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Public to include public constructors in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public constructors (that is, private, internal, and protected constructors) in the search. Constructors of base classes are not returned.
+
+
+ Seefor more information.
+ To get the class initializer (.cctor) using this method overload, you must specify|(Orin Visual Basic). You can also get the class initializer using theproperty.
+ If the currentrepresents a constructed generic type, this method returns theobjects with the type parameters replaced by the appropriate type arguments. For example, if class C<T> has a constructor C(T t1) (Sub New(ByVal t1 As T) in Visual Basic), callingon C<int> returns athat represents C(int t1) in C# (Sub New(ByVal t1 As Integer) in Visual Basic).
+ If the currentrepresents a generic type parameter, themethod returns an empty array.
+
+
+
+ When overridden in a derived class, searches for the constructors defined for the current, using the specified BindingFlags.
+
+
+
+ An array ofobjects representing all constructors defined for the currentthat match the specified binding constraints, including the type initializer if it is defined. Returns an empty array of typeif no constructors are defined for the current, if none of the defined constructors match the binding constraints, or if the currentrepresents a type parameter in the definition of a generic type or generic method.
+
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MemberInfo[]
+
+
+
+
+
+ Themethod does not return members in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which members are returned, because that order varies.
+ This method can be overridden by a derived class.
+ Members include properties, methods, fields, events, and so on.
+ The following table shows what members of a base class are returned by the Get methods when reflecting on a type.
+
+
+
+
+ Member Type
+
+
+ Static
+
+
+ Non-Static
+
+
+
+
+
+ Constructor
+
+
+ No
+
+
+ No
+
+
+
+
+ Field
+
+
+ No
+
+
+ Yes. A field is always hide-by-name-and-signature.
+
+
+
+
+ Event
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+ Method
+
+
+ No
+
+
+ Yes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.
+
+
+
+
+ Nested Type
+
+
+ No
+
+
+ No
+
+
+
+
+ Property
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+
+ Hide-by-name-and-signature considers all of the parts of the signature, including custom modifiers, return types, parameter types, sentinels, and unmanaged calling conventions. This is a binary comparison.
+
+
+ For reflection, properties and events are hide-by-name-and-signature. If you have a property with both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and you will not be able to access the setter on the base class.
+
+
+ Custom attributes are not part of the common type system.
+
+
+ If the currentrepresents a constructed generic type, this method returns theobjects with the type parameters replaced by the appropriate type arguments. For example, if class C<T> has a property P that returns T, callingon C<int> returns int P in C# (Property P As Integer in Visual Basic).
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the members of the class constraint, or the members ofif there is no class constraint.
+
+
+
+ Searches for the members defined for the currentwhoseis set.
+
+
+
+ An array ofobjects representing all default members of the current.
+ -or-
+ An empty array of type, if the currentdoes not have default members.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+ The following example demonstrates themethod.
+ using System;
+class TestType {
+ public static void Main() {
+ int[] array = {1,2,3};
+ Type t = array.GetType();
+ Type t2 = t.GetElementType();
+ Console.WriteLine("{0} element type is {1}",array, t2.ToString());
+
+ TestType newMe = new TestType();
+ t = newMe.GetType();
+ t2 = t.GetElementType();
+ Console.WriteLine("{0} element type is {1}", newMe, t2==null? "null" : t2.ToString());
+ }
+}
+ The output is
+
+ System.Int32[] element type is System.Int32
+ TestType element type is null
+
+
+
+
+ This method returns null for theclass.
+
+
+
+ When overridden in a derived class, returns theof the object encompassed or referred to by the current array, pointer or reference type.
+
+
+
+ Theof the object encompassed or referred to by the current array, pointer, or reference type, or null if the currentis not an array or a pointer, or is not passed by reference, or represents a generic type or a type parameter in the definition of a generic type or generic method.
+
+
+ 0
+
+
+
+
+ Method
+
+ 4.0.0.0
+
+
+ System.String
+
+
+
+
+
+ To be added.
+
+
+ Returns the name of the constant that has the specified value, for the current enumeration type.
+
+
+
+ The name of the member of the current enumeration type that has the specified value, or null if no such constant is found.
+
+
+ The value whose name is to be retrieved.
+
+
+
+
+
+ Method
+
+ 4.0.0.0
+
+
+ System.String[]
+
+
+
+
+
+ The elements of the return value array are sorted by the binary values (that is, the unsigned values) of the enumerated constants. If the array contains enumerated constants with the same value, the order of their corresponding names is unspecified.
+
+
+
+ Returns the names of the members of the current enumeration type.
+
+
+
+ An array that contains the names of the members of the enumeration.
+
+
+
+
+
+
+ Method
+
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+ By default, the underlying type of an enumeration in C# and Visual Basic is. Other integer types can be specified.
+
+
+
+ Returns the underlying type of the current enumeration type.
+
+
+
+ The underlying type of the current enumeration.
+
+
+
+
+
+
+ Method
+
+ 4.0.0.0
+
+
+ System.Array
+
+
+
+ To be added.
+
+
+ Returns an array of the values of the constants in the current enumeration type.
+
+
+
+ An array that contains the values. The elements of the array are sorted by the binary values (that is, the unsigned values) of the enumeration constants.
+
+
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.EventInfo
+
+
+
+
+
+
+ is.
+
+
+ An event is considered public to reflection if it has at least one method or accessor that is public. Otherwise the event is considered private, and you must use||(in Visual Basic, combine the values using Or) to get it.
+ The search foris case-sensitive. The search includes public static and public instance events.
+ The following table shows what members of a base class are returned by the Get methods when reflecting on a type.
+
+
+
+
+ Member Type
+
+
+ Static
+
+
+ Non-Static
+
+
+
+
+
+ Constructor
+
+
+ No
+
+
+ No
+
+
+
+
+ Field
+
+
+ No
+
+
+ Yes. A field is always hide-by-name-and-signature.
+
+
+
+
+ Event
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+ Method
+
+
+ No
+
+
+ Yes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.
+
+
+
+
+ Nested Type
+
+
+ No
+
+
+ No
+
+
+
+
+ Property
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+
+ Hide-by-name-and-signature considers all of the parts of the signature, including custom modifiers, return types, parameter types, sentinels, and unmanaged calling conventions. This is a binary comparison.
+
+
+ For reflection, properties and events are hide-by-name-and-signature. If you have a property with both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and you will not be able to access the setter on the base class.
+
+
+ Custom attributes are not part of the common type system.
+
+
+ If the currentrepresents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the events of the class constraint.
+
+
+
+ Returns theobject representing the specified public event.
+
+
+
+ The object representing the specified public event that is declared or inherited by the current, if found; otherwise, null.
+
+
+ The string containing the name of an event that is declared or inherited by the current.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.EventInfo
+
+
+
+
+
+
+
+ is.
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+
+ The followingfilter flags can be used to define which events to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Public to include public events in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public events (that is, private, internal, and protected events) in the search.
+
+
+ Specify BindingFlags.FlattenHierarchy to include public and protected static members up the hierarchy; private static members in inherited classes are not included.
+
+
+ The followingmodifier flags can be used to change how the search works:
+
+
+ BindingFlags.IgnoreCase to ignore the case of.
+
+
+ BindingFlags.DeclaredOnly to search only the events declared on the, not events that were simply inherited.
+
+
+ Seefor more information.
+ An event is considered public to reflection if it has at least one method or accessor that is public. Otherwise the event is considered private, and you must use||(in Visual Basic, combine the values using Or) to get it.
+ If the currentrepresents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the events of the class constraint.
+
+
+
+ When overridden in a derived class, returns theobject representing the specified event, using the specified binding constraints.
+
+
+
+ The object representing the specified event that is declared or inherited by the current, if found; otherwise, null.
+
+
+ The string containing the name of an event which is declared or inherited by the current.
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.EventInfo[]
+
+
+
+
+
+ An event is considered public to reflection if it has at least one method or accessor that is public. Otherwise the event is considered private, and you must use||(in Visual Basic, combine the values using Or) to get it.
+ Themethod does not return events in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which events are returned, because that order varies.
+ This method can be overridden by a derived class.
+ The following table shows what members of a base class are returned by the Get methods when reflecting on a type.
+
+
+
+
+ Member Type
+
+
+ Static
+
+
+ Non-Static
+
+
+
+
+
+ Constructor
+
+
+ No
+
+
+ No
+
+
+
+
+ Field
+
+
+ No
+
+
+ Yes. A field is always hide-by-name-and-signature.
+
+
+
+
+ Event
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+ Method
+
+
+ No
+
+
+ Yes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.
+
+
+
+
+ Nested Type
+
+
+ No
+
+
+ No
+
+
+
+
+ Property
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+
+ Hide-by-name-and-signature considers all of the parts of the signature, including custom modifiers, return types, parameter types, sentinels, and unmanaged calling conventions. This is a binary comparison.
+
+
+ For reflection, properties and events are hide-by-name-and-signature. If you have a property with both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and you will not be able to access the setter on the base class.
+
+
+ Custom attributes are not part of the common type system.
+
+
+ If the currentrepresents a constructed generic type, this method returns theobjects with the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the events of the class constraint.
+
+
+
+ Returns all the public events that are declared or inherited by the current.
+
+
+
+ An array ofobjects representing all the public events which are declared or inherited by the current.
+ -or-
+ An empty array of type, if the currentdoes not have public events.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.EventInfo[]
+
+
+
+
+
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+
+ Themethod does not return events in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which events are returned, because that order varies.
+ The followingfilter flags can be used to define which events to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Public to include public events in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public events (that is, private, internal, and protected events) in the search. Only protected and internal events on base classes are returned; private events on base classes are not returned.
+
+
+ Specify BindingFlags.FlattenHierarchy to include public and protected static members up the hierarchy; private static members in inherited classes are not included.
+
+
+ The followingmodifier flags can be used to change how the search works:
+
+
+ BindingFlags.DeclaredOnly to search only the events declared on the, not events that were simply inherited.
+
+
+ Seefor more information.
+ An event is considered public to reflection if it has at least one method or accessor that is public. Otherwise the event is considered private, and you must use||(in Visual Basic, combine the values using Or) to get it.
+ If the currentrepresents a constructed generic type, this method returns theobjects with the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the events of the class constraint.
+
+
+
+ When overridden in a derived class, searches for events that are declared or inherited by the current, using the specified binding constraints.
+
+
+
+ An array ofobjects representing all events that are declared or inherited by the currentthat match the specified binding constraints.
+ -or-
+ An empty array of type, if the currentdoes not have events, or if none of the events match the binding constraints.
+
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.FieldInfo
+
+
+
+
+
+
+ is.
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+
+ The search foris case-sensitive. The search includes public static and public instance fields.
+ If the currentrepresents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the fields of the class constraint.
+
+
+
+ Searches for the public field with the specified name.
+
+
+
+ An object representing the public field with the specified name, if found; otherwise, null.
+
+
+ The string containing the name of the data field to get.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.FieldInfo
+
+
+
+
+
+
+
+ is.
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+
+ The following table shows what members of a base class are returned by the Get methods when reflecting on a type.
+
+
+
+
+ Member Type
+
+
+ Static
+
+
+ Non-Static
+
+
+
+
+
+ Constructor
+
+
+ No
+
+
+ No
+
+
+
+
+ Field
+
+
+ No
+
+
+ Yes. A field is always hide-by-name-and-signature.
+
+
+
+
+ Event
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+ Method
+
+
+ No
+
+
+ Yes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.
+
+
+
+
+ Nested Type
+
+
+ No
+
+
+ No
+
+
+
+
+ Property
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+
+ Hide-by-name-and-signature considers all of the parts of the signature, including custom modifiers, return types, parameter types, sentinels, and unmanaged calling conventions. This is a binary comparison.
+
+
+ For reflection, properties and events are hide-by-name-and-signature. If you have a property with both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and you will not be able to access the setter on the base class.
+
+
+ Custom attributes are not part of the common type system.
+
+
+ The followingfilter flags can be used to define which fields to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Public to include public fields in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public fields (that is, private, internal, and protected fields) in the search.
+
+
+ Specify BindingFlags.FlattenHierarchy to include public and protected static members up the hierarchy; private static members in inherited classes are not included.
+
+
+ The followingmodifier flags can be used to change how the search works:
+
+
+ BindingFlags.IgnoreCase to ignore the case of.
+
+
+ BindingFlags.DeclaredOnly to search only the fields declared on the, not fields that were simply inherited.
+
+
+ Seefor more information.
+ If the currentrepresents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the fields of the class constraint.
+
+
+
+ Searches for the specified field, using the specified binding constraints.
+
+
+
+ An object representing the field that matches the specified requirements, if found; otherwise, null.
+
+
+ The string containing the name of the data field to get.
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.FieldInfo[]
+
+
+
+
+
+ Themethod does not return fields in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which fields are returned, because that order varies.
+ The following table shows what members of a base class are returned by the Get methods when reflecting on a type.
+
+
+
+
+ Member Type
+
+
+ Static
+
+
+ Non-Static
+
+
+
+
+
+ Constructor
+
+
+ No
+
+
+ No
+
+
+
+
+ Field
+
+
+ No
+
+
+ Yes. A field is always hide-by-name-and-signature.
+
+
+
+
+ Event
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+ Method
+
+
+ No
+
+
+ Yes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.
+
+
+
+
+ Nested Type
+
+
+ No
+
+
+ No
+
+
+
+
+ Property
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+
+ Hide-by-name-and-signature considers all of the parts of the signature, including custom modifiers, return types, parameter types, sentinels, and unmanaged calling conventions. This is a binary comparison.
+
+
+ For reflection, properties and events are hide-by-name-and-signature. If you have a property with both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and you will not be able to access the setter on the base class.
+
+
+ Custom attributes are not part of the common type system.
+
+
+ If the currentrepresents a constructed generic type, this method returns theobjects with the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the public fields of the class constraint.
+
+
+
+ Returns all the public fields of the current.
+
+
+
+ An array ofobjects representing all the public fields defined for the current.
+ -or-
+ An empty array of type, if no public fields are defined for the current.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.FieldInfo[]
+
+
+
+
+
+ Requires permission to retrieve information on non-public members of a type in loaded assemblies. See.
+
+
+ Themethod does not return fields in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which fields are returned, because that order varies.
+ The followingfilter flags can be used to define which fields to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Public to include public fields in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public fields (that is, private, internal, and protected fields) in the search. Only protected and internal fields on base classes are returned; private fields on base classes are not returned.
+
+
+ Specify BindingFlags.FlattenHierarchy to include public and protected static members up the hierarchy; private static members in inherited classes are not included.
+
+
+ The followingmodifier flags can be used to change how the search works:
+
+
+ BindingFlags.DeclaredOnly to search only the fields declared on the, not fields that were simply inherited.
+
+
+ Seefor more information.
+ If the currentrepresents a constructed generic type, this method returns theobjects with the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the public fields of the class constraint.
+
+
+
+ When overridden in a derived class, searches for the fields defined for the current, using the specified binding constraints.
+
+
+
+ An array ofobjects representing all fields defined for the currentthat match the specified binding constraints.
+ -or-
+ An empty array of type, if no fields are defined for the current, or if none of the defined fields match the binding constraints.
+
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ 1
+ Reflection
+
+
+
+
+ Method
+
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type[]
+
+
+
+
+
+ For an example of using this method, see the example for.
+
+
+
+ The array elements are returned in the order in which they appear in the list of type arguments for the generic type.
+
+
+ If the current type is a closed constructed type (that is, theproperty returns false), the array returned by themethod contains the types that have been assigned to the generic type parameters of the generic type definition.
+
+
+ If the current type is a generic type definition, the array contains the type parameters.
+
+
+ If the current type is an open constructed type (that is, theproperty returns true) in which specific types have not been assigned to all of the type parameters and type parameters of enclosing generic types or methods, the array contains both types and type parameters. Use theproperty to tell them apart. For a demonstration of this scenario, see the code example for theproperty.
+
+
+ For a list of the invariant conditions for terms used in generic reflection, see theproperty remarks.
+
+
+
+ Returns an array ofobjects that represent the type arguments of a generic type or the type parameters of a generic type definition.
+
+
+
+ An array ofobjects that represent the type arguments of a generic type. Returns an empty array if the current type is not a generic type.
+
+
+
+
+
+
+ Method
+
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type[]
+
+
+
+
+ The currentobject is not a generic type parameter. That is, theproperty returns.
+
+
+ Each constraint on a generic type parameter is expressed as aobject. Use theproperty to determine whether a constraint is the base class constraint; if the property returns false, the constraint is an interface constraint. If a type parameter has no class constraint and no interface constraints, an empty array is returned.
+ For a list of the invariant conditions for terms used in generic reflection, see theproperty remarks.
+
+
+
+ Returns an array ofobjects that represent the constraints on the current generic type parameter.
+
+
+
+ An array ofobjects that represent the constraints on the current generic type parameter.
+
+
+
+
+
+
+ Method
+
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+ The current type is not a generic type. That is,returns.
+
+ For an example of using this method, see the example for.
+
+
+
+ A generic type definition is a template from which other types can be constructed. For example, from the generic type definition G<T> (expressed in C# syntax; G(Of T) in Visual Basic or generic <typename T> ref class G in C++) you can construct and instantiate the type G<int> (G(Of Integer) in Visual Basic). Given aobject representing this constructed type, themethod returns the generic type definition.
+ If two constructed types are created from the same generic type definition, using the same type arguments, themethod returns the sameobject for both types.
+ If you call themethod on aobject that already represents a generic type definition, it returns the current.
+
+ An array of generic types is not itself generic. In the C# code A<int>[] v; or the Visual Basic code Dim v() As A(Of Integer), the type of variable v is not generic. Useto determine whether a type is generic before calling.
+
+ For a list of the invariant conditions for terms used in generic reflection, see theproperty remarks.
+
+
+
+ Returns aobject that represents a generic type definition from which the current generic type can be constructed.
+
+
+
+ Aobject representing a generic type from which the current type can be constructed.
+
+
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Int32
+
+
+
+
+
+ This method overrides.
+
+
+
+ Returns the hash code for this instance.
+
+
+
+ The hash code for this instance.
+
+
+ 0
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+ is.
+ The current instance represents a type that implements the same generic interface with different type arguments.
+
+
+ The search foris case-sensitive.
+ If the currentrepresents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the interface constraints and any interfaces inherited from class or interface constraints.
+
+ For generic interfaces, theparameter is the mangled name, ending with a grave accent (`) and the number of type parameters. This is true for both generic interface definitions and constructed generic interfaces. For example, to find IExample<T> (IExample(Of T) in Visual Basic) or IExample<string> (IExample(Of String) in Visual Basic), search for "IExample`1".
+
+
+
+
+ Searches for the interface with the specified name.
+
+
+
+ An object representing the interface with the specified name, implemented or inherited by the current, if found; otherwise, null.
+
+
+ The string containing the name of the interface to get. For generic interfaces, this is the mangled name.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+
+ is.
+ The current instance represents a type that implements the same generic interface with different type arguments.
+
+
+ Theparameter applies only to the simple interface name, not to the namespace. The portion ofthat specifies the namespace must have the correct case, or the interface will not be found. For example, the string "System.icomparable" finds theinterface, but the string "system.icomparable" does not.
+ If the currentrepresents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the interface constraints and any interfaces inherited from class or interface constraints.
+
+ For generic interfaces, theparameter is the mangled name, ending with a grave accent (`) and the number of type parameters. This is true for both generic interface definitions and constructed generic interfaces. For example, to find IExample<T> (IExample(Of T) in Visual Basic) or IExample<string> (IExample(Of String) in Visual Basic), search for "IExample`1".
+
+
+
+
+ When overridden in a derived class, searches for the specified interface, specifying whether to do a case-insensitive search for the interface name.
+
+
+
+ An object representing the interface with the specified name, implemented or inherited by the current, if found; otherwise, null.
+
+
+ The string containing the name of the interface to get. For generic interfaces, this is the mangled name.
+
+ true to ignore the case of that part ofthat specifies the simple interface name (the part that specifies the namespace must be correctly cased).
+
+ 1
+ Reflection
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+
+ System.Runtime.InteropServices.ComVisible(true)
+
+
+
+ System.Reflection.InterfaceMapping
+
+
+
+
+
+
+
+ The interface map denotes how an interface is mapped into the actual methods on a class that implements that interface.
+ If the currentrepresents a constructed generic type, type parameters are replaced by the appropriate type arguments in the elements of thereturned by this method.
+
+
+
+ Returns an interface mapping for the specified interface type.
+
+
+
+ An object that represents the interface mapping for.
+
+
+ The interface type to retrieve a mapping for.
+
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type[]
+
+
+
+
+
+ Themethod does not return interfaces in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which interfaces are returned, because that order varies.
+ If the currentrepresents a constructed generic type, this method returns theobjects with the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the interface constraints and any interfaces inherited from class or interface constraints.
+
+
+
+ When overridden in a derived class, gets all the interfaces implemented or inherited by the current.
+
+
+
+ An array ofobjects representing all the interfaces implemented or inherited by the current.
+ -or-
+ An empty array of type, if no interfaces are implemented or inherited by the current.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MemberInfo[]
+
+
+
+
+
+
+ is.
+
+
+ The search foris case-sensitive. The search includes public static and public instance members.
+ Members include properties, methods, fields, events, and so on.
+ Themethod does not return members in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which members are returned, because that order varies.
+ This method overload will not find class initializers (.cctor). To find class initializers, use an overload that takes, and specify|(Orin Visual Basic). You can also get the class initializer using theproperty.
+ The following table shows what members of a base class are returned by the Get methods when reflecting on a type.
+
+
+
+
+ Member Type
+
+
+ Static
+
+
+ Non-Static
+
+
+
+
+
+ Constructor
+
+
+ No
+
+
+ No
+
+
+
+
+ Field
+
+
+ No
+
+
+ Yes. A field is always hide-by-name-and-signature.
+
+
+
+
+ Event
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+ Method
+
+
+ No
+
+
+ Yes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.
+
+
+
+
+ Nested Type
+
+
+ No
+
+
+ No
+
+
+
+
+ Property
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+
+ Hide-by-name-and-signature considers all of the parts of the signature, including custom modifiers, return types, parameter types, sentinels, and unmanaged calling conventions. This is a binary comparison.
+
+
+ For reflection, properties and events are hide-by-name-and-signature. If you have a property with both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and you will not be able to access the setter on the base class.
+
+
+ Custom attributes are not part of the common type system.
+
+
+ If the currentrepresents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the members of the class constraint, or the members ofif there is no class constraint.
+
+ For generic methods, do not include the type arguments in. For example, the C# code GetMember("MyMethod<int>") searches for a member with the text name "MyMethod<int>", rather than for a method named MyMethod that has one generic argument of type int.
+
+
+
+
+ Searches for the public members with the specified name.
+
+
+
+ An array ofobjects representing the public members with the specified name, if found; otherwise, an empty array.
+
+
+ The string containing the name of the public members to get.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MemberInfo[]
+
+
+
+
+
+
+
+ is.
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+
+ This method can be overridden by a derived class.
+ Members include properties, methods, fields, events, and so on.
+ Themethod does not return members in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which members are returned, because that order varies.
+ The followingfilter flags can be used to define which members to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Public to include public members in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public members (that is, private, internal, and protected members) in the search.
+
+
+ Specify BindingFlags.FlattenHierarchy to include public and protected static members up the hierarchy; private static members in inherited classes are not included.
+
+
+ The followingmodifier flags can be used to change how the search works:
+
+
+ BindingFlags.IgnoreCase to ignore the case of.
+
+
+ BindingFlags.DeclaredOnly to search only the members declared on the, not members that were simply inherited.
+
+
+ Seefor more information.
+ To get the class initializer (.cctor) using this method overload, you must specify ".cctor" for, and|(Orin Visual Basic) for. You can also get the class initializer using theproperty.
+ If the currentrepresents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the members of the class constraint, or the members ofif there is no class constraint.
+
+ For generic methods, do not include the type arguments in. For example, the C# code GetMember("MyMethod<int>") searches for a member with the text name "MyMethod<int>", rather than for a method named MyMethod that has one generic argument of type int.
+
+
+
+
+ Searches for the specified members, using the specified binding constraints.
+
+
+
+ An array ofobjects representing the public members with the specified name, if found; otherwise, an empty array.
+
+
+ The string containing the name of the members to get.
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ 1
+ Reflection
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MemberInfo[]
+
+
+
+
+
+
+
+
+
+ Members include properties, methods, fields, events, and so on.
+ Themethod does not return members in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which members are returned, because that order varies.
+ The followingfilter flags can be used to define which members to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Public to include public members in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public members (that is, private, internal, and protected members) in the search.
+
+
+ Specify BindingFlags.FlattenHierarchy to include public and protected static members up the hierarchy; private static members in inherited classes are not included.
+
+
+ The followingmodifier flags can be used to change how the search works:
+
+
+ BindingFlags.IgnoreCase to ignore the case of.
+
+
+ BindingFlags.DeclaredOnly to search only the members declared on the, not members that were simply inherited.
+
+
+ Seefor more information.
+ To get the class initializer (.cctor) using this method overload, you must specify ".cctor" for,for, and|(Orin Visual Basic) for. You can also get the class initializer using theproperty.
+ If the currentrepresents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the members of the class constraint, or the members ofif there is no class constraint.
+
+ For generic methods, do not include the type arguments in. For example, the C# code GetMember("MyMethod<int>") searches for a member with the text name "MyMethod<int>", rather than for a method named MyMethod that has one generic argument of type int.
+
+
+
+
+ Searches for the specified members of the specified member type, using the specified binding constraints.
+
+
+
+ An array ofobjects representing the public members with the specified name, if found; otherwise, an empty array.
+
+
+ The string containing the name of the members to get.
+
+ The value to search for.
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MemberInfo[]
+
+
+
+
+
+ Members include properties, methods, fields, events, and so on.
+ Themethod does not return members in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which members are returned, because that order varies.
+ This method overload calls themethod overload, with||(OrOrin Visual Basic). It will not find class initializers (.cctor). To find class initializers, use an overload that takes, and specify|(Orin Visual Basic). You can also get the class initializer using theproperty.
+ The following table shows what members of a base class are returned by the Get methods when reflecting on a type.
+
+
+
+
+ Member Type
+
+
+ Static
+
+
+ Non-Static
+
+
+
+
+
+ Constructor
+
+
+ No
+
+
+ No
+
+
+
+
+ Field
+
+
+ No
+
+
+ Yes. A field is always hide-by-name-and-signature.
+
+
+
+
+ Event
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+ Method
+
+
+ No
+
+
+ Yes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.
+
+
+
+
+ Nested Type
+
+
+ No
+
+
+ No
+
+
+
+
+ Property
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+
+ Hide-by-name-and-signature considers all of the parts of the signature, including custom modifiers, return types, parameter types, sentinels, and unmanaged calling conventions. This is a binary comparison.
+
+
+ For reflection, properties and events are hide-by-name-and-signature. If you have a property with both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and you will not be able to access the setter on the base class.
+
+
+ Custom attributes are not part of the common type system.
+
+
+ If the currentrepresents a constructed generic type, this method returns theobjects with the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the members of the class constraint, or the members ofif there is no class constraint.
+
+
+
+ Returns all the public members of the current.
+
+
+
+ An array ofobjects representing all the public members of the current.
+ -or-
+ An empty array of type, if the currentdoes not have public members.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MemberInfo[]
+
+
+
+
+
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+
+ Members include properties, methods, fields, events, and so on.
+ Themethod does not return members in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which members are returned, because that order varies.
+ The followingfilter flags can be used to define which members to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Public to include public members in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public members (that is, private, internal, and protected members) in the search. Only protected and internal members on base classes are returned; private members on base classes are not returned.
+
+
+ Specify BindingFlags.FlattenHierarchy to include public and protected static members up the hierarchy; private static members in inherited classes are not included.
+
+
+ The followingmodifier flags can be used to change how the search works:
+
+
+ BindingFlags.DeclaredOnly to search only the members declared on the, not members that were simply inherited.
+
+
+ Calling this method with only the Public flag or only the NonPublic flag will return the specified members and does not require any other flags.
+ Seefor more information.
+ To get the class initializer (.cctor) using this method overload, you must specify|(Orin Visual Basic). You can also get the class initializer using theproperty.
+ If the current T:System.Type represents a constructed generic type, this method returns theobjects with the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the members of the class constraint, or the members ofif there is no class constraint.
+
+
+
+ When overridden in a derived class, searches for the members defined for the current, using the specified binding constraints.
+
+
+
+ An array ofobjects representing all members defined for the currentthat match the specified binding constraints.
+ -or-
+ An empty array of type, if no members are defined for the current, or if none of the defined members match the binding constraints.
+
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MethodInfo
+
+
+
+
+
+ More than one method matching the specified criteria was found.
+
+ is.
+
+
+ The search foris case-sensitive. The search includes public static and public instance methods.
+
+ You cannot omit parameters when looking up constructors and methods. You can only omit parameters when invoking.
+
+ If the current T:System.Type represents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the methods of the class constraint, or the methods ofif there is no class constraint.
+
+ For generic methods, do not include the type arguments in. For example, the C# code GetMember("MyMethod<int>") searches for a member with the text name "MyMethod<int>", rather than for a method named MyMethod that has one generic argument of type int.
+
+
+
+
+ Searches for the public method with the specified name.
+
+
+
+ An object that represents the public method with the specified name, if found; otherwise, null.
+
+
+ The string containing the name of the public method to get.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MethodInfo
+
+
+
+
+
+
+ More than one method matching the specified criteria was found.
+
+ is.
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+
+ The followingfilter flags can be used to define which methods to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Public to include public methods in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public methods (that is, private, internal, and protected methods) in the search.
+
+
+ Specify BindingFlags.FlattenHierarchy to include public and protected static members up the hierarchy; private static members in inherited classes are not included.
+
+
+ The followingmodifier flags can be used to change how the search works:
+
+
+ BindingFlags.IgnoreCase to ignore the case of.
+
+
+ BindingFlags.DeclaredOnly to search only the methods declared on the, not methods that were simply inherited.
+
+
+ Seefor more information.
+
+ You cannot omit parameters when looking up constructors and methods. You can only omit parameters when invoking.
+
+ If the current T:System.Type represents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the methods of the class constraint, or the methods ofif there is no class constraint.
+
+ For generic methods, do not include the type arguments in. For example, the C# code GetMember("MyMethod<int>") searches for a member with the text name "MyMethod<int>", rather than for a method named MyMethod that has one generic argument of type int.
+
+
+
+
+ Searches for the specified method, using the specified binding constraints.
+
+
+
+ An object representing the method that matches the specified requirements, if found; otherwise, null.
+
+
+ The string containing the name of the method to get.
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MethodInfo
+
+
+
+
+
+
+ More than one method matching the specified criteria was found.
+
+ oris.
+ -or-
+ At least one of the elements inis.
+
+
+ has more than one dimension.
+
+
+
+ The search foris case-sensitive. The search includes public static and public instance methods.
+
+ You cannot omit parameters when looking up constructors and methods. You can only omit parameters when invoking.
+
+ If the current T:System.Type represents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the methods of the class constraint, or the methods ofif there is no class constraint.
+
+ Theparameter cannot include type arguments. For example, the C# code GetMethod("MyGenericMethod<int>") searches for a method with the text name "MyGenericMethod<int>", rather than for a method named MyGenericMethod that has one generic argument of type int. Instead, use GetMethod("MyGenericMethod") with the appropriate parameter in thearray.
+
+
+
+
+ Searches for the specified public method whose parameters match the specified argument types.
+
+
+
+ An object representing the public method whose parameters match the specified argument types, if found; otherwise, null.
+
+
+ The string containing the name of the public method to get.
+
+ An array ofobjects representing the number, order, and type of the parameters for the method to get.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MethodInfo
+
+
+
+
+
+
+
+ More than one method matching the specified criteria was found.
+
+ oris.
+ -or-
+ At least one of the elements inis.
+
+
+ has more than one dimension.
+
+
+
+ Although the default binder does not process(theparameter), you can use the abstractclass to write a custom binder that does process. ParameterModifier is only used when calling through COM interop, and only parameters that are passed by reference are handled.
+ The search foris case-sensitive. The search includes public static and public instance methods.
+
+ You cannot omit parameters when looking up constructors and methods. You can only omit parameters when invoking.
+
+ If the current T:System.Type represents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the methods of the class constraint, or the methods ofif there is no class constraint.
+
+ For generic methods, do not include the type arguments in. For example, the C# code GetMethod("MyMethod<int>") searches for a member with the text name "MyMethod<int>", rather than for a method named MyMethod that has one generic argument of type int. Instead, use GetMethod("MyMethod") with the appropriate parameter in thearray.
+
+
+
+
+ Searches for the specified public method whose parameters match the specified argument types and modifiers.
+
+
+
+ An object representing the public method that matches the specified requirements, if found; otherwise, null.
+
+
+ The string containing the name of the public method to get.
+
+ An array ofobjects representing the number, order, and type of the parameters for the method to get.
+
+ An array ofobjects representing the attributes associated with the corresponding element in thearray. To be only used when calling through COM interop, and only parameters that are passed by reference are handled. The default binder does not process this parameter.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MethodInfo
+
+
+
+
+
+
+
+
+
+ More than one method matching the specified criteria was found.
+
+ oris.
+ -or-
+ At least one of the elements inis.
+
+
+ has more than one dimension.
+
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+
+ Although the default binder does not process(theparameter), you can use the abstractclass to write a custom binder that does process. ParameterModifier is only used when calling through COM interop, and only parameters that are passed by reference are handled.
+ The followingfilter flags can be used to define which methods to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Public to include public methods in the search.
+
+
+ Specify BindingFlags.NonPublic to include nonpublic methods (that is, private, internal, and protected methods) in the search.
+
+
+ Specify BindingFlags.FlattenHierarchy to include public and protected static members up the hierarchy; private static members in inherited classes are not included.
+
+
+ The followingmodifier flags can be used to change how the search works:
+
+
+ BindingFlags.IgnoreCase to ignore the case of.
+
+
+ BindingFlags.DeclaredOnly to search only the methods declared on the, not methods that were simply inherited.
+
+
+ Seefor more information.
+
+ You cannot omit parameters when looking up constructors and methods. You can only omit parameters when invoking.
+
+ If the current T:System.Type represents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the methods of the class constraint, or the methods ofif there is no class constraint.
+
+ For generic methods, do not include the type arguments in. For example, the C# code GetMember("MyMethod<int>") searches for a member with the text name "MyMethod<int>", rather than for a method named MyMethod that has one generic argument of type int.
+
+
+
+
+ Searches for the specified method whose parameters match the specified argument types and modifiers, using the specified binding constraints.
+
+
+
+ An object representing the method that matches the specified requirements, if found; otherwise, null.
+
+
+ The string containing the name of the method to get.
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ An object that defines a set of properties and enables binding, which can involve selection of an overloaded method, coercion of argument types, and invocation of a member through reflection.
+
+ An array ofobjects representing the number, order, and type of the parameters for the method to get.
+
+ An array ofobjects representing the attributes associated with the corresponding element in thearray. To be only used when calling through COM interop, and only parameters that are passed by reference are handled. The default binder does not process this parameter.
+
+ 1
+ Reflection
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MethodInfo
+
+
+
+
+
+
+
+
+
+
+
+
+ Although the default binder does not process(theparameter), you can use the abstractclass to write a custom binder that does process. ParameterModifier is only used when calling through COM interop, and only parameters that are passed by reference are handled.
+ The following table shows what members of a base class are returned by the GetXXX methods when reflecting on a type.
+
+
+
+
+ Member Type
+
+
+ Static
+
+
+ Non-Static
+
+
+
+
+
+ Constructor
+
+
+ No
+
+
+ No
+
+
+
+
+ Field
+
+
+ No
+
+
+ Yes. A field is always hide-by-name-and-signature.
+
+
+
+
+ Event
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+ Method
+
+
+ No
+
+
+ Yes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.
+
+
+
+
+ Nested Type
+
+
+ No
+
+
+ No
+
+
+
+
+ Property
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+
+ Hide-by-name-and-signature considers all of the parts of the signature, including custom modifiers, return types, parameter types, sentinels, and unmanaged calling conventions. This is a binary comparison.
+
+
+ For reflection, properties and events are hide-by-name-and-signature. If you have a property with both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and you will not be able to access the setter on the base class.
+
+
+ Custom attributes are not part of the common type system.
+
+
+ The followingfilter flags can be used to define which methods to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Public to include public methods in the search.
+
+
+ Specify BindingFlags.NonPublic to include nonpublic methods (that is, private, internal, and protected methods) in the search.
+
+
+ Specify BindingFlags.FlattenHierarchy to include public and protected static members up the hierarchy; private static members in inherited classes are not included.
+
+
+ The followingmodifier flags can be used to change how the search works:
+
+
+ BindingFlags.IgnoreCase to ignore the case of.
+
+
+ BindingFlags.DeclaredOnly to search only the methods declared on the, not methods that were simply inherited.
+
+
+ Seefor more information.
+
+ You cannot omit parameters when looking up constructors and methods. You can only omit parameters when invoking.
+
+ If the current T:System.Type represents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the methods of the class constraint, or the methods ofif there is no class constraint.
+
+ For generic methods, do not include the type arguments in. For example, the C# code GetMember("MyMethod<int>") searches for a member with the text name "MyMethod<int>", rather than for a method named MyMethod that has one generic argument of type int.
+
+
+
+
+ Searches for the specified method whose parameters match the specified argument types and modifiers, using the specified binding constraints and the specified calling convention.
+
+
+
+ An object representing the method that matches the specified requirements, if found; otherwise, null.
+
+
+ The string containing the name of the method to get.
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ An object that defines a set of properties and enables binding, which can involve selection of an overloaded method, coercion of argument types, and invocation of a member through reflection.
+
+ The object that specifies the set of rules to use regarding the order and layout of arguments, how the return value is passed, what registers are used for arguments, and how the stack is cleaned up.
+
+ An array ofobjects representing the number, order, and type of the parameters for the method to get.
+
+ An array ofobjects representing the attributes associated with the corresponding element in thearray. To be only used when calling through COM interop, and only parameters that are passed by reference are handled. The default binder does not process this parameter.
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MethodInfo
+
+
+
+
+
+
+
+
+
+
+
+
+ Although the default binder does not process(theparameter), you can use the abstractclass to write a custom binder that does process. ParameterModifier is only used when calling through COM interop, and only parameters that are passed by reference are handled.
+ Ifis null, arguments are not matched.
+ The followingfilter flags can be used to define which methods to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Public to include public methods in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public methods (that is, private, internal, and protected methods) in the search.
+
+
+ Specify BindingFlags.FlattenHierarchy to include public and protected static members up the hierarchy; private static members in inherited classes are not included.
+
+
+ The followingmodifier flags can be used to change how the search works:
+
+
+ BindingFlags.IgnoreCase to ignore the case of.
+
+
+ BindingFlags.DeclaredOnly to search only the methods declared on the, not methods that were simply inherited.
+
+
+ Seefor more information.
+
+
+
+ When overridden in a derived class, searches for the specified method whose parameters match the specified argument types and modifiers, using the specified binding constraints and the specified calling convention.
+
+
+
+ An object representing the method that matches the specified requirements, if found; otherwise, null.
+
+
+ The string containing the name of the method to get.
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ An object that defines a set of properties and enables binding, which can involve selection of an overloaded method, coercion of argument types, and invocation of a member through reflection.
+
+ The object that specifies the set of rules to use regarding the order and layout of arguments, how the return value is passed, what registers are used for arguments, and what process cleans up the stack.
+
+ An array ofobjects representing the number, order, and type of the parameters for the method to get.
+
+ An array ofobjects representing the attributes associated with the corresponding element in thearray. The default binder does not process this parameter.
+
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MethodInfo[]
+
+
+
+
+
+ Themethod does not return methods in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which methods are returned, because that order varies.
+ Constructors are not included in the array of methods returned by this call. Make a separate call to GetConstructors() to get the constructor methods.
+ The following table shows what members of a base class are returned by the Get methods when reflecting on a type.
+
+
+
+
+ Member Type
+
+
+ Static
+
+
+ Non-Static
+
+
+
+
+
+ Constructor
+
+
+ No
+
+
+ No
+
+
+
+
+ Field
+
+
+ No
+
+
+ Yes. A field is always hide-by-name-and-signature.
+
+
+
+
+ Event
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+ Method
+
+
+ No
+
+
+ Yes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.
+
+
+
+
+ Nested Type
+
+
+ No
+
+
+ No
+
+
+
+
+ Property
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+
+ Hide-by-name-and-signature considers all of the parts of the signature, including custom modifiers, return types, parameter types, sentinels, and unmanaged calling conventions. This is a binary comparison.
+
+
+ For reflection, properties and events are hide-by-name-and-signature. If you have a property with both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and you will not be able to access the setter on the base class.
+
+
+ Custom attributes are not part of the common type system.
+
+
+
+ You cannot omit parameters when looking up constructors and methods. You can only omit parameters when invoking.
+
+ If the current T:System.Type represents a constructed generic type, this method returns theobjects with the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the methods of the class constraint, or the methods ofif there is no class constraint.
+
+
+
+ Returns all the public methods of the current.
+
+
+
+ An array ofobjects representing all the public methods defined for the current.
+ -or-
+ An empty array of type, if no public methods are defined for the current.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MethodInfo[]
+
+
+
+
+
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+
+ Themethod does not return methods in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which methods are returned, because that order varies.
+ The followingfilter flags can be used to define which methods to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Public to include public methods in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public methods (that is, private, internal, and protected methods) in the search. Only protected and internal methods on base classes are returned; private methods on base classes are not returned.
+
+
+ Specify BindingFlags.FlattenHierarchy to include public and protected static members up the hierarchy; private static members in inherited classes are not included.
+
+
+ The followingmodifier flags can be used to change how the search works:
+
+
+ BindingFlags.DeclaredOnly to search only the methods declared on the, not methods that were simply inherited.
+
+
+ Seefor more information.
+
+ You cannot omit parameters when looking up constructors and methods. You can only omit parameters when invoking.
+
+ If the current T:System.Type represents a constructed generic type, this method returns theobjects with the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the methods of the class constraint, or the methods ofif there is no class constraint.
+
+
+
+ When overridden in a derived class, searches for the methods defined for the current, using the specified binding constraints.
+
+
+
+ An array ofobjects representing all methods defined for the currentthat match the specified binding constraints.
+ -or-
+ An empty array of type, if no methods are defined for the current, or if none of the defined methods match the binding constraints.
+
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+ is.
+
+
+ The search foris case-sensitive.
+ Use the simple name of the nested class for. Do not qualify it with the name of the outer class. For a generic nested class, use the mangled name — that is, append a grave accent and the number of generic arguments. For example, use the string "Inner`1" to get the generic nested class Inner<T> (Inner(Of T) in Visual Basic). Do not include language-specific syntax for type parameters.
+ The following table shows what members of a base class are returned by the Get methods when reflecting on a type.
+
+
+
+
+ Member Type
+
+
+ Static
+
+
+ Non-Static
+
+
+
+
+
+ Constructor
+
+
+ No
+
+
+ No
+
+
+
+
+ Field
+
+
+ No
+
+
+ Yes. A field is always hide-by-name-and-signature.
+
+
+
+
+ Event
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+ Method
+
+
+ No
+
+
+ Yes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.
+
+
+
+
+ Nested Type
+
+
+ No
+
+
+ No
+
+
+
+
+ Property
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+
+ Hide-by-name-and-signature considers all of the parts of the signature, including custom modifiers, return types, parameter types, sentinels, and unmanaged calling conventions. This is a binary comparison.
+
+
+ For reflection, properties and events are hide-by-name-and-signature. If you have a property with both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and you will not be able to access the setter on the base class.
+
+
+ Custom attributes are not part of the common type system.
+
+
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the nested types of the class constraint.
+ If a nested type is generic, this method returns its generic type definition. This is true even if the enclosing generic type is a closed constructed type.
+
+ If the currentrepresents a generic type defined in C#, Visual Basic, or C++, its nested types are all generic even if they have no generic parameters of their own. This is not necessarily true of nested types defined in dynamic assemblies or compiled with the
+ MSIL Assembler (Ilasm.exe)
+ .
+
+ For information on nested generic types, and on constructing nested generic types from their generic type definitions, see.
+
+
+
+ Searches for the public nested type with the specified name.
+
+
+
+ An object representing the public nested type with the specified name, if found; otherwise, null.
+
+
+ The string containing the name of the nested type to get.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+
+ is.
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+
+ Use the simple name of the nested class for. Do not qualify it with the name of the outer class. For a generic nested class, use the mangled name — that is, append a grave accent and the number of generic parameters. For example, use the string "Inner`1" to get the generic nested class Inner<T> (Inner(Of T) in Visual Basic). Do not include language-specific syntax for type parameters.
+ The followingfilter flags can be used to define which nested types to include in the search:
+
+
+ You must specify either BindingFlags.Public or BindingFlags.NonPublic to get a return.
+
+
+ Specify BindingFlags.Public to include public nested types in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public nested types (that is, private, internal, and protected nested types) in the search.
+
+
+ This method returns only the nested types of the current type. It does not search the base classes of the current type. To find types that are nested in base classes, you must walk the inheritance hierarchy, callingat each level.
+ BindingFlags.Instance and BindingFlags.Static are ignored.
+ Calling this method with only theflag or only theflag will return the specified nested types and does not require any other flags.
+ Seefor more information.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the nested types of the class constraint.
+ If a nested type is generic, this method returns its generic type definition. This is true even if the enclosing generic type is a closed constructed type.
+
+ If the currentrepresents a generic type defined in C#, Visual Basic, or C++, its nested types are all generic even if they have no generic parameters of their own. This is not necessarily true of nested types defined in dynamic assemblies or compiled with the
+ MSIL Assembler (Ilasm.exe)
+ .
+
+ For information on nested generic types, and on constructing nested generic types from their generic type definitions, see.
+
+
+
+ When overridden in a derived class, searches for the specified nested type, using the specified binding constraints.
+
+
+
+ An object representing the nested type that matches the specified requirements, if found; otherwise, null.
+
+
+ The string containing the name of the nested type to get.
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type[]
+
+
+
+
+
+ Themethod does not return types in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which types are returned, because that order varies.
+ Only the public types immediately nested in the current type are returned; the search is not recursive.
+ The following table shows what members of a base class are returned by the Get methods when reflecting on a type.
+
+
+
+
+ Member Type
+
+
+ Static
+
+
+ Non-Static
+
+
+
+
+
+ Constructor
+
+
+ No
+
+
+ No
+
+
+
+
+ Field
+
+
+ No
+
+
+ Yes. A field is always hide-by-name-and-signature.
+
+
+
+
+ Event
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+ Method
+
+
+ No
+
+
+ Yes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.
+
+
+
+
+ Nested Type
+
+
+ No
+
+
+ No
+
+
+
+
+ Property
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+
+ Hide-by-name-and-signature considers all of the parts of the signature, including custom modifiers, return types, parameter types, sentinels, and unmanaged calling conventions. This is a binary comparison.
+
+
+ For reflection, properties and events are hide-by-name-and-signature. If you have a property with both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and you will not be able to access the setter on the base class.
+
+
+ Custom attributes are not part of the common type system.
+
+
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the nested types of the class constraint.
+ If a nested type is generic, this method returns its generic type definition. This is true even if the enclosing generic type is a closed constructed type.
+
+ If the currentrepresents a generic type defined in C#, Visual Basic, or C++, its nested types are all generic even if they have no generic parameters of their own. This is not necessarily true of nested types defined in dynamic assemblies or compiled with the
+ MSIL Assembler (Ilasm.exe)
+ .
+
+ For information on nested generic types, and on constructing nested generic types from their generic type definitions, see.
+
+
+
+ Returns the public types nested in the current.
+
+
+
+ An array ofobjects representing the public types nested in the current(the search is not recursive), or an empty array of typeif no public types are nested in the current.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type[]
+
+
+
+
+
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+
+ The search for nested types is not recursive.
+ Themethod does not return types in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which types are returned, because that order varies.
+ The followingfilter flags can be used to define which nested types to include in the search:
+
+
+ You must specify either BindingFlags.Public or BindingFlags.NonPublic to get a return.
+
+
+ Specify BindingFlags.Public to include public nested types in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public nested types (that is, private, internal, and protected nested types) in the search.
+
+
+ This method returns only the nested types of the current type. It does not search the base classes of the current type. To find types that are nested in base classes, you must walk the inheritance hierarchy, callingat each level.
+ BindingFlags.Instance and BindingFlags.Static are ignored.
+ Calling this method with only theflag or only theflag will return the specified nested types and does not require any other flags.
+ Seefor more information.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the nested types of the class constraint.
+ If a nested type is generic, this method returns its generic type definition. This is true even if the enclosing generic type is a closed constructed type.
+
+ If the currentrepresents a generic type defined in C#, Visual Basic, or C++, its nested types are all generic even if they have no generic parameters of their own. This is not necessarily true of nested types defined in dynamic assemblies or compiled with the
+ MSIL Assembler (Ilasm.exe)
+ .
+
+ For information on nested generic types, and on constructing nested generic types from their generic type definitions, see.
+
+
+
+ When overridden in a derived class, searches for the types nested in the current, using the specified binding constraints.
+
+
+
+ An array ofobjects representing all the types nested in the currentthat match the specified binding constraints (the search is not recursive), or an empty array of type, if no nested types are found that match the binding constraints.
+
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.PropertyInfo[]
+
+
+
+
+
+ A property is considered public to reflection if it has at least one accessor that is public. Otherwise the property is considered private, and you must use||(in Visual Basic, combine the values using Or) to get it.
+ Themethod does not return properties in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which properties are returned, because that order varies.
+ The following table shows what members of a base class are returned by the Get methods when reflecting on a type.
+
+
+
+
+ Member Type
+
+
+ Static
+
+
+ Non-Static
+
+
+
+
+
+ Constructor
+
+
+ No
+
+
+ No
+
+
+
+
+ Field
+
+
+ No
+
+
+ Yes. A field is always hide-by-name-and-signature.
+
+
+
+
+ Event
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+ Method
+
+
+ No
+
+
+ Yes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.
+
+
+
+
+ Nested Type
+
+
+ No
+
+
+ No
+
+
+
+
+ Property
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+
+ Hide-by-name-and-signature considers all of the parts of the signature, including custom modifiers, return types, parameter types, sentinels, and unmanaged calling conventions. This is a binary comparison.
+
+
+ For reflection, properties and events are hide-by-name-and-signature. If you have a property with both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and you will not be able to access the setter on the base class.
+
+
+ Custom attributes are not part of the common type system.
+
+
+ If the current T:System.Type represents a constructed generic type, this method returns theobjects with the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the properties of the class constraint.
+
+
+
+ Returns all the public properties of the current.
+
+
+
+ An array ofobjects representing all public properties of the current.
+ -or-
+ An empty array of type, if the currentdoes not have public properties.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.PropertyInfo[]
+
+
+
+
+
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+
+ A property is considered public to reflection if it has at least one accessor that is public. Otherwise the property is considered private, and you must use||(in Visual Basic, combine the values using Or) to get it.
+ Themethod does not return properties in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which properties are returned, because that order varies.
+ The followingfilter flags can be used to define which nested types to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Public to include public properties in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public properties (that is, private, internal, and protected properties) in the search. Only protected and internal properties on base classes are returned; private properties on base classes are not returned.
+
+
+ Specify BindingFlags.FlattenHierarchy to include public and protected static members up the hierarchy; private static members in inherited classes are not included.
+
+
+ The followingmodifier flags can be used to change how the search works:
+
+
+ BindingFlags.DeclaredOnly to search only the properties declared on the, not properties that were simply inherited.
+
+
+ Seefor more information.
+ A property is considered public to reflection if it has at least one accessor that is public. Otherwise the property is considered private, and you must use||(in Visual Basic, combine the values using Or) to get it.
+ If the current T:System.Type represents a constructed generic type, this method returns theobjects with the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the properties of the class constraint.
+
+
+
+ When overridden in a derived class, searches for the properties of the current, using the specified binding constraints.
+
+
+
+ An array ofobjects representing all properties of the currentthat match the specified binding constraints.
+ -or-
+ An empty array of type, if the currentdoes not have properties, or if none of the properties match the binding constraints.
+
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.PropertyInfo
+
+
+
+
+
+ More than one property matching the specified criteria was found.
+
+ is.
+
+
+
+ The search foris case-sensitive. The search includes public static and public instance properties.
+ A property is considered public to reflection if it has at least one accessor that is public. Otherwise the property is considered private, and you must use||(in Visual Basic, combine the values using Or) to get it.
+ If the currentrepresents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the properties of the class constraint.
+ Situations in whichoccurs include the following:
+
+
+ A type contains two indexed properties that have the same name but different numbers of parameters. To resolve the ambiguity, use an overload of themethod that specifies parameter types.
+
+
+ A derived type declares a property that hides an inherited property with the same name, by using the new modifier (Shadows in Visual Basic). To resolve the ambiguity, use themethod overload and includeto restrict the search to members that are not inherited.
+
+
+
+
Indexers and Default Properties
+
+ vbprvblong, csprcslong, and vcprvclong have simplified syntax for accessing indexed properties and allow one indexed property to be a default for its type. For example, if the variable myList refers to an, the syntax myList[3] (myList(3) in Visual Basic) retrieves the element with the index of 3. You can overload the property.
+ In C#, this feature is called an indexer and cannot be refered to by name. By default, a C# indexer appears in metadata as an indexed property named "Item". However, a class library developer can use theattribute to change the name of the indexer in the metadata. For example, theclass has an indexer named. Indexed properties created using languages other than C# can have names other than Item, as well.
+ To determine whether a type has a default property, use themethod to test for theattribute. If the type has, theproperty returns the name of the default property.
+
+
+
+ Searches for the public property with the specified name.
+
+
+
+ An object representing the public property with the specified name, if found; otherwise, null.
+
+
+ The string containing the name of the public property to get.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.PropertyInfo
+
+
+
+
+
+
+ More than one property matching the specified criteria was found.
+
+ is.
+
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+
+ A property is considered public to reflection if it has at least one accessor that is public. Otherwise the property is considered private, and you must use||(in Visual Basic, combine the values using Or) to get it.
+ The followingfilter flags can be used to define which properties to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Public to include public properties in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public properties (that is, private, internal, and protected properties) in the search.
+
+
+ Specify BindingFlags.FlattenHierarchy to include public and protected static members up the hierarchy; private static members in inherited classes are not included.
+
+
+ The followingmodifier flags can be used to change how the search works:
+
+
+ BindingFlags.IgnoreCase to ignore the case of.
+
+
+ BindingFlags.DeclaredOnly to search only the properties declared on the, not properties that were simply inherited.
+
+
+ Seefor more information.
+ If the currentrepresents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the properties of the class constraint.
+ Situations in whichoccurs include the following:
+
+
+ A type contains two indexed properties that have the same name but different numbers of parameters. To resolve the ambiguity, use an overload of themethod that specifies parameter types.
+
+
+ A derived type declares a property that hides an inherited property with the same name, using the new modifier (Shadows in Visual Basic). To resolve the ambiguity, includeto restrict the search to members that are not inherited.
+
+
+
+
Indexers and Default Properties
+
+ vbprvblong, csprcslong, and vcprvclong have simplified syntax for accessing indexed properties and allow one indexed property to be a default for its type. For example, if the variable myList refers to an, the syntax myList[3] (myList(3) in Visual Basic) retrieves the element with the index of 3. You can overload the property.
+ In C#, this feature is called an indexer and cannot be refered to by name. By default, a C# indexer appears in metadata as an indexed property named "Item". However, a class library developer can use theattribute to change the name of the indexer in the metadata. For example, theclass has an indexer named. Indexed properties created using languages other than C# can have names other than Item, as well.
+ To determine whether a type has a default property, use themethod to test for theattribute. If the type has, theproperty returns the name of the default property.
+
+
+
+ Searches for the specified property, using the specified binding constraints.
+
+
+
+ An object representing the property that matches the specified requirements, if found; otherwise, null.
+
+
+ The string containing the name of the property to get.
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.PropertyInfo
+
+
+
+
+
+
+ More than one property matching the specified criteria was found.
+
+ is.
+
+
+ The return type of the property.
+
+
+ A property is considered public to reflection if it has at least one accessor that is public. Otherwise the property is considered private, and you must use||(in Visual Basic, combine the values using Or) to get it.
+ The search foris case-sensitive. The search includes public static and public instance properties.
+ If the currentrepresents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the properties of the class constraint.
+
+
Indexers and Default Properties
+
+ vbprvblong, csprcslong, and vcprvclong have simplified syntax for accessing indexed properties and allow one indexed property to be a default for its type. For example, if the variable myList refers to an, the syntax myList[3] (myList(3) in Visual Basic) retrieves the element with the index of 3. You can overload the property.
+ In C#, this feature is called an indexer and cannot be refered to by name. By default, a C# indexer appears in metadata as an indexed property named "Item". However, a class library developer can use theattribute to change the name of the indexer in the metadata. For example, theclass has an indexer named. Indexed properties created using languages other than C# can have names other than Item, as well.
+ To determine whether a type has a default property, use themethod to test for theattribute. If the type has, theproperty returns the name of the default property.
+
+
+
+ Searches for the public property with the specified name and return type.
+
+
+
+ An object representing the public property with the specified name, if found; otherwise, null.
+
+
+ The string containing the name of the public property to get.
+
+ The return type of the property.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.PropertyInfo
+
+
+
+
+
+
+ More than one property matching the specified criteria was found.
+
+
+ oris, or at least one of the elements inis.
+
+
+ has more than one dimension.
+
+
+
+ A property is considered public to reflection if it has at least one accessor that is public. Otherwise the property is considered private, and you must use||(in Visual Basic, combine the values using Or) to get it.
+ The search foris case-sensitive. The search includes public static and public instance properties.
+ If the currentrepresents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the properties of the class constraint.
+
+
Indexers and Default Properties
+
+ vbprvblong, csprcslong, and vcprvclong have simplified syntax for accessing indexed properties and allow one indexed property to be a default for its type. For example, if the variable myList refers to an, the syntax myList[3] (myList(3) in Visual Basic) retrieves the element with the index of 3. You can overload the property.
+ In C#, this feature is called an indexer and cannot be refered to by name. By default, a C# indexer appears in metadata as an indexed property named "Item". However, a class library developer can use theattribute to change the name of the indexer in the metadata. For example, theclass has an indexer named. Indexed properties created using languages other than C# can have names other than Item, as well.
+ To determine whether a type has a default property, use themethod to test for theattribute. If the type has, theproperty returns the name of the default property.
+
+
+
+ Searches for the specified public property whose parameters match the specified argument types.
+
+
+
+ An object representing the public property whose parameters match the specified argument types, if found; otherwise, null.
+
+
+ The string containing the name of the public property to get.
+
+ An array ofobjects representing the number, order, and type of the parameters for the indexed property to get.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.PropertyInfo
+
+
+
+
+
+
+
+ More than one property matching the specified criteria was found.
+
+
+ oris, or at least one of the elements inis.
+
+
+ has more than one dimension.
+
+ The return type of the property.
+
+
+ A property is considered public to reflection if it has at least one accessor that is public. Otherwise the property is considered private, and you must use||(in Visual Basic, combine the values using Or) to get it.
+ The search foris case-sensitive. The search includes public static and public instance properties.
+ If the currentrepresents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the properties of the class constraint.
+
+
Indexers and Default Properties
+
+ vbprvblong, csprcslong, and vcprvclong have simplified syntax for accessing indexed properties and allow one indexed property to be a default for its type. For example, if the variable myList refers to an, the syntax myList[3] (myList(3) in Visual Basic) retrieves the element with the index of 3. You can overload the property.
+ In C#, this feature is called an indexer and cannot be refered to by name. By default, a C# indexer appears in metadata as an indexed property named "Item". However, a class library developer can use theattribute to change the name of the indexer in the metadata. For example, theclass has an indexer named. Indexed properties created using languages other than C# can have names other than Item, as well.
+ To determine whether a type has a default property, use themethod to test for theattribute. If the type has, theproperty returns the name of the default property.
+
+
+
+ Searches for the specified public property whose parameters match the specified argument types.
+
+
+
+ An object representing the public property whose parameters match the specified argument types, if found; otherwise, null.
+
+
+ The string containing the name of the public property to get.
+
+ The return type of the property.
+
+ An array ofobjects representing the number, order, and type of the parameters for the indexed property to get.
+
+ 1
+ Reflection
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.PropertyInfo
+
+
+
+
+
+
+
+
+
+
+ A property is considered public to reflection if it has at least one accessor that is public. Otherwise the property is considered private, and you must use||(in Visual Basic, combine the values using Or) to get it.
+ Although the default binder does not process(theparameter), you can use the abstractclass to write a custom binder that does process. ParameterModifier is only used when calling through COM interop, and only parameters that are passed by reference are handled.
+ The search foris case-sensitive. The search includes public static and public instance properties.
+ If the currentrepresents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the properties of the class constraint.
+
+
Indexers and Default Properties
+
+ vbprvblong, csprcslong, and vcprvclong have simplified syntax for accessing indexed properties and allow one indexed property to be a default for its type. For example, if the variable myList refers to an, the syntax myList[3] (myList(3) in Visual Basic) retrieves the element with the index of 3. You can overload the property.
+ In C#, this feature is called an indexer and cannot be refered to by name. By default, a C# indexer appears in metadata as an indexed property named "Item". However, a class library developer can use theattribute to change the name of the indexer in the metadata. For example, theclass has an indexer named. Indexed properties created using languages other than C# can have names other than Item, as well.
+ To determine whether a type has a default property, use themethod to test for theattribute. If the type has, theproperty returns the name of the default property.
+
+
+
+ Searches for the specified public property whose parameters match the specified argument types and modifiers.
+
+
+
+ An object representing the public property that matches the specified requirements, if found; otherwise, null.
+
+
+ The string containing the name of the public property to get.
+
+ The return type of the property.
+
+ An array ofobjects representing the number, order, and type of the parameters for the indexed property to get.
+
+ An array ofobjects representing the attributes associated with the corresponding element in thearray. The default binder does not process this parameter.
+
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.PropertyInfo
+
+
+
+
+
+
+
+
+
+
+ More than one property matching the specified criteria was found.
+
+
+ oris, or at least one of the elements inis.
+
+
+ has more than one dimension.
+
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+ The return type of the property.
+
+
+ A property is considered public to reflection if it has at least one accessor that is public. Otherwise the property is considered private, and you must use||(in Visual Basic, combine the values using Or) to get it.
+ Although the default binder does not process(theparameter), you can use the abstractclass to write a custom binder that does process. ParameterModifier is only used when calling through COM interop, and only parameters that are passed by reference are handled.
+ The following table shows what members of a base class are returned by the Get methods when reflecting on a type.
+
+
+
+
+ Member Type
+
+
+ Static
+
+
+ Non-Static
+
+
+
+
+
+ Constructor
+
+
+ No
+
+
+ No
+
+
+
+
+ Field
+
+
+ No
+
+
+ Yes. A field is always hide-by-name-and-signature.
+
+
+
+
+ Event
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+ Method
+
+
+ No
+
+
+ Yes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.
+
+
+
+
+ Nested Type
+
+
+ No
+
+
+ No
+
+
+
+
+ Property
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+
+ Hide-by-name-and-signature considers all of the parts of the signature, including custom modifiers, return types, parameter types, sentinels, and unmanaged calling conventions. This is a binary comparison.
+
+
+ For reflection, properties and events are hide-by-name-and-signature. If you have a property with both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and you will not be able to access the setter on the base class.
+
+
+ Custom attributes are not part of the common type system.
+
+
+ The followingfilter flags can be used to define which properties to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Public to include public properties in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public properties (that is, private, internal, and protected properties) in the search.
+
+
+ Specify BindingFlags.FlattenHierarchy to include public and protected static members up the hierarchy; private static members in inherited classes are not included.
+
+
+ The followingmodifier flags can be used to change how the search works:
+
+
+ BindingFlags.IgnoreCase to ignore the case of.
+
+
+ BindingFlags.DeclaredOnly to search only the properties declared on the, not properties that were simply inherited.
+
+
+ Seefor more information.
+ If the currentrepresents a constructed generic type, this method returns thewith the type parameters replaced by the appropriate type arguments.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this method searches the properties of the class constraint.
+
+
Indexers and Default Properties
+
+ vbprvblong, csprcslong, and vcprvclong have simplified syntax for accessing indexed properties and allow one indexed property to be a default for its type. For example, if the variable myList refers to an, the syntax myList[3] (myList(3) in Visual Basic) retrieves the element with the index of 3. You can overload the property.
+ In C#, this feature is called an indexer and cannot be refered to by name. By default, a C# indexer appears in metadata as an indexed property named "Item". However, a class library developer can use theattribute to change the name of the indexer in the metadata. For example, theclass has an indexer named. Indexed properties created using languages other than C# can have names other than Item, as well.
+ To determine whether a type has a default property, use themethod to test for theattribute. If the type has, theproperty returns the name of the default property.
+
+
+
+ Searches for the specified property whose parameters match the specified argument types and modifiers, using the specified binding constraints.
+
+
+
+ An object representing the property that matches the specified requirements, if found; otherwise, null.
+
+
+ The string containing the name of the property to get.
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ An object that defines a set of properties and enables binding, which can involve selection of an overloaded method, coercion of argument types, and invocation of a member through reflection.
+
+ The return type of the property.
+
+ An array ofobjects representing the number, order, and type of the parameters for the indexed property to get.
+
+ An array ofobjects representing the attributes associated with the corresponding element in thearray. The default binder does not process this parameter.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.PropertyInfo
+
+
+
+
+
+
+
+
+
+
+ More than one property matching the specified criteria was found.
+
+
+ oris, or at least one of the elements inis.
+
+
+ has more than one dimension.
+
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+ The return type of the property.
+
+
+ Although the default binder does not process(theparameter), you can use the abstractclass to write a custom binder that does process. ParameterModifier is only used when calling through COM interop, and only parameters that are passed by reference are handled.
+ The followingfilter flags can be used to define which properties to include in the search:
+
+
+ You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
+
+
+ Specify BindingFlags.Public to include public properties in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public properties (that is, private, internal, and protected properties) in the search.
+
+
+ Specify BindingFlags.FlattenHierarchy to include public and protected static members up the hierarchy; private static members in inherited classes are not included.
+
+
+ The followingmodifier flags can be used to change how the search works:
+
+
+ BindingFlags.IgnoreCase to ignore the case of.
+
+
+ BindingFlags.DeclaredOnly to search only the properties declared on the, not properties that were simply inherited.
+
+
+ Seefor more information.
+
+
+
+ When overridden in a derived class, searches for the specified property whose parameters match the specified argument types and modifiers, using the specified binding constraints.
+
+
+
+ An object representing the property that matches the specified requirements, if found; otherwise, null.
+
+
+ The string containing the name of the property to get.
+
+ A bitmask comprised of one or morethat specify how the search is conducted.
+
+ An object that defines a set of properties and enables binding, which can involve selection of an overloaded member, coercion of argument types, and invocation of a member through reflection.
+
+ The return type of the property.
+
+ An array ofobjects representing the number, order, and type of the parameters for the indexed property to get.
+
+ An array ofobjects representing the attributes associated with the corresponding element in thearray. The default binder does not process this parameter.
+
+ 1
+ Reflection
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+ To be added.
+
+
+ Gets the current.
+
+
+
+ The current.
+
+
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+ is.
+ A type initializer was invoked and threw an exception.
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+
+ You can use themethod to obtain aobject for a type in another assembly, if the you know its namespace-qualified name.causes loading of the assembly specified in. You can also load an assembly using themethod, and then use theormethods of theclass to getobjects. If a type is in an assembly known to your program at compile time, it is more efficient to use typeof in C#,in Visual Basic, or typeid in C++.
+ GetType only works on assemblies loaded from disk. If you call GetType to look up a type defined in a dynamic assembly defined using theservices, you might get inconsistent behavior. The behavior depends on whether the dynamic assembly is persistent, that is, created using the RunAndSave or Save access modes of theenumeration. If the dynamic assembly is persistent and has been written to disk before GetType is called, the loader finds the saved assembly on disk, loads that assembly, and retrieves the type from that assembly. If the assembly has not been saved to disk when GetType is called, the method returns null. GetType does not understand transient dynamic assemblies; therefore, calling GetType to retrieve a type in a transient dynamic assembly returns null.
+ To use GetType on a dynamic module, subscribe to theevent and call GetType before saving. Otherwise, you will get two copies of the assembly in memory.
+ The following table shows what members of a base class are returned by the Get methods when reflecting on a type.
+
+
+
+
+ Member Type
+
+
+ Static
+
+
+ Non-Static
+
+
+
+
+
+ Constructor
+
+
+ No
+
+
+ No
+
+
+
+
+ Field
+
+
+ No
+
+
+ Yes. A field is always hide-by-name-and-signature.
+
+
+
+
+ Event
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+ Method
+
+
+ No
+
+
+ Yes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.
+
+
+
+
+ Nested Type
+
+
+ No
+
+
+ No
+
+
+
+
+ Property
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+
+ Hide-by-name-and-signature considers all of the parts of the signature, including custom modifiers, return types, parameter types, sentinels, and unmanaged calling conventions. This is a binary comparison.
+
+
+ For reflection, properties and events are hide-by-name-and-signature. If you have a property with both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and you will not be able to access the setter on the base class.
+
+
+ Custom attributes are not part of the common type system.
+
+
+ Arrays or COM types are not searched for unless they have already been loaded into the table of available classes.
+
+ can be the type name qualified by its namespace or an assembly-qualified name that includes an assembly name specification. See.
+ Ifincludes the namespace but not the assembly name, this method searches only the calling object's assembly and Mscorlib.dll, in that order. If typeName is fully qualified with the partial or complete assembly name, this method searches in the specified assembly. If the assembly has a strong name, a complete assembly name is required.
+ Theproperty returns a fully qualified type name including nested types, the assembly name, and generic type arguments. All compilers that support the common language runtime will emit the simple name of a nested class, and reflection constructs a mangled name when queried, in accordance with the following conventions.
+
+ In the .NET Framework version 2.0, processor architecture is added to assembly identity, and can be specified as part of assembly name strings. For example, "ProcessorArchitecture=msil". However, it is not included in the string returned by theproperty, for compatibility reasons. You can also load types by creating anobject and passing it to an appropriate overload of themethod. You can then use themethod to load types from the assembly. See also.
+
+
+
+
+
+ Delimiter
+
+
+ Meaning
+
+
+
+
+
+ Backslash (\)
+
+
+ Escape character.
+
+
+
+
+ Backtick (`)
+
+
+ Precedes one or more digits representing the number of type parameters, located at the end of the name of a generic type.
+
+
+
+
+ Brackets ([])
+
+
+ Enclose a generic type argument list, for a constructed generic type; within a type argument list, enclose an assembly-qualified type.
+
+
+
+
+ Comma (,)
+
+
+ Precedes the Assembly name.
+
+
+
+
+ Period (.)
+
+
+ Denotes namespace identifiers.
+
+
+
+
+ Plus sign (+)
+
+
+ Precedes a nested class.
+
+
+
+ For example, the fully qualified name for a class might look like this:
+ TopNamespace.SubNameSpace.ContainingClass+NestedClass,MyAssembly
+ If the namespace were TopNamespace.Sub+Namespace, then the string would have to precede the plus sign (+) with an escape character (\) to prevent it from being interpreted as a nesting separator. Reflection emits this string as follows:
+ TopNamespace.Sub\+Namespace.ContainingClass+NestedClass,MyAssembly
+ A "++" becomes "\+\+", and a "\" becomes "\\".
+ This qualified name can be persisted and later used to load the. To search for and load a, useeither with the type name only or with the assembly qualified type name.with the type name only will look for thein the caller's assembly and then in the System assembly.with the assembly qualified type name will look for thein any assembly.
+ Type names may include trailing characters that denote additional information about the type, such as whether the type is a reference type, a pointer type or an array type. To retrieve the type name without these trailing characters, use t.GetElementType().ToString(), whereis the type.
+ Spaces are relevant in all type name components except the assembly name. In the assembly name, spaces before the ',' separator are relevant, but spaces after the ',' separator are ignored.
+ The name of a generic type ends with a backtick (`) followed by digits representing the number of generic type arguments. The purpose of this name mangling is to allow compilers to support generic types with the same name but with different numbers of type parameters, occurring in the same scope. For example, reflection returns the mangled names Tuple`1 and Tuple`2 from the generic methods Tuple(Of T) and Tuple(Of T0, T1) in Visual Basic, or Tuple<T> and Tuple<T0, T1> in Visual C#.
+ For generic types, the type argument list is enclosed in brackets, and the type arguments are separated by commas. For example, a generichas two type parameters. Aof MyType with keys of typemight be represented as follows:
+ System.Collections.Generic.Dictionary`2[System.String,MyType]
+ To specify an assembly-qualified type within a type argument list, enclose the assembly-qualified type within brackets. Otherwise, the commas that separate the parts of the assembly-qualified name are interpreted as delimiting additional type arguments. For example, aof MyType from MyAssembly.dll, with keys of type, might be specified as follows:
+ Type.GetType("System.Collections.Generic.Dictionary`2[System.String,[MyType,MyAssembly]]")
+
+ An assembly-qualified type can be enclosed in brackets only when it appears within a type parameter list. The rules for searching assemblies for qualified and unqualified types in type parameter lists are the same as the rules for qualified and unqualified nongeneric types.
+
+ Nullable types are a special case of generic types. For example, a nullableis represented by the string "System.Nullable`1[System.Int32]".
+
+ In C#, C++, and Visual Basic you can also get nullable types using type operators. For example, the nullabletype is returned by typeof(Nullable<bool>) in C#, by Nullable<Boolean>::typeid in C++, and by GetType(Nullable(Of Boolean)) in Visual Basic.
+
+ The following table shows the syntax you use with GetType for various types.
+
+
+
+
+ To Get
+
+
+ Use
+
+
+
+
+
+ A nullable
+
+
+ Type.GetType("System.Nullable`1[System.Int32]")
+
+
+
+
+ An unmanaged pointer to MyType
+
+
+ Type.GetType("MyType*")
+
+
+
+
+ An unmanaged pointer to a pointer to MyType
+
+
+ Type.GetType("MyType**")
+
+
+
+
+ A managed pointer or reference to MyType
+
+
+ Type.GetType("MyType&"). Note that unlike pointers, references are limited to one level.
+
+
+
+
+ A parent class and a nested class
+
+
+ Type.GetType("MyParentClass+MyNestedClass")
+
+
+
+
+ A one-dimensional array with a lower bound of 0
+
+
+ Type.GetType("MyType[]")
+
+
+
+
+ A one-dimensional array with an unknown lower bound
+
+
+ Type.GetType("MyType[*]")
+
+
+
+
+ An n-dimensional array
+
+
+ A comma (,) inside the brackets a total of n-1 times. For example, System.Object[,,] represents a three-dimensional Object array.
+
+
+
+
+ An array of one-dimensional arrays
+
+
+ Type.GetType("MyType[][]")
+
+
+
+
+ A rectangular two-dimensional array with unknown lower bounds
+
+
+ Type.GetType("MyType[,]")
+
+
+
+
+ A generic type with one type argument
+
+
+ Type.GetType("MyGenericType`1[MyType]")
+
+
+
+
+ A generic type with two type arguments
+
+
+ Type.GetType("MyGenericType`2[MyType,AnotherType]")
+
+
+
+
+ A generic type with two assembly-qualified type arguments
+
+
+ Type.GetType("MyGenericType`2[[MyType,MyAssembly],[AnotherType,AnotherAssembly]]")
+
+
+
+
+ An assembly-qualified generic type with an assembly-qualified type argument
+
+
+ Type.GetType("MyGenericType`1[[MyType,MyAssembly]],MyGenericTypeAssembly")
+
+
+
+
+ A generic type whose type argument is a generic type with two type arguments
+
+
+ Type.GetType("MyGenericType`1[AnotherGenericType`2[MyType,AnotherType]]")
+
+
+
+
+
+
+ Gets thewith the specified name, performing a case-sensitive search.
+
+
+
+ The type with the specified name, if found; otherwise, null.
+
+
+ The assembly-qualified name of the type to get. See. If the type is in the currently executing assembly or in Mscorlib.dll, it is sufficient to supply the type name qualified by its namespace.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+
+ is.
+ A type initializer was invoked and threw an exception.
+
+ isand an error was encountered while loading the.
+ Requires permission to retrieve information on non-public objects. See
+
+
+
+ You can use themethod to obtain aobject for a type in another assembly, if the you know its namespace-qualified name.causes loading of the assembly specified in. You can also load an assembly using themethod, and then use theormethods of theclass to getobjects. If a type is in an assembly known to your program at compile time, it is more efficient to use typeof in C#,in Visual Basic, or typeid in C++.
+ GetType only works on assemblies loaded from disk. If you call GetType to look up a type defined in a dynamic assembly defined using theservices, you might get inconsistent behavior. The behavior depends on whether the dynamic assembly is persistent, that is, created using the RunAndSave or Save access modes of theenumeration. If the dynamic assembly is persistent and has been written to disk before GetType is called, the loader finds the saved assembly on disk, loads that assembly, and retrieves the type from that assembly. If the assembly has not been saved to disk when GetType is called, the method returns null. GetType does not understand transient dynamic assemblies; therefore, calling GetType to retrieve a type in a transient dynamic assembly returns null.
+ To use GetType on a dynamic module, subscribe to theevent and call GetType before saving. Otherwise, you will get two copies of the assembly in memory.
+ Theparameter specifies what happens when the type is not found, and also suppresses certain other exception conditions, as described in the Exceptions section. Some exceptions are thrown regardless of the value of. For example, if the type is found but cannot be loaded, ais thrown even ifis false.
+ The following table shows what members of a base class are returned by the Get methods when reflecting on a type.
+
+
+
+
+ Member Type
+
+
+ Static
+
+
+ Non-Static
+
+
+
+
+
+ Constructor
+
+
+ No
+
+
+ No
+
+
+
+
+ Field
+
+
+ No
+
+
+ Yes. A field is always hide-by-name-and-signature.
+
+
+
+
+ Event
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+ Method
+
+
+ No
+
+
+ Yes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.
+
+
+
+
+ Nested Type
+
+
+ No
+
+
+ No
+
+
+
+
+ Property
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+
+ Hide-by-name-and-signature considers all of the parts of the signature, including custom modifiers, return types, parameter types, sentinels, and unmanaged calling conventions. This is a binary comparison.
+
+
+ For reflection, properties and events are hide-by-name-and-signature. If you have a property with both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and you will not be able to access the setter on the base class.
+
+
+ Custom attributes are not part of the common type system.
+
+
+ Arrays or COM types are not searched for unless they have already been loaded into the table of available classes.
+
+ can be the type name qualified by its namespace or an assembly-qualified name that includes an assembly name specification. See.
+ Ifincludes the namespace but not the assembly name, this method searches only the calling object's assembly and Mscorlib.dll, in that order. If typeName is fully qualified with the partial or complete assembly name, this method searches in the specified assembly. If the assembly has a strong name, a complete assembly name is required.
+ Theproperty returns a fully qualified type name including nested types, the assembly name, and generic arguments. All compilers that support the common language runtime will emit the simple name of a nested class, and reflection constructs a mangled name when queried, in accordance with the following conventions.
+
+ In the .NET Framework version 2.0, processor architecture is added to assembly identity, and can be specified as part of assembly name strings. For example, "ProcessorArchitecture=msil". However, it is not included in the string returned by theproperty, for compatibility reasons. You can also load types by creating anobject and passing it to an appropriate overload of themethod. You can then use themethod to load types from the assembly. See also.
+
+
+
+
+
+ Delimiter
+
+
+ Meaning
+
+
+
+
+
+ Backslash (\)
+
+
+ Escape character.
+
+
+
+
+ Backtick (`)
+
+
+ Precedes one or more digits representing the number of type parameters, located at the end of the name of a generic type.
+
+
+
+
+ Brackets ([])
+
+
+ Enclose a generic type argument list, for a constructed generic type; within a type argument list, enclose an assembly-qualified type.
+
+
+
+
+ Comma (,)
+
+
+ Precedes the Assembly name.
+
+
+
+
+ Period (.)
+
+
+ Denotes namespace identifiers.
+
+
+
+
+ Plus sign (+)
+
+
+ Precedes a nested class.
+
+
+
+ For example, the fully qualified name for a class might look like this:
+ TopNamespace.SubNameSpace.ContainingClass+NestedClass,MyAssembly
+ If the namespace were TopNamespace.Sub+Namespace, then the string would have to precede the plus sign (+) with an escape character (\) to prevent it from being interpreted as a nesting separator. Reflection emits this string as follows:
+ TopNamespace.Sub\+Namespace.ContainingClass+NestedClass,MyAssembly
+ A "++" becomes "\+\+", and a "\" becomes "\\".
+ This qualified name can be persisted and later used to load the. To search for and load a, useeither with the type name only or with the assembly qualified type name.with the type name only will look for thein the caller's assembly and then in the System assembly.with the assembly qualified type name will look for thein any assembly.
+ Type names may include trailing characters that denote additional information about the type, such as whether the type is a reference type, a pointer type or an array type. To retrieve the type name without these trailing characters, use t.GetElementType().ToString(), whereis the type.
+ Spaces are relevant in all type name components except the assembly name. In the assembly name, spaces before the ',' separator are relevant, but spaces after the ',' separator are ignored.
+ The name of a generic type ends with a backtick (`) followed by digits representing the number of generic type arguments. The purpose of this name mangling is to allow compilers to support generic types with the same name but with different numbers of type parameters, occurring in the same scope. For example, reflection returns the mangled names Tuple`1 and Tuple`2 from the generic methods Tuple(Of T) and Tuple(Of T0, T1) in Visual Basic, or Tuple<T> and Tuple<T0, T1> in Visual C#.
+ For generic types, the type argument list is enclosed in brackets, and the type arguments are separated by commas. For example, a generichas two type parameters. Aof MyType with keys of typemight be represented as follows:
+ System.Collections.Generic.Dictionary`2[System.String,MyType]
+ To specify an assembly-qualified type within a type argument list, enclose the assembly-qualified type within brackets. Otherwise, the commas that separate the parts of the assembly-qualified name are interpreted as delimiting additional type arguments. For example, aof MyType from MyAssembly.dll, with keys of type, might be specified as follows:
+ Type.GetType("System.Collections.Generic.Dictionary`2[System.String,[MyType,MyAssembly]]")
+
+ An assembly-qualified type can be enclosed in brackets only when it appears within a type parameter list. The rules for searching assemblies for qualified and unqualified types in type parameter lists are the same as the rules for qualified and unqualified nongeneric types.
+
+ Nullable types are a special case of generic types. For example, a nullableis represented by the string "System.Nullable`1[System.Int32]".
+
+ In C#, C++, and Visual Basic you can also get nullable types using type operators. For example, the nullabletype is returned by typeof(Nullable<bool>) in C#, by Nullable<Boolean>::typeid in C++, and by GetType(Nullable(Of Boolean)) in Visual Basic.
+
+ The following table shows the syntax you use with GetType for various types.
+
+
+
+
+ To Get
+
+
+ Use
+
+
+
+
+
+ A nullable
+
+
+ Type.GetType("System.Nullable`1[System.Int32]")
+
+
+
+
+ An unmanaged pointer to MyType
+
+
+ Type.GetType("MyType*")
+
+
+
+
+ An unmanaged pointer to a pointer to MyType
+
+
+ Type.GetType("MyType**")
+
+
+
+
+ A managed pointer or reference to MyType
+
+
+ Type.GetType("MyType&"). Note that unlike pointers, references are limited to one level.
+
+
+
+
+ A parent class and a nested class
+
+
+ Type.GetType("MyParentClass+MyNestedClass")
+
+
+
+
+ A one-dimensional array with a lower bound of 0
+
+
+ Type.GetType("MyArray[]")
+
+
+
+
+ A one-dimensional array with an unknown lower bound
+
+
+ Type.GetType("MyArray[*]")
+
+
+
+
+ An n-dimensional array
+
+
+ A comma (,) inside the brackets a total of n-1 times. For example, System.Object[,,] represents a three-dimensional Object array.
+
+
+
+
+ A two-dimensional array's array
+
+
+ Type.GetType("MyArray[][]")
+
+
+
+
+ A rectangular two-dimensional array with unknown lower bounds
+
+
+ Type.GetType("MyArray[,]")
+
+
+
+
+ A generic type with one type argument
+
+
+ Type.GetType("MyGenericType`1[MyType]")
+
+
+
+
+ A generic type with two type arguments
+
+
+ Type.GetType("MyGenericType`2[MyType,AnotherType]")
+
+
+
+
+ A generic type with two assembly-qualified type arguments
+
+
+ Type.GetType("MyGenericType`2[[MyType,MyAssembly],[AnotherType,AnotherAssembly]]")
+
+
+
+
+ An assembly-qualified generic type with an assembly-qualified type argument
+
+
+ Type.GetType("MyGenericType`1[[MyType,MyAssembly]],MyGenericTypeAssembly")
+
+
+
+
+ A generic type whose type argument is a generic type with two type arguments
+
+
+ Type.GetType("MyGenericType`1[AnotherGenericType`2[MyType,AnotherType]]")
+
+
+
+
+
+
+ Gets thewith the specified name, performing a case-sensitive search and specifying whether to throw an exception if the type is not found.
+
+
+
+ The type with the specified name. If the type is not found, theparameter specifies whether null is returned or an exception is thrown. In some cases, an exception is thrown regardless of the value of. See the Exceptions section.
+
+
+ The assembly-qualified name of the type to get. See. If the type is in the currently executing assembly or in Mscorlib.dll, it is sufficient to supply the type name qualified by its namespace.
+
+ true to throw an exception if the type cannot be found; false to return null. Specifying false also suppresses some other exception conditions, but not all of them. See the Exceptions section.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+
+
+ is.
+ A type initializer was invoked and threw an exception.
+
+ isand an error was encountered while loading the selected.
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+
+ You can use themethod to obtain aobject for a type in another assembly, if the you know its namespace-qualified name.causes loading of the assembly specified in. You can also load an assembly using themethod, and then use theormethods of theclass to getobjects. If a type is in an assembly known to your program at compile time, it is more efficient to use typeof in C#,in Visual Basic, or typeid in C++.
+ GetType only works on assemblies loaded from disk. If you call GetType to look up a type defined in a dynamic assembly defined using theservices, you might get inconsistent behavior. The behavior depends on whether the dynamic assembly is persistent, that is, created using the RunAndSave or Save access modes of theenumeration. If the dynamic assembly is persistent and has been written to disk before GetType is called, the loader finds the saved assembly on disk, loads that assembly, and retrieves the type from that assembly. If the assembly has not been saved to disk when GetType is called, the method returns null. GetType does not understand transient dynamic assemblies; therefore, calling GetType to retrieve a type in a transient dynamic assembly returns null.
+ To use GetType on a dynamic module, subscribe to theevent and call GetType before saving. Otherwise, you will get two copies of the assembly in memory.
+ Theparameter specifies what happens when the type is not found, and also suppresses certain other exception conditions, as described in the Exceptions section. Some exceptions are thrown regardless of the value of. For example, if the type is found but cannot be loaded, ais thrown even ifis false.
+ The following table shows what members of a base class are returned by the Get methods when reflecting on a type.
+
+
+
+
+ Member Type
+
+
+ Static
+
+
+ Non-Static
+
+
+
+
+
+ Constructor
+
+
+ No
+
+
+ No
+
+
+
+
+ Field
+
+
+ No
+
+
+ Yes. A field is always hide-by-name-and-signature.
+
+
+
+
+ Event
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+ Method
+
+
+ No
+
+
+ Yes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.
+
+
+
+
+ Nested Type
+
+
+ No
+
+
+ No
+
+
+
+
+ Property
+
+
+ Not applicable
+
+
+ The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.
+
+
+
+
+
+ Hide-by-name-and-signature considers all of the parts of the signature, including custom modifiers, return types, parameter types, sentinels, and unmanaged calling conventions. This is a binary comparison.
+
+
+ For reflection, properties and events are hide-by-name-and-signature. If you have a property with both a get and a set accessor in the base class, but the derived class has only a get accessor, the derived class property hides the base class property, and you will not be able to access the setter on the base class.
+
+
+ Custom attributes are not part of the common type system.
+
+
+ Arrays or COM types are not searched for unless they have already been loaded into the table of available classes.
+
+ can be the type name qualified by its namespace or an assembly-qualified name that includes an assembly name specification. See.
+ Ifincludes the namespace but not the assembly name, this method searches only the calling object's assembly and Mscorlib.dll, in that order. If typeName is fully qualified with the partial or complete assembly name, this method searches in the specified assembly. If the assembly has a strong name, a complete assembly name is required.
+ Theproperty returns a fully qualified type name including nested types, the assembly name, and type arguments. All compilers that support the common language runtime will emit the simple name of a nested class, and reflection constructs a mangled name when queried, in accordance with the following conventions.
+
+ In the .NET Framework version 2.0, processor architecture is added to assembly identity, and can be specified as part of assembly name strings. For example, "ProcessorArchitecture=msil". However, it is not included in the string returned by theproperty, for compatibility reasons. You can also load types by creating anobject and passing it to an appropriate overload of themethod. You can then use themethod to load types from the assembly. See also.
+
+
+
+
+
+ Delimiter
+
+
+ Meaning
+
+
+
+
+
+ Backslash (\)
+
+
+ Escape character.
+
+
+
+
+ Backtick (`)
+
+
+ Precedes one or more digits representing the number of type parameters, located at the end of the name of a generic type.
+
+
+
+
+ Brackets ([])
+
+
+ Enclose a generic type argument list, for a constructed generic type; within a type argument list, enclose an assembly-qualified type.
+
+
+
+
+ Comma (,)
+
+
+ Precedes the Assembly name.
+
+
+
+
+ Period (.)
+
+
+ Denotes namespace identifiers.
+
+
+
+
+ Plus sign (+)
+
+
+ Precedes a nested class.
+
+
+
+ For example, the fully qualified name for a class might look like this:
+ TopNamespace.SubNameSpace.ContainingClass+NestedClass,MyAssembly
+ If the namespace were TopNamespace.Sub+Namespace, then the string would have to precede the plus sign (+) with an escape character (\) to prevent it from being interpreted as a nesting separator. Reflection emits this string as follows:
+ TopNamespace.Sub\+Namespace.ContainingClass+NestedClass,MyAssembly
+ A "++" becomes "\+\+", and a "\" becomes "\\".
+ This qualified name can be persisted and later used to load the. To search for and load a, useeither with the type name only or with the assembly qualified type name.with the type name only will look for thein the caller's assembly and then in the System assembly.with the assembly qualified type name will look for thein any assembly.
+ Type names may include trailing characters that denote additional information about the type, such as whether the type is a reference type, a pointer type or an array type. To retrieve the type name without these trailing characters, use t.GetElementType().ToString(), whereis the type.
+ Spaces are relevant in all type name components except the assembly name. In the assembly name, spaces before the ',' separator are relevant, but spaces after the ',' separator are ignored.
+ The name of a generic type ends with a backtick (`) followed by digits representing the number of generic type arguments. The purpose of this name mangling is to allow compilers to support generic types with the same name but with different numbers of type parameters, occurring in the same scope. For example, reflection returns the mangled names Tuple`1 and Tuple`2 from the generic methods Tuple(Of T) and Tuple(Of T0, T1) in Visual Basic, or Tuple<T> and Tuple<T0, T1> in Visual C#.
+ For generic types, the type argument list is enclosed in brackets, and the type arguments are separated by commas. For example, a generichas two type parameters. Aof MyType with keys of typemight be represented as follows:
+ System.Collections.Generic.Dictionary`2[System.String,MyType]
+ To specify an assembly-qualified type within a type argument list, enclose the assembly-qualified type within brackets. Otherwise, the commas that separate the parts of the assembly-qualified name are interpreted as delimiting additional type arguments. For example, aof MyType from MyAssembly.dll, with keys of type, might be specified as follows:
+ Type.GetType("System.Collections.Generic.Dictionary`2[System.String,[MyType,MyAssembly]]")
+
+ An assembly-qualified type can be enclosed in brackets only when it appears within a type parameter list. The rules for searching assemblies for qualified and unqualified types in type parameter lists are the same as the rules for qualified and unqualified nongeneric types.
+
+ Nullable types are a special case of generic types. For example, a nullableis represented by the string "System.Nullable`1[System.Int32]".
+
+ In C#, C++, and Visual Basic you can also get nullable types using type operators. For example, the nullabletype is returned by typeof(Nullable<bool>) in C#, by Nullable<Boolean>::typeid in C++, and by GetType(Nullable(Of Boolean)) in Visual Basic.
+
+ The following table shows the syntax you use with GetType for various types.
+
+
+
+
+ To Get
+
+
+ Use
+
+
+
+
+
+ A nullable
+
+
+ Type.GetType("System.Nullable`1[System.Int32]")
+
+
+
+
+ An unmanaged pointer to MyType
+
+
+ Type.GetType("MyType*")
+
+
+
+
+ An unmanaged pointer to a pointer to MyType
+
+
+ Type.GetType("MyType**")
+
+
+
+
+ A managed pointer or reference to MyType
+
+
+ Type.GetType("MyType&"). Note that unlike pointers, references are limited to one level.
+
+
+
+
+ A parent class and a nested class
+
+
+ Type.GetType("MyParentClass+MyNestedClass")
+
+
+
+
+ A one-dimensional array with a lower bound of 0
+
+
+ Type.GetType("MyArray[]")
+
+
+
+
+ A one-dimensional array with an unknown lower bound
+
+
+ Type.GetType("MyArray[*]")
+
+
+
+
+ An n-dimensional array
+
+
+ A comma (,) inside the brackets a total of n-1 times. For example, System.Object[,,] represents a three-dimensional Object array.
+
+
+
+
+ A two-dimensional array's array
+
+
+ Type.GetType("MyArray[][]")
+
+
+
+
+ A rectangular two-dimensional array with unknown lower bounds
+
+
+ Type.GetType("MyArray[,]")
+
+
+
+
+ A generic type with one type argument
+
+
+ Type.GetType("MyGenericType`1[MyType]")
+
+
+
+
+ A generic type with two type arguments
+
+
+ Type.GetType("MyGenericType`2[MyType,AnotherType]")
+
+
+
+
+ A generic type with two assembly-qualified type arguments
+
+
+ Type.GetType("MyGenericType`2[[MyType,MyAssembly],[AnotherType,AnotherAssembly]]")
+
+
+
+
+ An assembly-qualified generic type with an assembly-qualified type argument
+
+
+ Type.GetType("MyGenericType`1[[MyType,MyAssembly]],MyGenericTypeAssembly")
+
+
+
+
+ A generic type whose type argument is a generic type with two type arguments
+
+
+ Type.GetType("MyGenericType`1[AnotherGenericType`2[MyType,AnotherType]]")
+
+
+
+
+
+
+ Gets thewith the specified name, specifying whether to perform a case-sensitive search and whether to throw an exception if the type is not found.
+
+
+
+ The type with the specified name. If the type is not found, theparameter specifies whether null is returned or an exception is thrown. In some cases, an exception is thrown regardless of the value of. See the Exceptions section.
+
+
+ The assembly-qualified name of the type to get. See. If the type is in the currently executing assembly or in Mscorlib.dll, it is sufficient to supply the type name qualified by its namespace.
+
+ true to throw an exception if the type cannot be found; false to return null.Specifying false also suppresses some other exception conditions, but not all of them. See the Exceptions section.
+
+ true to perform a case-insensitive search for, false to perform a case-sensitive search for.
+
+ 1
+ Reflection
+
+
+
+
+ Method
+
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+
+
+
+ Usage scenarios for this method and details about theandparameters can be found in themethod overload.
+ Calling this method overload is the same as calling themethod overload and specifying false for theandparameters.
+
+
+
+ Gets the type with the specified name, optionally providing custom methods to resolve the assembly and the type.
+
+
+
+ The type with the specified name, or null if the type is not found.
+
+
+ The name of the type to get. If theparameter is provided, the type name can be any string thatis capable of resolving. If theparameter is provided or if standard type resolution is used,must be an assembly-qualified name (see), unless the type is in the currently executing assembly or in Mscorlib.dll, in which case it is sufficient to supply the type name qualified by its namespace.
+
+ A method that locates and returns the assembly that is specified in. The assembly name is passed toas anobject. Ifdoes not contain the name of an assembly,is not called. Ifis not supplied, standard assembly resolution is performed.
+
+ A method that locates and returns the type that is specified byfrom the assembly that is returned byor by standard assembly resolution. If no assembly is provided, themethod can provide one. The method also takes a parameter that specifies whether to perform a case-insensitive search; false is passed to that parameter.
+
+
+
+
+
+ Method
+
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+
+
+
+
+ Usage scenarios for this method and details about theandparameters can be found in themethod overload.
+ Calling this method overload is the same as calling themethod overload and specifying false for theparameter.
+
+
+
+ Gets the type with the specified name, specifying whether to throw an exception if the type is not found, and optionally providing custom methods to resolve the assembly and the type.
+
+
+
+ The type with the specified name. If the type is not found, theparameter specifies whether null is returned or an exception is thrown. In some cases, an exception is thrown regardless of the value of. See the Exceptions section.
+
+
+ The name of the type to get. If theparameter is provided, the type name can be any string thatis capable of resolving. If theparameter is provided or if standard type resolution is used,must be an assembly-qualified name (see), unless the type is in the currently executing assembly or in Mscorlib.dll, in which case it is sufficient to supply the type name qualified by its namespace.
+
+ A method that locates and returns the assembly that is specified in. The assembly name is passed toas anobject. Ifdoes not contain the name of an assembly,is not called. Ifis not supplied, standard assembly resolution is performed.
+
+ A method that locates and returns the type that is specified byfrom the assembly that is returned byor by standard assembly resolution. If no assembly is provided, the method can provide one. The method also takes a parameter that specifies whether to perform a case-insensitive search; false is passed to that parameter.
+
+ true to throw an exception if the type cannot be found; false to return null. Specifying false also suppresses some other exception conditions, but not all of them. See the Exceptions section.
+
+
+
+
+
+ Method
+
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+
+
+
+
+
+ Use this method overload and its associated overloads (and) to replace the default implementation of themethod with more flexible implementations. By providing your own methods that resolve type names and the names of the assemblies that contain them, you can do the following:
+
+
+ Control which version of an assembly a type is loaded from.
+
+
+ Provide another place to look for a type name that does not include an assembly name.
+
+
+ Load assemblies using partial assembly names.
+
+
+ Return subclasses ofthat are not created by the common language runtime (CLR).
+
+
+ For example, in version-tolerant serialization this method enables you to search for a "best fit" assembly by using a partial name. Other overloads of themethod require an assembly-qualified type name, which includes the version number.
+ Alternate implementations of the type system may need to return subclasses ofthat are not created by the CLR; all types that are returned by other overloads of themethod are runtime types.
+
+
+
+
+
Usage Notes
+
+ This method overload and its associated overloads parseinto the name of a type and the name of an assembly, and then resolve the names. Resolution of the assembly name occurs before resolution of the type name, because a type name must be resolved in the context of an assembly.
+
+ If you are unfamiliar with the concept of assembly-qualified type names, see theproperty.
+
+ Ifis not an assembly-qualified name, assembly resolution is skipped. Unqualified type names can be resolved in the context of Mscorlib.dll or the currently executing assembly, or you can optionally provide an assembly in theparameter. The effects of including or omitting the assembly name for different kinds of name resolution are displayed as a table in the
+ Mixed Name Resolution
+ section.
+ General usage notes:
+
+
+ Do not pass methods toorif they come from unknown or untrusted callers. Use only methods that you provide or that you are familiar with.
+
+ Using methods from unknown or untrusted callers could result in elevation of privilege for malicious code.
+
+
+
+ If you omit theand/orparameters, the value of theparameter is passed to the methods that perform the default resolution.
+
+
+ Ifis true, this method throws awhenreturns null, and awhenreturns null.
+
+
+ This method does not catch exceptions thrown byand. You are responsible for any exceptions that are thrown by the resolver methods.
+
+
+
+
+
+
+
Resolving Assemblies
+
+ Themethod receives anobject, which is produced by parsing the string assembly name that is included in. Ifdoes not contain an assembly name,is not called and null is passed to.
+ Ifis not supplied, standard assembly probing is used to locate the assembly. Ifis provided, themethod does not do standard probing; in that case you must ensure that yourcan handle all the assemblies you pass to it.
+ Themethod should return null if the assembly cannot be resolved. Ifreturns null,is not called and no further processing occurs; additionally, ifis true, ais thrown.
+ If thethat is passed tois a partial name, one or more of its parts are null. For example, if it has no version, theproperty is null. If theproperty, theproperty, and themethod all return null, then only the simple name of the assembly was supplied. Themethod can use or ignore all parts of the assembly name.
+ The effects of different assembly resolution options are displayed as a table in the
+ Mixed Name Resolution
+ section, for simple and assembly-qualified type names.
+
+
+
+
+
Resolving Types
+
+ Ifdoes not specify an assembly name,is always called. Ifspecifies an assembly name,is called only when the assembly name is successfully resolved. Ifor standard assembly probing returns null,is not called.
+ Themethod receives three arguments:
+
+
+ The assembly to search or null ifdoes not contain an assembly name.
+
+
+ The simple name of the type. In the case of a nested type, this is the outermost containing type. In the case of a generic type, this is the simple name of the generic type.
+
+
+ A Boolean value that is true if the case of type names is to be ignored.
+
+
+ The implementation determines the way these arguments are used. Themethod should return null if it cannot resolve the type. Ifreturns null andis true, this overload ofthrows a.
+ The effects of different type resolution options are displayed as a table in the
+ Mixed Name Resolution
+ section, for simple and assembly-qualified type names.
+
+
Resolving Nested Types
+
+ Ifis a nested type, only the name of the outermost containing type is passed to. Whenreturns this type, themethod is called recursively until the innermost nested type has been resolved.
+
+
Resolving Generic Types
+
+ Theis called recursively to resolve generic types: First to resolve the generic type itself, and then to resolve its type arguments. If a type argument is generic,is called recursively to resolve its type arguments, and so on.
+ The combination ofandthat you provide must be capable of resolving all levels of this recursion. For example, suppose you supply anthat controls the loading of MyAssembly. Suppose you want to resolve the generic type Dictionary<string, MyType> (Dictionary(Of String, MyType) in Visual Basic). You might pass the following generic type name:
+ "System.Collections.Generic.Dictionary`2[System.String,[MyNamespace.MyType, MyAssembly]]"
+ Notice that MyType is the only assembly-qualified type argument. The names of theandclasses are not assembly-qualified. Yourmust be able handle either an assembly or null, because it will receive null forand. It can handle that case by calling an overload of themethod that takes a string, because both of the unqualified type names are in Mscorlib.dll:
+ code reference: GetTypeOnSteroids#1
+ Themethod is not called for the dictionary type and the string type, because those type names are not assembly-qualified.
+ Now suppose that instead of System.String, the first generic argument type is YourType, from YourAssembly:
+ "System.Collections.Generic.Dictionary`2[[YourNamespace.YourType, YourAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null], [MyNamespace.MyType, MyAssembly]]"
+ Because this assembly is neither Mscorlib.dll nor the currently executing assembly, you cannot resolve YourType without an assembly-qualified name. Because yourwill be called recursively, it must be able to handle this case. Instead of returning null for assemblies other than MyAssembly, it now performs an assembly load using the suppliedobject.
+ code reference: GetTypeOnSteroids#2
+ Back to
+ Usage Notes
+ .
+
+
Resolving Type Names with Special Characters
+
+ Certain characters have special meanings in assembly-qualified names. If a simple type name contains these characters, the characters cause parsing errors when the simple name is part of an assembly-qualified name. To avoid the parsing errors, you must escape the special characters with a backslash before you can pass the assembly-qualified name to themethod. For example, if a type is named Strange]Type, the escape character must be added ahead of the square bracket as follows: Strange\]Type.
+
+ Names with such special characters cannot be created in Visual Basic or C#, but can be created by using Microsoft intermediate language (MSIL) or by emitting dynamic assemblies.
+
+ The following table shows the special characters for type names.
+
+
+
+
+ Character
+
+
+ Meaning
+
+
+
+
+
+ , (comma)
+
+
+ Delimiter for assembly-qualified names.
+
+
+
+
+ [] (square brackets)
+
+
+ As a suffix pair, indicates an array type; as a delimiter pair, encloses generic argument lists and assembly-qualified names.
+
+
+
+
+ & (ampersand)
+
+
+ As a suffix, indicates that a type is a reference type.
+
+
+
+
+ * (asterisk)
+
+
+ As a suffix, indicates that a type is a pointer type.
+
+
+
+
+ + (plus)
+
+
+ Delimiter for nested types.
+
+
+
+
+ \ (backslash)
+
+
+ Escape character.
+
+
+
+ Properties such asreturn correctly escaped strings. You must pass correctly escaped strings to themethod. In turn, themethod passes correctly escaped names toand to the default type resolution methods. If you need to compare a name to an unescaped name in, you must remove the escape characters.
+ Back to
+ Usage Notes
+ .
+
+
+
+
+
Mixed Name Resolution
+
+ The following table summarizes the interactions between,, and default name resolution, for all combinations of type name and assembly name in:
+
+
+
+
+ Contents of type name
+
+
+ Assembly resolver method
+
+
+ Type resolver method
+
+
+ Result
+
+
+
+
+
+ type, assembly
+
+
+ null
+
+
+ null
+
+
+ Equivalent to calling themethod overload.
+
+
+
+
+ type, assembly
+
+
+ provided
+
+
+ null
+
+
+
+ returns the assembly or returns null if it cannot resolve the assembly. If the assembly is resolved, themethod overload is used to load the type from the assembly; otherwise, there is no attempt to resolve the type.
+
+
+
+
+ type, assembly
+
+
+ null
+
+
+ provided
+
+
+ Equivalent to converting the assembly name to anobject and calling themethod overload to get the assembly. If the assembly is resolved, it is passed to; otherwise,is not called and there is no further attempt to resolve the type.
+
+
+
+
+ type, assembly
+
+
+ provided
+
+
+ provided
+
+
+
+ returns the assembly or returns null if it cannot resolve the assembly. If the assembly is resolved, it is passed to; otherwise,is not called and there is no further attempt to resolve the type.
+
+
+
+
+ type
+
+
+ null, provided
+
+
+ null
+
+
+ Equivalent to calling themethod overload. Because the assembly name is not provided, only Mscorlib.dll and the currently executing assembly are searched. Ifis provided, it is ignored.
+
+
+
+
+ type
+
+
+ null, provided
+
+
+ provided
+
+
+
+ is called, and null is passed for the assembly.can provide a type from any assembly, including assemblies it loads for the purpose. Ifis provided, it is ignored.
+
+
+
+
+ assembly
+
+
+ null, provided
+
+
+ null, provided
+
+
+ Ais thrown, because the assembly name is parsed as if it were an assembly-qualified type name. This results in an invalid assembly name.
+
+
+
+ Back to:
+ Usage Notes
+ ,
+ Resolving Assemblies
+ ,
+ Resolving Types
+ .
+
+
+
+ Gets the type with the specified name, specifying whether to perform a case-sensitive search and whether to throw an exception if the type is not found, and optionally providing custom methods to resolve the assembly and the type.
+
+
+
+ The type with the specified name. If the type is not found, theparameter specifies whether null is returned or an exception is thrown. In some cases, an exception is thrown regardless of the value of. See the Exceptions section.
+
+
+ The name of the type to get. If theparameter is provided, the type name can be any string thatis capable of resolving. If theparameter is provided or if standard type resolution is used,must be an assembly-qualified name (see), unless the type is in the currently executing assembly or in Mscorlib.dll, in which case it is sufficient to supply the type name qualified by its namespace.
+
+ A method that locates and returns the assembly that is specified in. The assembly name is passed toas anobject. Ifdoes not contain the name of an assembly,is not called. Ifis not supplied, standard assembly resolution is performed.
+
+ A method that locates and returns the type that is specified byfrom the assembly that is returned byor by standard assembly resolution. If no assembly is provided, the method can provide one. The method also takes a parameter that specifies whether to perform a case-insensitive search; the value ofis passed to that parameter.
+
+ true to throw an exception if the type cannot be found; false to return null. Specifying false also suppresses some other exception conditions, but not all of them. See the Exceptions section.
+
+ true to perform a case-insensitive search for, false to perform a case-sensitive search for.
+
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type[]
+
+
+
+
+
+ To be added.
+
+ is.
+ The type initializers were invoked and at least one threw an exception.
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+
+ Gets the types of the objects in the specified array.
+
+
+
+ An array ofobjects representing the types of the corresponding elements in.
+
+
+ An array of objects whose types to determine.
+
+ 1
+ Reflection
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.TypeCode
+
+
+
+
+
+
+
+ When you inherit from, you can change the behavior of this method by overriding themethod.
+
+
+
+ Gets the underlying type code of the specified.
+
+
+
+ The code of the underlying type, orifis null.
+
+
+ The type whose underlying type code to get.
+
+
+
+
+
+ Method
+
+ 4.0.0.0
+
+
+ System.TypeCode
+
+
+
+
+
+ This method provides the implementation for themethod. When you inherit from, you can override this method to provide your own implementation of.
+
+
+
+ Returns the underlying type code of the specified.
+
+
+
+ The code of the underlying type.
+
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+ To be added.
+
+
+ Gets the type associated with the specified class identifier (CLSID).
+
+
+
+ System.__ComObject regardless of whether the CLSID is valid.
+
+
+ The CLSID of the type to get.
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+
+
+ Exceptions such aswill be thrown when specifying true for, but it will not fail for unregistered CLSIDs.
+
+
+
+ Gets the type associated with the specified class identifier (CLSID), specifying whether to throw an exception if an error occurs while loading the type.
+
+
+
+ System.__ComObject regardless of whether the CLSID is valid.
+
+
+ The CLSID of the type to get.
+
+ true to throw any exception that occurs.
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+ To be added.
+
+
+ Gets the type associated with the specified class identifier (CLSID) from the specified server.
+
+
+
+ System.__ComObject regardless of whether the CLSID is valid.
+
+
+ The CLSID of the type to get.
+
+ The server from which to load the type. If the server name is null, this method automatically reverts to the local machine.
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+
+
+
+ Exceptions such aswill be thrown when specifying true for, but it will not fail for unregistered CLSIDs.
+
+
+
+ Gets the type associated with the specified class identifier (CLSID) from the specified server, specifying whether to throw an exception if an error occurs while loading the type.
+
+
+
+ System.__ComObject regardless of whether the CLSID is valid.
+
+
+ The CLSID of the type to get.
+
+ The server from which to load the type. If the server name is null, this method automatically reverts to the local machine.
+
+ true to throw any exception that occurs.
+
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+ is.
+ The requested type is non-public and outside the current assembly, and the caller does not have the required permission.
+ A type initializer was invoked and threw an exception.
+ Requires permission to retrieve information on non-public objects. See
+
+
+
+ The handles are valid only in the application domain in which they were obtained.
+
+
+
+ Gets the type referenced by the specified type handle.
+
+
+
+ The type referenced by the specified, or null if theproperty ofis null.
+
+
+ The object that refers to the type.
+
+ 1
+ RuntimeInfrastructure
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+
+ This method is provided for COM support. ProgIDs are not used in the Microsoft .NET Framework because they have been superseded by the concept of namespace.
+
+
+
+ Gets the type associated with the specified program identifier (ProgID), returning null if an error is encountered while loading the.
+
+
+
+ The type associated with the specified ProgID, ifis a valid entry in the registry and a type is associated with it; otherwise, null.
+
+
+ The ProgID of the type to get.
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+
+
+ This method is provided for COM support. Program IDs are not used in Microsoft .NET Framework because they have been superseded by the concept of namespace.
+
+
+
+ Gets the type associated with the specified program identifier (ProgID), specifying whether to throw an exception if an error occurs while loading the type.
+
+
+
+ The type associated with the specified program identifier (ProgID), ifis a valid entry in the registry and a type is associated with it; otherwise, null.
+
+
+ The ProgID of the type to get.
+
+ true to throw any exception that occurs.
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+
+
+ This method is provided for COM support. Program IDs are not used in Microsoft .NET Framework because they have been superseded by the concept of namespace.
+
+
+
+ Gets the type associated with the specified program identifier (progID) from the specified server, returning null if an error is encountered while loading the type.
+
+
+
+ The type associated with the specified program identifier (progID), ifis a valid entry in the registry and a type is associated with it; otherwise, null.
+
+
+ The progID of the type to get.
+
+ The server from which to load the type. If the server name is null, this method automatically reverts to the local machine.
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+
+
+
+ This method is provided for COM support. Program IDs are not used in Microsoft .NET Framework because they have been superseded by the concept of namespace.
+
+
+
+ Gets the type associated with the specified program identifier (progID) from the specified server, specifying whether to throw an exception if an error occurs while loading the type.
+
+
+
+ The type associated with the specified program identifier (progID), ifis a valid entry in the registry and a type is associated with it; otherwise, null.
+
+
+ The progID of theto get.
+
+ The server from which to load the type. If the server name is null, this method automatically reverts to the local machine.
+
+ true to throw any exception that occurs.
+
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.RuntimeTypeHandle
+
+
+
+
+
+
+
+ The handles are valid only in the application domain in which they were obtained.
+
+
+
+ Gets the handle for theof a specified object.
+
+
+
+ The handle for theof the specified.
+
+
+ The object for which to get the type handle.
+
+ 1
+ RuntimeInfrastructure
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Guid
+
+
+ To be added.
+
+
+ A GUID is associated with a type using theattribute.
+
+
+
+ Gets the GUID associated with the.
+
+
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if theis an array, a pointer, or is passed by reference; otherwise,.
+
+
+
+ For example, Type.GetType("Int32[]").HasElementType returns true, but Type.GetType("Int32").HasElementType returns false. HasElementType also returns true for "Int32*" and "Int32&".
+ If the currentrepresents a generic type, or a type parameter in the definition of a generic type or generic method, this property always returns false.
+
+
+
+ Gets a value indicating whether the currentencompasses or refers to another type; that is, whether the currentis an array, a pointer, or is passed by reference.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ For example, Type.GetType("Int32[]").HasElementTypeImpl returns true, but Type.GetType("Int32").HasElementTypeImpl returns false. HasElementTypeImpl also returns true for "Int32*" and "Int32&".
+
+
+
+ When overridden in a derived class, implements theproperty and determines whether the currentencompasses or refers to another type; that is, whether the currentis an array, a pointer, or is passed by reference.
+
+
+
+ true if theis an array, a pointer, or is passed by reference; otherwise, false.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+
+ System.Diagnostics.DebuggerStepThrough
+
+
+
+ System.Object
+
+
+
+
+
+
+
+
+
+
+ is.
+
+
+ has more than one dimension.
+ -or-
+
+ is not a validvalue.
+ -or-
+ The member to be invoked is a constructor andis not specified in.
+ -or-
+ The member to be invoked is a method that is not a type initializer or instance constructor, andis not specified in.
+ -or-
+ The member to be accessed is a field, and neithernoris specified in.
+ -or-
+ The member to be accessed is a property, and neithernoris specified in.
+ -or-
+
+ containsand at least one of,,,, or.
+ -or-
+
+ contains bothand.
+ -or-
+
+ contains bothand.
+ -or-
+
+ containsand at least one ofor.
+ -or-
+
+ containsandhas more than one element.
+
+ A field or property matching the specified criteria was not found.
+
+ A method matching the specified criteria cannot be found.
+ -or-
+ The current instance object represents a type that contains open type parameters (that is,
+
+ returns
+
+ ).
+
+ The requested member is non-public and the caller does not have the required permission.
+ The member matching the specified criteria cannot be invoked on.
+ The member matching the specified criteria threw an exception.
+ More than one member matches the specified criteria.
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+
+
+ You cannot useto invoke a generic method.
+
+ The followingfilter flags can be used to define which members to include in the search:
+
+
+ Specify BindingFlags.Public to include public members in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public members (that is, private and protected members) in the search.
+
+
+ Specify BindingFlags.FlattenHierarchy to include static members up the hierarchy.
+
+
+ The followingmodifier flags can be used to change how the search works:
+
+
+ BindingFlags.IgnoreCase to ignore the case of.
+
+
+ BindingFlags.DeclaredOnly to search only the members declared on the, not members that were simply inherited.
+
+
+ The followinginvocation flags can be used to denote what action to take with the member:
+
+
+ CreateInstance to invoke a constructor.is ignored. Not valid with other invocation flags.
+
+
+ InvokeMethod to invoke a method, but not a constructor or a type initializer. Not valid with SetField or SetProperty. If InvokeMethod is specified by itself, BindingFlags.Public, BindingFlags.Instance, and BindingFlags.Static are automatically included.
+
+
+ GetField to get the value of a field. Not valid with SetField.
+
+
+ SetField to set the value of a field. Not valid with GetField.
+
+
+ GetProperty to get a property. Not valid with SetProperty.
+
+
+ SetProperty to set a property. Not valid with GetProperty.
+
+
+ Seefor more information.
+ A method will be invoked if both of the following conditions are true:
+
+
+ The number of parameters in the method declaration equals the number of arguments in thearray (unless default arguments are defined on the member and BindingFlags.OptionalParamBinding is specified).
+
+
+ The type of each argument can be converted by the binder to the type of the parameter.
+
+
+ The binder will find all of the matching methods. These methods are found based upon the type of binding requested (values InvokeMethod, GetProperty, and so on). The set of methods is filtered by the name, number of arguments, and a set of search modifiers defined in the binder.
+ After the method is selected, it is invoked. Accessibility is checked at that point. The search may control which set of methods are searched based upon the accessibility attribute associated with the method. Themethod of theclass is responsible for selecting the method to be invoked. The default binder selects the most specific match.
+ Access restrictions are ignored for fully trusted code; that is, private constructors, methods, fields, and properties can be accessed and invoked throughwhenever the code is fully trusted.
+ You can use Type.InvokeMember to set a field to a particular value by specifying. For example, if you want to set a public instance field named F on class C, and F is a String, you can use code such as:
+ typeof(C).InvokeMember("F", BindingFlags.SetField, null, c, new Object[] {"strings new value"});
+ If F is a String[], you can use code such as:
+ typeof(C).InvokeMember("F", BindingFlags.SetField, null, c, new Object[] {new String[]{"a","z","c","d"}});
+ which will initialize the field F to this new array. You can also use Type.InvokeMember to set a position in an array by supplying the index of the value and then the next value by using code such as the following:
+ typeof(C).InvokeMember("F", BindingFlags.SetField, null, c, new Object[] {1, "b"});
+ This will change string "z" in the array that F holds to string "b".
+ When you invoke anIDispatchmember, you can specify the DispID instead of the member name, using the string format "[DispID=##]". For example, if the DispID of MyComMethod is 3, you can specify the string "[DispID=3]" instead of "MyComMethod". Invoking a member by DispID is faster than looking up the member by name. In complex aggregation scenarios, the DispID is sometimes the only way to invoke the desired member.
+
+ Starting with the net_v20sp1_long, this method can be used to access non-public members if the caller has been grantedwith theflag and if the grant set of the non-public members is restricted to the caller’s grant set, or a subset thereof. (See
+ Security Considerations for Reflection
+ .)
+ To use this functionality, your application should target the net_v35_long or later.
+
+
+
+
+ Invokes the specified member, using the specified binding constraints and matching the specified argument list.
+
+
+
+ An object representing the return value of the invoked member.
+
+
+ The string containing the name of the constructor, method, property, or field member to invoke.
+
+ A bitmask comprised of one or morethat specify how the search is conducted. The access can be one of the BindingFlags such as Public, NonPublic, Private, InvokeMethod, GetField, and so on. The type of lookup need not be specified. If the type of lookup is omitted, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static are used.
+
+ An object that defines a set of properties and enables binding, which can involve selection of an overloaded method, coercion of argument types, and invocation of a member through reflection.
+
+ The object on which to invoke the specified member.
+
+ An array containing the arguments to pass to the member to invoke.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+
+ System.Diagnostics.DebuggerStepThrough
+
+
+
+ System.Object
+
+
+
+
+
+
+
+
+
+
+
+
+
+ is.
+
+
+ has more than one dimension.
+ -or-
+
+ is not a validvalue.
+ -or-
+ The member to be invoked is a constructor andis not specified in.
+ -or-
+ The member to be invoked is a method that is not a type initializer or instance constructor, andis not specified in.
+ -or-
+ The member to be accessed is a field, and neithernoris specified in.
+ -or-
+ The member to be accessed is a property, and neithernoris specified in.
+ -or-
+
+ containsand at least one of,,,, or.
+ -or-
+
+ contains bothand.
+ -or-
+
+ contains bothand.
+ -or-
+
+ containsand at least one ofor.
+ -or-
+
+ containsandhas more than one element.
+
+ A field or property matching the specified criteria was not found.
+
+ A method matching the specified criteria was not found.
+ -or-
+ The current instance object represents a type that contains open type parameters (that is,
+
+ returns
+
+ ).
+
+ The requested member is non-public and the caller does not have the required permission.
+ The member matching the specified criteria cannot be invoked on.
+ The member matching the specified criteria threw an exception.
+ More than one member matches the specified criteria.
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+ For an example that demonstrates, see(,,,,[],[],,[]).
+
+
+
+ Although the default binder does not process(theparameter), you can use the abstractclass to write a custom binder that does process.
+
+ You cannot useto invoke a generic method.
+
+ The followingfilter flags can be used to define which members to include in the search:
+
+
+ Specify BindingFlags.Public to include public members in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public members (that is, private, internal, and protected members) in the search.
+
+
+ Specify BindingFlags.FlattenHierarchy to include static members up the hierarchy.
+
+
+ The followingmodifier flags can be used to change how the search works:
+
+
+ BindingFlags.IgnoreCase to ignore the case of.
+
+
+ BindingFlags.DeclaredOnly to search only the members declared on the, not members that were simply inherited.
+
+
+ The followinginvocation flags can be used to denote what action to take with the member:
+
+
+ CreateInstance to invoke a constructor.is ignored. Not valid with other invocation flags.
+
+
+ InvokeMethod to invoke a method, but not a constructor or a type initializer. Not valid with SetField or SetProperty. If InvokeMethod is specified by itself, BindingFlags.Public, BindingFlags.Instance, and BindingFlags.Static are automatically included.
+
+
+ GetField to get the value of a field. Not valid with SetField.
+
+
+ SetField to set the value of a field. Not valid with GetField.
+
+
+ GetProperty to get a property. Not valid with SetProperty.
+
+
+ SetProperty to set a property. Not valid with GetProperty.
+
+
+ Seefor more information.
+ A method will be invoked if both of the following conditions are true:
+
+
+ The number of parameters in the method declaration equals the number of arguments in thearray (unless default arguments are defined on the member and BindingFlags.OptionalParamBinding is specified).
+
+
+ The type of each argument can be converted by the binder to the type of the parameter.
+
+
+ The binder will find all of the matching methods. These methods are found based upon the type of binding requested (values InvokeMethod, GetProperty, and so on). The set of methods is filtered by the name, number of arguments, and a set of search modifiers defined in the binder.
+ After the method is selected, it is invoked. Accessibility is checked at that point. The search may control which set of methods are searched based upon the accessibility attribute associated with the method. Themethod of theclass is responsible for selecting the method to be invoked. The default binder selects the most specific match.
+ Access restrictions are ignored for fully trusted code; that is, private constructors, methods, fields, and properties can be accessed and invoked through Reflection whenever the code is fully trusted.
+ You can use Type.InvokeMember to set a field to a particular value by specifying. For example, if you want to set a public instance field named F on class C, and F is a String you can use code such as:
+ typeof(C).InvokeMember("F", BindingFlags.SetField, null, c, new Object[] {"strings new value"}, null);
+ If F is a String[], you can use code such as:
+ typeof(C).InvokeMember("F", BindingFlags.SetField, null, c, new Object[] {new String[]{"a","z","c","d"}}, null);
+ which will initialize the field F to this new array. You can also use Type.InvokeMember to set a position in an array by supplying the index of the value and then the next value by using code such as the following:
+ typeof(C).InvokeMember("F", BindingFlags.SetField, null, c, new Object[] {1, "b"}, null);
+ This will change string "z" in the array that F holds to string "b".
+ When you invoke anIDispatchmember you can specify the DispID instead of the member name, using the string format "[DispID=##]". For example, if the DispID of MyComMethod is 3, you can specify the string "[DispID=3]" instead of "MyComMethod". Invoking a member by DispID is faster than looking up the member by name. In complex aggregation scenarios, the DispID is sometimes the only way to invoke the desired member.
+
+ Starting with the net_v20sp1_long, this method can be used to access non-public members if the caller has been grantedwith theflag and if the grant set of the non-public members is restricted to the caller’s grant set, or a subset thereof. (See
+ Security Considerations for Reflection
+ .)
+ To use this functionality, your application should target the net_v35_long or later.
+
+
+
+
+ Invokes the specified member, using the specified binding constraints and matching the specified argument list and culture.
+
+
+
+ An object representing the return value of the invoked member.
+
+
+ The string containing the name of the constructor, method, property, or field member to invoke.
+
+ A bitmask comprised of one or morethat specify how the search is conducted. The access can be one of the BindingFlags such as Public, NonPublic, Private, InvokeMethod, GetField, and so on. The type of lookup need not be specified. If the type of lookup is omitted, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static are used.
+
+ An object that defines a set of properties and enables binding, which can involve selection of an overloaded method, coercion of argument types, and invocation of a member through reflection.
+
+ The object on which to invoke the specified member.
+
+ An array containing the arguments to pass to the member to invoke.
+
+ The object representing the globalization locale to use, which may be necessary for locale-specific conversions, such as converting a numericto a.
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Object
+
+
+
+
+
+
+
+
+
+
+
+
+
+ is.
+
+
+ has more than one dimension.
+ -or-
+
+ is not a validvalue.
+ -or-
+ The member to be invoked is a constructor andis not specified in.
+ -or-
+ The member to be invoked is a method that is not a type initializer or instance constructor, andis not specified in.
+ -or-
+ The member to be accessed is a field, and neithernoris specified in.
+ -or-
+ The member to be accessed is a property, and neithernoris specified in.
+ -or-
+
+ containsand at least one of,,,, or.
+ -or-
+
+ contains bothand.
+ -or-
+
+ contains bothand.
+ -or-
+
+ containsand at least one ofor.
+ -or-
+
+ containsandhas more than one element.
+ -or-
+
+ .Length >.Length .
+ -or-
+ At least one element inis.
+ -or-
+ At least one element inis not assignment-compatible with the corresponding parameter in.
+
+ A field or property matching the specified criteria was not found.
+
+ A method matching the specified criteria cannot be found.
+ -or-
+ The current instance object represents a type that contains open type parameters (that is,
+
+ returns
+
+ ).
+
+ The requested member is non-public and the caller does not have the required permission.
+ The member matching the specified criteria cannot be invoked on.
+ The member matching the specified criteria threw an exception.
+ More than one member matches the specified criteria.
+ Requires permission to retrieve information on non-public members of types in loaded assemblies. See.
+
+ The following example demonstrates the use ofto
+ construct a, obtain itsproperty, invokeon it, and
+ then set its value using thefield.
+ using System;
+using System.Reflection;
+
+class InvokeMemberExample
+{
+ static void Main(string[] args)
+ {
+ // Create the parameter arrays that will
+ // be passed to InvokeMember.
+ char[] cAry =
+ new char[] {'A',' ','s','t','r','i','n','g'};
+ object[] oAry = new object[] {cAry, 0, cAry.Length};
+
+ Type t = typeof(string);
+
+ // Invoke the constructor of a string.
+ string str =
+ (string)t.InvokeMember(null, BindingFlags.Instance |
+ BindingFlags.Public | BindingFlags.CreateInstance, null,
+ null, oAry, null, null, null);
+ Console.WriteLine("The string is \"{0}\".", str);
+
+ // Access a property of the string.
+ int i =
+ (int) t.InvokeMember("Length", BindingFlags.Instance |
+ BindingFlags.Public | BindingFlags.GetProperty, null,
+ str, null, null, null, null);
+ Console.WriteLine("The length of the string is {0}.", i);
+
+ // Invoke a method on the string.
+ string newStr = "new ";
+ object[] oAry2 = new Object[] {2, newStr};
+ str = (string) t.InvokeMember("Insert", BindingFlags.Instance |
+ BindingFlags.Public | BindingFlags.InvokeMethod, null, str,
+ oAry2, null, null, null);
+ Console.WriteLine("The modified string is \"{0}\".", str);
+
+ // Access a field of the string.
+ str = (string) t.InvokeMember("Empty", BindingFlags.Static |
+ BindingFlags.Public | BindingFlags.GetField, null, str,
+ null);
+ Console.WriteLine("The empty string is \"{0}\".", str);
+
+ }
+}
+ The output is
+
+ The string is "A string".
+ The length of the string is 8.
+ The modified string is "A new string"
+ The empty string is "".
+
+
+
+
+ InvokeMember calls a constructor member or a method member, gets or sets a property member, gets or sets a data field member, or gets or sets an element of an array member.
+
+ You cannot useto invoke a generic method.
+
+ When you invoke anIDispatchmember you can specify the DispID instead of the member name, using the string format "[DispID=##]". For example, if the DispID of MyComMethod is 3, you can specify the string "[DispID=3]" instead of "MyComMethod". Invoking a member by DispID is faster than looking up the member by name. In complex aggregation scenarios, the DispID is sometimes the only way to invoke the desired member.
+ Although the default binder does not processor(theandparameters), you can use the abstractclass to write a custom binder that does processand. ParameterModifier is only used when calling through COM interop, and only parameters that are passed by reference are handled.
+ Each parameter in thearray gets the value in the corresponding element in thearray. If the length ofis greater than the length of, the remaining argument values are passed in order.
+ Thearray can be used to change the order of arguments in an input array. For example, given the method M(string a, int b) (M(ByVal a As String, ByVal b As Integer) in Visual Basic) and the input array { 42, "x" }, the input array can be passed unchanged toif the array { "b", "a" } is supplied for.
+ The followingfilter flags can be used to define which members to include in the search:
+
+
+ Specify BindingFlags.Public to include public members in the search.
+
+
+ Specify BindingFlags.NonPublic to include non-public members (that is, private, internal, and protected members) in the search.
+
+
+ Specify BindingFlags.FlattenHierarchy to include static members up the hierarchy.
+
+
+ The followingmodifier flags can be used to change how the search works:
+
+
+ BindingFlags.IgnoreCase to ignore the case of.
+
+
+ BindingFlags.DeclaredOnly to search only the members declared on the, not members that were simply inherited.
+
+
+ The followinginvocation flags can be used to denote what action to take with the member:
+
+
+ CreateInstance to invoke a constructor.is ignored. Not valid with other invocation flags.
+
+
+ InvokeMethod to invoke a method, but not a constructor or a type initializer. Not valid with SetField or SetProperty. If InvokeMethod is specified by itself, BindingFlags.Public, BindingFlags.Instance, and BindingFlags.Static are automatically included.
+
+
+ GetField to get the value of a field. Not valid with SetField.
+
+
+ SetField to set the value of a field. Not valid with GetField.
+
+
+ GetProperty to get a property. Not valid with SetProperty.
+
+
+ SetProperty to set a property. Not valid with GetProperty.
+
+
+ Seefor more information.
+ A method will be invoked if both of the following conditions are true:
+
+
+ The number of parameters in the method declaration equals the number of arguments in thearray (unless default arguments are defined on the member and BindingFlags.OptionalParamBinding is specified).
+
+
+ The type of each argument can be converted by the binder to the type of the parameter.
+
+
+ The binder will find all of the matching methods. These methods are found based upon the type of binding requested (values InvokeMethod, GetProperty, and so on). The set of methods is filtered by the name, number of arguments, and a set of search modifiers defined in the binder.
+ After the method is selected, it is invoked. Accessibility is checked at that point. The search may control which set of methods are searched based upon the accessibility attribute associated with the method. Themethod of theclass is responsible for selecting the method to be invoked. The default binder selects the most specific match.
+ InvokeMember can be used to invoke methods with parameters that have default values. To bind to these methods, Reflection requiresto be specified. For a parameter that has a default value, you can either supply a different value, or supplyto use the default value.
+ For example, consider a method such as MyMethod(int x, float y = 2.0). To invoke this method with only the first argument as MyMethod(4), pass one of the above binding flags and pass two arguments, namely, 4 for the first argument and Missing.Value for the second argument. Unless you use Missing.Value, you may not omit optional parameters with the Invoke method. If you must do so, use InvokeMember instead.
+ Access restrictions are ignored for fully trusted code; that is, private constructors, methods, fields, and properties can be accessed and invoked throughwhenever the code is fully trusted.
+ You can use Type.InvokeMember to set a field to a particular value by specifying. For example, if you want to set a public instance field named F on class C, and F is a String, you can use code such as:
+ typeof(C).InvokeMember("F", BindingFlags.SetField, null, c, new Object[] {"strings new value"}, null, null, null);
+ If F is a String[], you can use code such as:
+ typeof(C).InvokeMember("F", BindingFlags.SetField, null, c, new Object[] {new String[]{"a","z","c","d"}}, null, null, null);
+ which will initialize the field F to this new array. You can also use Type.InvokeMember to set a position in an array by supplying the index of the value and then the next value by using code such as the following:
+ typeof(C).InvokeMember("F", BindingFlags.SetField, null, c, new Object[] {1, "b"}, null, null, null);
+ This will change string "z" in the array that F holds to string "b".
+
+ Starting with the net_v20sp1_long, this method can be used to access non-public members if the caller has been grantedwith theflag and if the grant set of the non-public members is restricted to the caller’s grant set, or a subset thereof. (See
+ Security Considerations for Reflection
+ .)
+ To use this functionality, your application should target the net_v35_long or later.
+
+
+
+
+ When overridden in a derived class, invokes the specified member, using the specified binding constraints and matching the specified argument list, modifiers and culture.
+
+
+
+ An object representing the return value of the invoked member.
+
+
+ The string containing the name of the constructor, method, property, or field member to invoke.
+
+ A bitmask comprised of one or morethat specify how the search is conducted. The access can be one of the BindingFlags such as Public, NonPublic, Private, InvokeMethod, GetField, and so on. The type of lookup need not be specified. If the type of lookup is omitted, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static are used.
+
+ An object that defines a set of properties and enables binding, which can involve selection of an overloaded method, coercion of argument types, and invocation of a member through reflection.
+
+ The object on which to invoke the specified member.
+
+ An array containing the arguments to pass to the member to invoke.
+
+ An array ofobjects representing the attributes associated with the corresponding element in thearray. A parameter's associated attributes are stored in the member's signature.
+
+ Theobject representing the globalization locale to use, which may be necessary for locale-specific conversions, such as converting a numeric String to a Double.
+
+ An array containing the names of the parameters to which the values in thearray are passed.
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if theis abstract; otherwise,.
+
+
+
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this property always returns false.
+
+
+
+ Gets a value indicating whether theis abstract and must be overridden.
+
+
+ 1
+ Reflection
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+ if the type attributeis selected for the current type; otherwise,.
+
+
+ Theselects the string format attributes. The string format attributes enhance interoperability by defining how strings should be interpreted.
+ If the currentrepresents a generic type, this property pertains to the generic type definition from which the type was constructed. For example, if the currentrepresents MyGenericType<int> (MyGenericType(Of Integer) in Visual Basic), the value of this property is determined by MyGenericType<T>.
+ If the currentrepresents a type parameter of a generic type, this property always returns false.
+
+
+
+ Gets a value indicating whether the string format attribute AnsiClass is selected for the.
+
+
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if the currentrepresents an
+ array; otherwise.
+
+
+ The following example demonstrates using theproperty.
+ using System;
+class TestType {
+ public static void Main() {
+ int [] array = {1,2,3,4};
+ Type at = typeof(Array);
+ Type t = array.GetType();
+ Console.WriteLine("Type is {0}. IsArray? {1}", at, at.IsArray);
+ Console.WriteLine("Type is {0}. IsArray? {1}", t, t.IsArray);
+ }
+}
+ The output is
+
+ Type is System.Array. IsArray? False
+ Type is System.Int32[]. IsArray? True
+
+
+
+
+ Theproperty returns false for theclass.
+ To check for an array, use code such as typeof(Array).IsAssignableFrom(type).
+ If the currentrepresents a generic type, or a type parameter in the definition of a generic type or generic method, this property always returns false.
+ This property is read-only.
+
+
+
+ Gets a value indicating whether theis an array.
+
+
+ 0
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ An instance of theclass must return false because it is an object, not an array.
+
+
+
+ When overridden in a derived class, implements theproperty and determines whether theis an array.
+
+
+
+ true if theis an array; otherwise, false.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+
+ The following example demonstrates themethod using arrays.
+ using System;
+class ArrayTypeTest {
+ public static void Main() {
+ int i = 1;
+ int [] array10 = new int [10];
+ int [] array2 = new int[2];
+ int [,]array22 = new int[2,2];
+ int [,]array24 = new int[2,4];
+ int [,,]array333 = new int[3,3,3];
+ Type array10Type = array10.GetType();
+ Type array2Type = array2.GetType();
+ Type array22Type = array22.GetType();
+ Type array24Type = array24.GetType();
+ Type array333Type = array333.GetType();
+
+ // If X and Y are not both arrays, then false
+ Console.WriteLine("int[2] is assignable from int? {0} ", array2Type.IsAssignableFrom(i.GetType()));
+ // If X and Y have same type and rank, then true.
+ Console.WriteLine("int[2] is assignable from int[10]? {0} ", array2Type.IsAssignableFrom(array10Type));
+ Console.WriteLine("int[2,2] is assignable from int[2,4]? {0}", array22Type.IsAssignableFrom(array24Type));
+ Console.WriteLine("int[2,4] is assignable from int[2,2]? {0}", array24Type.IsAssignableFrom(array22Type));
+ Console.WriteLine("");
+ // If X and Y do not have the same rank, then false.
+ Console.WriteLine("int[2,2] is assignable from int[10]? {0}", array22Type.IsAssignableFrom(array10Type));
+ Console.WriteLine("int[2,2] is assignable from int[3,3,3]? {0}", array22Type.IsAssignableFrom(array333Type));
+ Console.WriteLine("int[3,3,3] is assignable from int[2,2]? {0}", array333Type.IsAssignableFrom(array22Type));
+ }
+}
+ The output is
+
+ int[2] is assignable from int? False
+ int[2] is assignable from int[10]? True
+ int[2,2] is assignable from int[2,4]? True
+ int[2,4] is assignable from int[2,2]? True
+ int[2,2] is assignable from int[10]? False
+ int[2,2] is assignable from int[3,3,3]? False
+ int[3,3,3] is assignable from int[2,2]? False
+
+
+
+
+ This method can be overridden by a derived class.
+
+ A generic type definition is not assignable from a closed constructed type. That is, you cannot assign the closed constructed type MyGenericList<int> (MyGenericList(Of Integer) in Visual Basic) to a variable of type MyGenericList<T>.
+
+ You can determine the element types of a Type using.
+ If theparameter is of type, the result is based on the type that is to be built. The following code example demonstrates this using a built type named B.
+ TypeBuilder b1 = moduleBuilder.DefineType("B", TypeAttributes.Public, typeof(A));
+// Returns true:
+typeof(A).IsAssignableFrom(b1))
+
+
+
+ Determines whether an instance of the currentcan be assigned from an instance of the specified Type.
+
+
+
+ true ifand the current Type represent the same type, or if the current Type is in the inheritance hierarchy of, or if the current Type is an interface thatimplements, or ifis a generic type parameter and the current Type represents one of the constraints of, or ifrepresents a value type and the current Type represents Nullable<c> (Nullable(Of c) in Visual Basic). false if none of these conditions are true, or ifis null.
+
+
+ The type to compare with the current type.
+
+ 0
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+ if the type attributeis selected for the current type; otherwise,.
+
+
+ Theselects the string format attributes. The string format attributes enhance interoperability by defining how strings should be interpreted.
+ If the currentrepresents a constructed generic type, this property applies to the generic type definition from which the type was constructed. For example, if the currentrepresents MyGenericType<int> (MyGenericType(Of Integer) in Visual Basic), the value of this property is determined by MyGenericType<T>.
+ If the currentrepresents a type parameter of a generic type, this property always returns false.
+
+
+
+ Gets a value indicating whether the string format attribute AutoClass is selected for the.
+
+
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if the type
+ layout attributeis specified for the current; otherwise,.
+
+
+
+ This property is provided as a convenience. Alternatively, you can use theenumeration value to select the type layout attributes, and then test whetheris set. The,, andenumeration values indicate the way the fields of the type are laid out in memory.
+ For dynamic types, you can specifywhen you create the type. In code, apply theattribute with theenumeration value to the type, to let the runtime determine the appropriate way to lay out the class.
+
+ You cannot use themethod to determine whether thehas been applied to a type.
+
+ If the currentrepresents a constructed generic type, this property applies to the generic type definition from which the type was constructed. For example, if the currentrepresents MyGenericType<int> (MyGenericType(Of Integer) in Visual Basic), the value of this property is determined by MyGenericType<T>.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this property always returns false.
+
+
+
+ Gets a value indicating whether the fields of the current type are laid out automatically by the common language runtime.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if theis passed by reference; otherwise,.
+
+
+
+ To get to the actual type, dereference the type that was passed by reference, and then callon that type.
+
+
+
+ Gets a value indicating whether theis passed by reference.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ As described above.
+
+
+
+
+ When overridden in a derived class, implements theproperty and determines whether theis passed by reference.
+
+
+
+ true if theis passed by reference; otherwise, false.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if the currentrepresents a class;
+ otherwise.
+
+
+
+ This property returns true for value types even if they are boxed.
+ Thedistinguishes a type declaration as class, interface, or value type.
+ If the currentrepresents a constructed generic type, this property returns true if the generic type definition is a class definition; that is, it does not define an interface or a value type.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this property always returns false.
+
+ This property returns true for Type instances that represent theandclasses. These two classes are the base types for enumerations and value types, respectively, but they are not enumerations or value types themselves. For more information, see theandproperties.
+
+ This property is read-only.
+
+
+
+ Gets a value indicating whether theis a class; that is, not a value type or interface.
+
+
+ 0
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+ To be added.
+
+
+ This method returns false for COM interfaces because they are not objects. COM interfaces can be implemented by Microsoft .NET Framework objects.
+ You can also load a COM class and get a Type object for that COM class by using the
+ [<topic://cpgrftypelibraryimportertlbimpexe>]
+ tool.
+ If the currentrepresents a constructed generic type, this property applies to the generic type definition from which the type was constructed. For example, if the currentrepresents MyGenericType<int> (MyGenericType(Of Integer) in Visual Basic), the value of this property is determined by MyGenericType<T>.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this property always returns false.
+
+
+
+ Gets a value indicating whether theis a COM object.
+
+
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ This method returns false for COM interfaces because they are not objects. COM interfaces can be implemented by Microsoft .NET Framework objects.
+
+
+
+ When overridden in a derived class, implements theproperty and determines whether theis a COM object.
+
+
+
+ true if theis a COM object; otherwise, false.
+
+
+ 1
+ Reflection
+
+
+
+
+ Property
+
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+ To be added.
+
+
+ A constructed generic type has had explicit types supplied for all of its generic type parameters. It is also referred to as a closed generic type.
+ When this property is true, you can create instances of the current type; when it is false, you can't.
+
+
+
+ Gets a value that indicates whether this object represents a constructed generic type. You can create instances of a constructed generic type.
+
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+ To be added.
+
+
+ A context intercepts calls to the class members and enforces policies that are applied to the class, such as synchronization. For more detailed information on remoting contexts, see.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this property always returns false.
+
+
+
+ Gets a value indicating whether thecan be hosted in a context.
+
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ This method can be overridden by a derived class.
+ A context intercepts calls to the class members and enforce policies that are applied to the class, such as synchronization.
+
+
+
+ Implements theproperty and determines whether thecan be hosted in a context.
+
+
+
+ true if thecan be hosted in a context; otherwise, false.
+
+
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if the currentrepresents an
+ enumeration; otherwise.
+
+
+ The following example demonstrates using theproperty.
+ using System;
+public enum Color {
+Red, Blue, Green
+}
+class TestType {
+ public static void Main() {
+ Type colorType = typeof(Color);
+ Type enumType = typeof(Enum);
+ Console.WriteLine("Color is enum ? {0}", colorType.IsEnum);
+ Console.WriteLine("Color is valueType? {0}", colorType.IsValueType);
+ Console.WriteLine("Enum is enum Type? {0}", enumType.IsEnum);
+ Console.WriteLine("Enum is value? {0}", enumType.IsValueType);
+ }
+}
+ The output is
+
+ Color is enum ? True
+ Color is valueType? True
+ Enum is enum Type? False
+ Enum is value? False
+
+
+
+
+ This property returns true for an enumeration, but not for thetype itself.
+ If the currentrepresents a constructed generic type, this property applies to the generic type definition from which the type was constructed. For example, if the currentrepresents MyGenericType<int> (MyGenericType(Of Integer) in Visual Basic), the value of this property is determined by MyGenericType<T>.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this property always returns false.
+ This property is read-only.
+
+
+
+ Gets a value indicating whether the currentrepresents an enumeration.
+
+
+ 0
+
+
+
+
+ Method
+
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ To be added.
+
+
+ Returns a value that indicates whether the specified value exists in the current enumeration type.
+
+
+
+ true if the specified value is a member of the current enumeration type; otherwise, false.
+
+
+ The value to be tested.
+
+
+
+
+
+ Method
+
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+
+
+ Beginning with the net_v40_long, the common language runtime supports the embedding of type information for COM types directly into managed assemblies, instead of requiring the managed assemblies to obtain type information for COM types from interop assemblies. Because the embedded type information includes only the types and members that are actually used by a managed assembly, two managed assemblies might have very different views of the same COM type. Each managed assembly has a differentobject to represent its view of the COM type. The common language runtime supports type equivalence between these different views for interfaces, structures, enumerations, and delegates.
+ Type equivalence means that a COM object that is passed from one managed assembly to another can be cast to the appropriate managed type in the receiving assembly. Themethod enables an assembly to determine that a COM object obtained from another assembly has the same COM identity as one of the first assembly's own embedded interop types, and thus can be cast to that type.
+ For more information, see
+ Type Equivalence and Embedded Interop Types
+ .
+
+
+
+ Determines whether two COM types have the same identity and are eligible for type equivalence.
+
+
+
+ true if the COM types are equivalent; otherwise, false. This method also returns false if one type is in an assembly that is loaded for execution, and the other is in an assembly that is loaded into the reflection-only context.
+
+
+ The COM type that is tested for equivalence with the current type.
+
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if the type layout attributeis specified for the current; otherwise,.
+
+
+
+ This property is provided as a convenience. Alternatively, you can use theenumeration value to select the type layout attributes, and then test whetheris set. The,, andenumeration values indicate the way the fields of the type are laid out in memory.
+ For dynamic types, you can specifywhen you create the type. In code, apply theattribute with theenumeration value to the type, to specify that the offsets at which the fields start are specified explicitly.
+
+ You cannot use themethod to determine whether thehas been applied to a type.
+
+ If the currentrepresents a constructed generic type, this property applies to the generic type definition from which the type was constructed. For example, if the currentrepresents MyGenericType<int> (MyGenericType(Of Integer) in Visual Basic), the value of this property is determined by MyGenericType<T>.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this property always returns false.
+
+
+
+ Gets a value indicating whether the fields of the current type are laid out at explicitly specified offsets.
+
+
+ 1
+ Reflection
+
+
+
+
+ Property
+
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+ if the current object represents a type parameter of a generic type or method; otherwise.
+
+
+ For an example of using this method, see the example for.
+
+
+
+
+ objects that represent generic type parameters can be obtained by calling themethod of aobject that represents a generic type definition, or themethod of aobject that represents a generic method definition.
+
+
+ For a generic type or method definition, theproperty returns true for every element of the resulting array.
+
+
+ For a closed constructed type or method, theproperty returns false for every element of the array returned by themethod.
+
+
+ For an open constructed type or method, some elements of the array might be specific types and others might be type parameters.returns false for the types and true for the type parameters. The code example for theproperty demonstrates a generic class with a mixture of types and type parameters.
+
+
+ For a list of the invariant conditions for terms used in generic reflection, see theproperty remarks.
+
+
+
+ Gets a value indicating whether the currentrepresents a type parameter in the definition of a generic type or method.
+
+
+
+
+
+
+ Property
+
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+ if the current type has type arguments; otherwise.
+
+
+ For an example of using this method, see the example for.
+
+
+
+ Use theproperty to determine whether aobject represents a generic type. Use theproperty to determine whether aobject represents an open constructed type or a closed constructed type.
+
+ Theproperty returns false if the immediate type is not generic. For example, an array whose elements are of type A<int> (A(Of Integer) in Visual Basic) is not itself a generic type.
+
+ The following table summarizes the invariant conditions for common terms used in generic reflection.
+
+
+
+
+ Term
+
+
+ Invariant
+
+
+
+
+
+ generic type definition
+
+
+ Theproperty is true.
+ Defines a generic type. A constructed type is created by calling themethod on aobject that represents a generic type definition and specifying an array of type arguments.
+
+ can be called only on generic type definitions.
+ Any generic type definition is a generic type (theproperty is true), but the converse is not true.
+
+
+
+
+ generic type
+
+
+ Theproperty is true.
+ Can be a generic type definition, an open constructed type, or a closed constructed type.
+ Note that an array type whose element type is generic is not itself a generic type. The same is true of aobject representing a pointer to a generic type.
+
+
+
+
+ open constructed type
+
+
+ Theproperty is true.
+ Examples are a generic type that has unassigned type parameters, a type that is nested in a generic type definition or in an open constructed type, or a generic type that has a type argument for which theproperty is true.
+ It is not possible to create an instance of an open constructed type.
+ Note that not all open constructed types are generic. For example, an array whose element type is a generic type definition is not generic, and a pointer to an open constructed type is not generic.
+
+
+
+
+ closed constructed type
+
+
+ Theproperty is false.
+ When examined recursively, the type has no unassigned generic parameters.
+
+
+
+
+ generic type parameter
+
+
+ Theproperty is true.
+ Theproperty is true.
+ In a generic type definition, a placeholder for a type that will be assigned later.
+
+
+
+
+ generic type argument
+
+
+ Can be any type, including a generic type parameter.
+ Type arguments are specified as an array ofobjects passed to themethod when creating a constructed generic type. If instances of the resulting type are to be created, theproperty must be false for all the type arguments.
+
+
+
+ The following code example and table illustrate some of these terms and invariants. The Derived class is of particular interest because its base type is a constructed type that has a mixture of types and type parameters in its type argument list.
+ code reference: System.Type.IsGenericType#2
+ The following table shows examples that use and build on the classes Base, Derived, and G. When the C++ and C# code is the same, only one entry is shown.
+
+
+
+
+ Example
+
+
+ Invariants
+
+
+
+
+
+ Derived(Of V)
+ Derived<V>
+
+
+ For this type:
+ is true.
+ is true.
+ is true.
+
+
+
+
+ Base(Of String, V)
+ Base<String,V>
+ Base<String^,V>
+
+
+ For this type:
+ is true.
+ is false.
+ is true.
+
+
+
+
+ Dim d() As Derived(Of Integer)
+ Derived<int>[] d;
+ array<Derived<int>^>^ d;
+
+
+ For the type of variable d:
+
+ is false because d is an array.
+ is false.
+ is false.
+
+
+
+
+ T, U, and V (everywhere they appear)
+
+
+ is true.
+
+ is false because there is no way to constrain a type parameter to generic types.
+ is false.
+
+ is true because T, U, and V are themselves generic type parameters. This does not imply anything about type arguments that are assigned to them later.
+
+
+
+
+ The type of field F
+
+
+ is true.
+
+ is false because a type has been assigned to to the type parameter of G. Note that this is equivalent to having called themethod.
+
+ is true because the type of field F has a type argument that is an open constructed type. The constructed type is open because its type argument (that is, Base) is a generic type definition. This illustrates the recursive nature of theproperty.
+
+
+
+
+ The nested class Nested
+
+
+
+ is true, even though the Nested class has no generic type parameters of its own, because it is nested in a generic type.
+
+ is true. That is, you can call themethod and supply the type parameter of the enclosing type, Derived.
+
+ is true because the enclosing type, Derived, has generic type parameters. This illustrates the recursive nature of theproperty.
+
+
+
+
+
+
+ Gets a value indicating whether the current type is a generic type.
+
+
+
+
+
+
+ Property
+
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+ if the current object represents the definition of a generic type, none of whose type parameters have been bound to specific types; otherwise.
+
+
+ For an example of using this method, see the example for.
+
+
+
+ A generic type definition is a template from which other types can be constructed. For example, from the generic type definition G<T> (expressed in C# syntax; G(Of T) in Visual Basic or generic <typename T> ref class G in C++) you can construct and instantiate the type G<int> (G(Of Integer) in Visual Basic), by calling themethod with a generic argument list containing thetype. Given aobject representing this constructed type, themethod gets the generic type definition back again.
+ Use theproperty to determine whether you can create new types from the current type. If theproperty returns true, you can call themethod to create new generic types.
+ For a list of the invariant conditions for terms used in generic reflection, see theproperty remarks.
+
+
+
+ Gets a value indicating whether the currentrepresents a generic type definition, from which other generic types can be constructed.
+
+
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if thewas imported from another class; otherwise,.
+
+
+
+ If the currentrepresents a constructed generic type, this property applies to the generic type definition from which the type was constructed. For example, if the currentrepresents MyGenericType<int> (MyGenericType(Of Integer) in Visual Basic), the value of this property is determined by MyGenericType<T>.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this property always returns false.
+
+
+
+ Gets a value indicating whether thehas aattribute applied, indicating that it was imported from a COM type library.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+
+ The following example demonstrates themethod.
+ using System;
+public interface IFoo { }
+public class MyClass : IFoo {}
+public class MyDerivedClass : MyClass {}
+class IsInstanceTest {
+ public static void Main() {
+ Type ifooType=typeof(IFoo);
+ MyClass mc = new MyClass();
+ Type mcType = mc.GetType();
+ MyClass mdc = new MyDerivedClass();
+ Type mdcType = mdc.GetType();
+ int [] array = new int [10];
+ Type arrayType = typeof(Array);
+ Console.WriteLine("int[] is instance of Array? {0}", arrayType.IsInstanceOfType(array));
+ Console.WriteLine("myclass instance is instance of MyClass? {0}", mcType.IsInstanceOfType(mc));
+ Console.WriteLine("myderivedclass instance is instance of MyClass? {0}", mcType.IsInstanceOfType(mdc));
+ Console.WriteLine("myclass instance is instance of IFoo? {0}", ifooType.IsInstanceOfType(mc));
+ Console.WriteLine("myderivedclass instance is instance of IFoo? {0}", ifooType.IsInstanceOfType(mdc));
+ }
+}
+ The output is
+
+ int[] is instance of Array? True
+ myclass instance is instance of MyClass? True
+ myderivedclass instance is instance of MyClass? True
+ myclass instance is instance of IFoo? True
+ myderivedclass instance is instance of IFoo? True
+
+
+
+
+ This method can be overridden by a derived class.
+
+ A constructed type is not an instance of its generic type definition. That is, MyGenericList<int> (MyGenericList(Of Integer) in Visual Basic) is not an instance of MyGenericList<T> (MyGenericList(Of T) in Visual Basic).
+
+
+
+
+ Determines whether the specified object is an instance of the current.
+
+
+
+ true if the current Type is in the inheritance hierarchy of the object represented by, or if the current Type is an interface thatsupports. false if neither of these conditions is the case, or ifis null, or if the current Type is an open generic type (that is,returns true).
+
+
+ The object to compare with the current type.
+
+ 0
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if the currentrepresents an
+ interface; otherwise.
+
+
+
+ Thedistinguishes a type declaration as class, interface or value type.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this property always returns false.
+ This property is read-only.
+
+
+
+ Gets a value indicating whether theis an interface; that is, not a class or a value type.
+
+
+ 0
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if the type layout attributeis specified for the current; otherwise,.
+
+
+
+ This property is provided as a convenience. Alternatively, you can use theenumeration value to select the type layout attributes, and then test whetheris set. The,, andenumeration values indicate the way the fields of the type are laid out in memory.
+ For dynamic types, you can specifywhen you create the type. In code, apply theattribute with theenumeration value to the type, to specify that layout is sequential.
+
+ You cannot use themethod to determine whether thehas been applied to a type.
+
+ For more information, see section 9.1.2 of the specification for the Common Language Infrastructure (CLI) documentation, "Partition II: Metadata Definition and Semantics". The documentation is available online; seeECMA C# and Common Language Infrastructure Standardson MSDN andStandard ECMA-335 - Common Language Infrastructure (CLI)on the Ecma International Web site.
+ If the currentrepresents a constructed generic type, this property applies to the generic type definition from which the type was constructed. For example, if the currentrepresents MyGenericType<int> (MyGenericType(Of Integer) in Visual Basic), the value of this property is determined by MyGenericType<T>.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this property always returns false.
+
+
+
+ Gets a value indicating whether the fields of the current type are laid out sequentially, in the order that they were defined or emitted to the metadata.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if theis marshaled by reference; otherwise,.
+
+
+ This property is read-only.
+
+
+
+ Gets a value indicating whether theis marshaled by reference.
+
+
+ 1
+ Reflection
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ This method can be overridden by a derived class.
+
+
+
+ Implements theproperty and determines whether theis marshaled by reference.
+
+
+
+ true if theis marshaled by reference; otherwise, false.
+
+
+
+
+
+
+ Property
+
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+ To be added.
+
+
+
+ Theproperty returns true for all nested types, regardless of visibility. To test for nesting and visibility at the same time, use the related properties,,,,, or.
+
+ Theenumeration member selects the visibility attributes for a type.
+
+
+
+
+ Gets a value indicating whether the currentobject represents a type whose definition is nested inside the definition of another type.
+
+
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if theis nested and visible only within its own assembly; otherwise,.
+
+
+
+ If the currentrepresents a type parameter of a generic type, this property always returns false.
+
+ selects the visibility attributes.
+
+
+
+ Gets a value indicating whether theis nested and visible only within its own assembly.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if theis nested
+ and visible only to classes that belong to both its own family and its own assembly; otherwise,.
+
+
+
+ If the currentrepresents a type parameter of a generic type, this property always returns false.
+
+ selects the visibility attributes.
+ Aobject's family is defined as all objects of the exact sameand of its subtypes.
+
+
+
+ Gets a value indicating whether theis nested and visible only to classes that belong to both its own family and its own assembly.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if theis nested
+ and visible only within its own family; otherwise,.
+
+
+
+ If the currentrepresents a type parameter of a generic type, this property always returns false.
+
+ selects the visibility attributes.
+ Aobject's family is defined as all objects of the exact sameand of its subtypes.
+
+
+
+ Gets a value indicating whether theis nested and visible only within its own family.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if theis nested
+ and visible only to classes that belong to its own family or to its own assembly; otherwise,.
+
+
+
+ If the currentrepresents a type parameter of a generic type, this property always returns false.
+
+ selects the visibility attributes.
+ Aobject's family is defined as all objects of the exact sameand of its subtypes.
+
+
+
+ Gets a value indicating whether theis nested and visible only to classes that belong to either its own family or to its own assembly.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if theis nested and declared private; otherwise,.
+
+
+
+ If the currentrepresents a type parameter of a generic type, this property always returns false.
+
+ selects the visibility attributes.
+
+
+
+ Gets a value indicating whether theis nested and declared private.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if
+ the class is nested and declared public; otherwise,.
+
+
+
+ If the currentrepresents a type parameter of a generic type, this property always returns false.
+
+ selects the visibility attributes.
+
+
+
+ Gets a value indicating whether a class is nested and declared public.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if the
+ top-levelis not declared public; otherwise,.
+
+
+
+ Do not use with nested types; useinstead.
+ If the currentrepresents a type parameter of a generic type, this property returns false.
+
+ selects the visibility attributes.
+
+
+
+ Gets a value indicating whether theis not declared public.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+ This property is read-only.
+
+ if the currentrepresents a
+ pointer; otherwise.
+
+
+
+ If the currentrepresents a generic type, or a type parameter in the definition of a generic type or generic method, this property always returns false.
+ This property is read-only.
+
+
+
+ Gets a value indicating whether theis a pointer.
+
+
+ 0
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ As described above.
+
+
+
+
+ When overridden in a derived class, implements theproperty and determines whether theis a pointer.
+
+
+
+ true if theis a pointer; otherwise, false.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if theis one of the primitive types; otherwise,.
+
+
+
+ The primitive types are,,,,,,,,,,,,, and.
+ If the currentrepresents a generic type, or a type parameter in the definition of a generic type or generic method, this property always returns false.
+
+
+
+ Gets a value indicating whether theis one of the primitive types.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ The primitive types are,,,,,,,,,,, and.
+
+
+
+ When overridden in a derived class, implements theproperty and determines whether theis one of the primitive types.
+
+
+
+ true if theis one of the primitive types; otherwise, false.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if the top-levelis declared public; otherwise,.
+
+
+
+ Do not use with nested types; useinstead.
+ If the currentrepresents a type parameter of a generic type, this property returns true.
+
+ selects the visibility attributes.
+
+
+
+ Gets a value indicating whether theis declared public.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if theis declared sealed; otherwise,.
+
+
+
+ If the currentrepresents a type parameter of a generic type, this property always returns true.
+
+
+
+ Gets a value indicating whether theis declared sealed.
+
+
+ 1
+ Reflection
+
+
+
+
+ Property
+
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+ To be added.
+
+
+ The,, andproperties report the transparency level of the type at its current trust level, as determined by the common language runtime (CLR). The combinations of these properties are shown in the following table:
+
+
+
+
+ Security level
+
+
+ IsSecurityCritical
+
+
+ IsSecuritySafeCritical
+
+
+ IsSecurityTransparent
+
+
+
+
+
+ Critical
+
+
+ true
+
+
+ false
+
+
+ false
+
+
+
+
+ Safe critical
+
+
+ true
+
+
+ true
+
+
+ false
+
+
+
+
+ Transparent
+
+
+ false
+
+
+ false
+
+
+ true
+
+
+
+ Using these properties is much simpler than examining the security annotations of an assembly and its types, checking the current trust level, and attempting to duplicate the runtime's rules.
+
+ For partial-trust assemblies, the value of this property depends on the current trust level of the assembly. If the assembly is loaded into a partially trusted application domain (for example, into a sandboxed application domain), then the runtime ignores the security annotations of the assembly. The assembly and all its types are treated as transparent. The runtime pays attention to the security annotations of a partial-trust assembly only when that assembly is loaded into a fully trusted application domain (for example, into the default application domain of a desktop application). By contrast, a trusted assembly (that is, a strong-named assembly that is installed in the global assembly cache) is always loaded with full trust regardless of the trust level of the application domain, so its current trust level is always fully trusted. You can determine the current trust levels of assemblies and application domains by using theandproperties.
+
+ For more information about reflection and transparency, see
+ Security Considerations for Reflection
+ . For information about transparency, see
+ Security Changes in the .NET Framework Version 4.0
+ .
+
+
+
+ Gets a value that indicates whether the current type is security-critical or security-safe-critical at the current trust level, and therefore can perform critical operations.
+
+
+
+
+
+
+ Property
+
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+ To be added.
+
+
+ The,, andproperties report the transparency level of the type at its current trust level, as determined by the common language runtime (CLR). The combinations of these properties are shown in the following table:
+
+
+
+
+ Security level
+
+
+ IsSecurityCritical
+
+
+ IsSecuritySafeCritical
+
+
+ IsSecurityTransparent
+
+
+
+
+
+ Critical
+
+
+ true
+
+
+ false
+
+
+ false
+
+
+
+
+ Safe critical
+
+
+ true
+
+
+ true
+
+
+ false
+
+
+
+
+ Transparent
+
+
+ false
+
+
+ false
+
+
+ true
+
+
+
+ Using these properties is much simpler than examining the security annotations of an assembly and its types, checking the current trust level, and attempting to duplicate the runtime's rules.
+
+ For partial-trust assemblies, the value of this property depends on the current trust level of the assembly. If the assembly is loaded into a partially trusted application domain (for example, into a sandboxed application domain), then the runtime ignores the security annotations of the assembly. The assembly and all its types are treated as transparent. The runtime pays attention to the security annotations of a partial-trust assembly only when that assembly is loaded into a fully trusted application domain (for example, into the default application domain of a desktop application). By contrast, a trusted assembly (that is, a strong-named assembly that is installed in the global assembly cache) is always loaded with full trust regardless of the trust level of the application domain, so its current trust level is always fully trusted. You can determine the current trust levels of assemblies and application domains by using theandproperties.
+
+ For more information about reflection and transparency, see
+ Security Considerations for Reflection
+ . For information about transparency, see
+ Security Changes in the .NET Framework Version 4.0
+ .
+
+
+
+ Gets a value that indicates whether the current type is security-safe-critical at the current trust level; that is, whether it can perform critical operations and can be accessed by transparent code.
+
+
+
+
+
+
+ Property
+
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+ To be added.
+
+
+ If this property returns true, theandproperties return false.
+ The,, andproperties report the transparency level of the type at its current trust level, as determined by the common language runtime (CLR). Using these properties is much simpler than examining the security annotations of an assembly and its types, checking the current trust level, and attempting to duplicate the runtime's rules.
+
+ For partial-trust assemblies, the value of this property depends on the current trust level of the assembly. If the assembly is loaded into a partially trusted application domain (for example, into a sandboxed application domain), then the runtime ignores the security annotations of the assembly. The assembly and all its types are treated as transparent. The runtime pays attention to the security annotations of a partial-trust assembly only when that assembly is loaded into a fully trusted application domain (for example, into the default application domain of a desktop application). By contrast, a trusted assembly (that is, a strong-named assembly that is installed in the global assembly cache) is always loaded with full trust regardless of the trust level of the application domain, so its current trust level is always fully trusted. You can determine the current trust levels of assemblies and application domains by using theandproperties.
+
+ For more information about reflection and transparency, see
+ Security Considerations for Reflection
+ . For information about transparency, see
+ Security Changes in the .NET Framework Version 4.0
+ .
+
+
+
+ Gets a value that indicates whether the current type is transparent at the current trust level, and therefore cannot perform critical operations.
+
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+ To be added.
+
+
+ If the currentrepresents a constructed generic type, this property applies to the generic type definition from which the type was constructed. For example, if the currentrepresents MyGenericType<int> (MyGenericType(Of Integer) in Visual Basic), the value of this property is determined by MyGenericType<T>.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this property always returns false.
+
+
+
+ Gets a value indicating whether theis serializable.
+
+
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if thehas a name that requires special handling; otherwise,.
+
+
+
+ Names that begin with or contain an underscore character (_), property accessors, and operator overloading methods are examples of types that might require special treatment by some compilers.
+ If the currentrepresents a constructed generic type, this property applies to the generic type definition from which the type was constructed. For example, if the currentrepresents MyGenericType<int> (MyGenericType(Of Integer) in Visual Basic), the value of this property is determined by MyGenericType<T>.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this property always returns false.
+
+
+
+ Gets a value indicating whether thehas a name that requires special handling.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+
+ System.Runtime.InteropServices.ComVisible(true)
+
+
+
+ System.Boolean
+
+
+
+
+
+
+ The following example demonstrates themethod.
+ using System;
+public interface IFoo { }
+public interface IBar:IFoo{}
+public class MyClass : IFoo {}
+public class MyDerivedClass : MyClass {}
+class IsSubclassTest {
+ public static void Main() {
+ Type ifooType = typeof(IFoo);
+ Type ibarType = typeof(IBar);
+ MyClass mc = new MyClass();
+ Type mcType = mc.GetType();
+ MyClass mdc = new MyDerivedClass();
+ Type mdcType = mdc.GetType();
+ int [] array = new int [10];
+ Type arrayOfIntsType = array.GetType();
+ Type arrayType = typeof(Array);
+
+ Console.WriteLine("Array is subclass of int[]? {0}", arrayType.IsSubclassOf(arrayOfIntsType));
+ Console.WriteLine("int [] is subclass of Array? {0}", arrayOfIntsType.IsSubclassOf(arrayType));
+ Console.WriteLine("IFoo is subclass of IBar? {0}", ifooType.IsSubclassOf(ibarType));
+ Console.WriteLine("myclass is subclass of MyClass? {0}", mcType.IsSubclassOf(mcType));
+ Console.WriteLine("myderivedclass is subclass of MyClass? {0}", mdcType.IsSubclassOf(mcType));
+ Console.WriteLine("IBar is subclass of IFoo? {0}", ibarType.IsSubclassOf(ifooType));
+ }
+}
+ The output is
+
+ Array is subclass of int[]? False
+ int [] is subclass of Array? True
+ IFoo is subclass of IBar? False
+ myclass is subclass of MyClass? False
+ myderivedclass is subclass of MyClass? True
+ IBar is subclass of IFoo? False
+
+
+
+
+ Themethod cannot be used to determine whether an interface derives from another interface, or whether a class implements an interface. Use themethod for that purpose. Note that if a type is dervived from an interface, this method returns true for that type being a subclass of.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, it derives from its class constraint or fromif it has no class constraint.
+
+ If theis the converse of. That is, if t1.IsSubclassOf(t2) is true, then t2.IsAssignableFrom(t1) is also true.
+
+ This method can be overridden by a derived class.
+
+
+
+ Determines whether the class represented by the currentderives from the class represented by the specified.
+
+
+
+ true if the Type represented by theparameter and the current Type represent classes, and the class represented by the current Type derives from the class represented by; otherwise, false. This method also returns false ifand the current Type represent the same class.
+
+
+ The type to compare with the current type.
+
+ 0
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+ if the type attributeis selected for the current type; otherwise,.
+
+
+ Theis used to select the string format attributes. The string format attributes enhance interoperability by defining how strings should be interpreted.
+ If the currentrepresents a constructed generic type, this property applies to the generic type definition from which the type was constructed. For example, if the currentrepresents MyGenericType<int> (MyGenericType(Of Integer) in Visual Basic), the value of this property is determined by MyGenericType<T>.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this property always returns false.
+
+
+
+ Gets a value indicating whether the string format attribute UnicodeClass is selected for the.
+
+
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ if the currentrepresents a value
+ type (structure); otherwise.
+
+
+
+ Value types are types that are represented as sequences of bits; value types are not classes or interfaces. Value types are referred to as "structs" in some programming languages. Enums are a special case of value types.
+ This property returns false for theclass, becauseis not a value type itself. It is the base class for all value types, and therefore any value type can be assigned to it. This would not be possible ifitself was a value type. Value types are boxed when they are assigned to a field of type.
+ This property returns true for enumerations, but not for thetype itself. For an example that demonstrates this behavior, see.
+ This property is read-only.
+
+
+
+ Gets a value indicating whether theis a value type.
+
+
+ 0
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+ This method is provided to enable the implementation of alternate type systems. It is not generally used in application code.
+
+
+
+ Implements theproperty and determines whether theis a value type; that is, not a class or an interface.
+
+
+
+ true if theis a value type; otherwise, false.
+
+
+
+
+
+
+ Property
+
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+ To be added.
+
+
+
+ Use this property to determine whether a type is part of the public interface of a component assembly.
+
+
+
+ Gets a value indicating whether thecan be accessed by code outside the assembly.
+
+
+
+
+
+
+ Method
+
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+ Themethod provides a way to generate array types whose element types are computed at run time.
+ Note The common language runtime makes a distinction between vectors (that is, one-dimensional arrays that are always zero-based) and multidimensional arrays. A vector, which always has only one dimension, is not the same as a multidimensional array that happens to have only one dimension. This method overload can only be used to create vector types, and it is the only way to create a vector type. Use themethod overload to create multidimensional array types.
+
+
+
+ Returns aobject representing a one-dimensional array of the current type, with a lower bound of zero.
+
+
+
+ Aobject representing a one-dimensional array of the current type, with a lower bound of zero.
+
+
+
+
+
+
+ Method
+
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+
+ is invalid (being less than 1, for example).
+
+
+
+ Themethod provides a way to generate array types whose element types are computed at run time.
+
+ The common language runtime makes a distinction between vectors (that is, one-dimensional arrays that are always zero-based) and multidimensional arrays. A vector, which always has only one dimension, is not the same as a multidimensional array that happens to have only one dimension. You cannot use this method overload to create a vector type; ifis 1, this method overload returns a multidimensional array type that happens to have one dimension. Use themethod overload to create vector types.
+
+
+
+
+ Returns aobject representing an array of the current type, with the specified number of dimensions.
+
+
+
+ An object representing an array of the current type, with the specified number of dimensions.
+
+
+ The number of dimensions for the array. This number must be less than or equal to 32.
+
+
+
+
+
+ Method
+
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+ Themethod provides a way to generate ref types (ByRef in Visual Basic) for parameter lists.
+ Using the syntax of Microsoft intermediate language (MSIL), if the currentobject represents, this method returns aobject representing Int32&.
+
+
+
+ Returns aobject that represents the current type when passed as a ref parameter (ByRef parameter in Visual Basic).
+
+
+
+ Aobject that represents the current type when passed as a ref parameter (ByRef parameter in Visual Basic).
+
+
+
+
+
+
+ Method
+
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+ System.ParamArray
+
+
+
+
+
+
+
+ The number of elements inis not the same as the number of type parameters of the current generic type definition.
+ -or-
+ An element ofdoes not satisfy the constraints specified for the corresponding type parameter of the current generic type definition.
+
+
+ is.
+ -or-
+ An element ofis.
+
+
+ The current type does not represent the definition of a generic type. That is,returns.
+
+
+ The following example usesandto create a constructed type from the generictype. The constructed type represents aofobjects with string keys.
+ using System;
+using System.Reflection;
+using System.Collections.Generic;
+
+public class Test
+{
+ public static void Main()
+ {
+ Console.WriteLine("\n--- Create a constructed type from the generic Dictionary type.");
+
+ // Create a type object representing the generic Dictionary
+ // type.
+ Type generic = Type.GetType("System.Collections.Generic.Dictionary");
+
+ DisplayTypeInfo(generic);
+
+ // Create an array of types to substitute for the type
+ // parameters of Dictionary. The key is of type string, and
+ // the type to be contained in the Dictionary is Test.
+ Type[] typeArgs = { typeof(string), typeof(Test) };
+ Type constructed = generic.MakeGenericType(typeArgs);
+
+ DisplayTypeInfo(constructed);
+
+ // Compare the type objects obtained above to type objects
+ // obtained using typeof() and GetGenericTypeDefinition().
+ Console.WriteLine("\n--- Compare types obtained by different methods:");
+
+ Type t = typeof(Dictionary<string, Test>);
+
+ Console.WriteLine("\tAre the constructed types equal? {0}", t == constructed);
+ Console.WriteLine("\tAre the generic types equal? {0}", t.GetGenericTypeDefinition() == generic);
+ }
+
+ private static void DisplayTypeInfo(Type t)
+ {
+ Console.WriteLine("\n{0}", t);
+ Console.WriteLine("\tIs this a generic type definition? {0}", t.IsGenericTypeDefinition);
+ Console.WriteLine("\tDoes it have generic type arguments? {0}", t.HasGenericArguments);
+
+ Type[] typeArguments = t.GetGenericArguments();
+
+ Console.WriteLine("\tList type arguments ({0}):", typeArguments.Length);
+ foreach (Type tParam in typeArguments)
+ {
+ Console.WriteLine("\t\t{0}", tParam);
+ }
+ }
+}
+
+/* This example produces the following output:
+
+--- Create a constructed type from the generic Dictionary type.
+
+System.Collections.Generic.Dictionary[KeyType,ValueType]
+ Is this a generic type definition? True
+ Does it have generic type arguments? True
+ List type arguments (2):
+ K
+ V
+
+System.Collections.Generic.Dictionary[System.String, Test]
+ Is this a generic type definition? False
+ Does it have generic type arguments? True
+ List type arguments (2):
+ System.String
+ Test
+
+--- Compare types obtained by different methods:
+ Are the constructed types equal? True
+ Are the generic types equal? True
+ */
+
+
+
+ Themethod allows you to write code that assigns specific types to the type parameters of a generic type definition, thus creating aobject that represents a particular constructed type. You can use thisobject to create run-time instances of the constructed type.
+ Types constructed withcan be open, that is, some of their type arguments can be type parameters of enclosing generic methods or types. You might use such open constructed types when you emit dynamic assemblies. For example, consider the classes Base and Derived in the following code.
+ code reference: System.Type.MakeGenericType#1
+ To generate Derived in a dynamic assembly, it is necessary to construct its base type. To do this, call themethod on aobject representing the class Base, using the generic type argumentsand the type parameter V from Derived. Because types and generic type parameters are both represented byobjects, an array containing both can be passed to themethod.
+
+ A constructed type such as Base<int, V> is useful when emitting code, but you cannot call themethod on this type because it is not a generic type definition. To create a closed constructed type that can be instantiated, first call themethod to get aobject representing the generic type definition and then callwith the desired type arguments.
+
+ Theobject returned byis the same as theobtained by calling themethod of the resulting constructed type, or themethod of any constructed type that was created from the same generic type definition using the same type arguments.
+
+ An array of generic types is not itself a generic type. You cannot callon an array type such as C<T>[] (Dim ac() As C(Of T) in Visual Basic). To construct a closed generic type from C<T>[], callto obtain the generic type definition C<T>; callon the generic type definition to create the constructed type; and finally call themethod on the constructed type to create the array type. The same is true of pointer types and ref types (ByRef in Visual Basic).
+
+ For a list of the invariant conditions for terms used in generic reflection, see theproperty remarks.
+
+
Nested Types
+
+ If a generic type is defined using C#, C++, or Visual Basic, then its nested types are all generic. This is true even if the nested types have no type parameters of their own, because all three languages include the type parameters of enclosing types in the type parameter lists of nested types. Consider the following classes:
+ code reference: System.Type.MakeGenericType#2
+ The type parameter list of the nested class Inner has two type parameters,and, the first of which is the type parameter of its enclosing class. Similarly, the type parameter list of the nested class Innermost1 has three type parameters,,, and, withandcoming from its enclosing classes. The nested class Innermost2 has two type parameters,and, which come from its enclosing classes.
+ If the parameter list of the enclosing type has more than one type parameter, all the type parameters in order are included in the type parameter list of the nested type.
+ To construct a generic type from the generic type definition for a nested type, call themethod with the array formed by concatenating the type argument arrays of all the enclosing types, beginning with the outermost generic type, and ending with the type argument array of the nested type itself, if it has type parameters of its own. To create an instance of Innermost1, call themethod with an array containing three types, to be assigned to T, U, and V. To create an instance of Innermost2, call themethod with an array containing two types, to be assigned to T and U.
+ The languages propagate the type parameters of enclosing types in this fashion so you can use the type parameters of an enclosing type to define fields of nested types. Otherwise, the type parameters would not be in scope within the bodies of the nested types. It is possible to define nested types without propagating the type parameters of enclosing types, by emitting code in dynamic assemblies or by using the
+ MSIL Assembler (Ilasm.exe)
+ . Consider the following code for the MSIL assembler:
+ .class public Outer<T> {
+ .class nested public Inner<U> {
+ .class nested public Innermost {
+ }
+ }
+}
+ In this example, it is not possible to define a field of typeorin class Innermost, because those type parameters are not in scope. The following assembler code defines nested classes that behave the way they would if defined in C++, Visual Basic, and C#:
+ .class public Outer<T> {
+ .class nested public Inner<T, U> {
+ .class nested public Innermost<T, U, V> {
+ }
+ }
+}
+ You can use the
+ MSIL Disassembler (Ildasm.exe)
+ to examine nested classes defined in the high-level languages and observe this naming scheme.
+
+
+
+ Substitutes the elements of an array of types for the type parameters of the current generic type definition and returns aobject representing the resulting constructed type.
+
+
+
+ Arepresenting the constructed type formed by substituting the elements offor the type parameters of the current generic type.
+
+
+ An array of types to be substituted for the type parameters of the current generic type.
+
+
+
+
+
+ Method
+
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+ Themethod provides a way to generate pointer types for parameter lists.
+ Using the syntax of Microsoft intermediate language (MSIL), if the currentobject represents, this method returns aobject representing Int32*.
+
+
+
+ Returns aobject that represents a pointer to the current type.
+
+
+
+ Aobject that represents a pointer to the current type.
+
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.MemberTypes
+
+
+ To be added.
+
+
+ This property overrides. Therefore, when you examine a set ofobjects—for example, the array returned by—theproperty returnswhen a given member is a nested type.
+ If the currentrepresents a constructed generic type, this property applies to the generic type definition from which the type was constructed. For example, if the currentrepresents MyGenericType<int> (MyGenericType(Of Integer) in Visual Basic), the value of this property is determined by MyGenericType<T>.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this property always returns.
+
+
+
+ Gets avalue indicating that this member is a type or a nested type.
+
+
+
+
+
+
+
+ Field
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Object
+
+
+ null
+
+
+
+ Use the Missing field for invocation through reflection to obtain the default value of a parameter. If the Missing field is passed in for a parameter value and there is no default value for that parameter, anis thrown.
+
+
+
+ Represents a missing value in theinformation. This field is read-only.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Reflection.Module
+
+
+
+
+ Athat reflects the module in which the currentis defined.
+
+
+
+ If the currentrepresents a constructed generic type, this property returns the module in which the generic type definition was defined. For example, if you create an instance of MyGenericStack<int>, theproperty for the constructed type returns the module in which MyGenericStack<T> is defined.
+ Similarly, if the currentrepresents a generic parameter, this property returns the assembly that contains the generic type that defines.
+
+
+
+ Gets the module (the DLL) in which the currentis defined.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.String
+
+
+
+
+ Acontaining the namespace of the current.
+
+
+
+ A namespace is a logical design-time naming convenience, used mainly to define scope in an application and organize classes and other types in a single hierarchical structure. From the viewpoint of the runtime, there are no namespaces.
+ If the currentrepresents a constructed generic type, this property returns the namespace that contains the generic type definition. Similarly, if the currentrepresents a generic parameter, this property returns the namespace that contains the generic type definition that defines.
+ If the currentobject represents a generic parameter, this property returns null.
+
+
+
+ Gets the namespace of the.
+
+
+ 1
+ Reflection
+
+
+
+
+ Method
+
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+
+ To be added.
+
+
+ Indicates whether twoobjects are equal.
+
+
+
+ true ifis equal to; otherwise, false.
+
+
+ The first object to compare.
+
+ The second object to compare.
+
+
+
+
+
+ Method
+
+ 4.0.0.0
+
+
+ System.Boolean
+
+
+
+
+
+
+ To be added.
+
+
+ Indicates whether twoobjects are not equal.
+
+
+
+ true ifis not equal to; otherwise, false.
+
+
+ The first object to compare.
+
+ The second object to compare.
+
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+ Theobject
+ through which the current instance was obtained.
+
+
+ The following example demonstrates theproperty. Although the methodis
+ declared in, its reflected type is obtained from.
+ using System;
+using System.Reflection;
+public abstract class ReflectedTypeTest {
+ public abstract class MyClassA {
+ public abstract int m();
+ }
+ public abstract class MyClassB : MyClassA {
+ }
+ public static void Main(string[] args) {
+ Console.WriteLine("Reflected type of m is {0}",
+ typeof(MyClassB).GetMethod("m").ReflectedType);
+ }
+}
+ The output is
+
+ Reflected type of m is ReflectedTypeTest+MyClassB
+
+
+
+
+ Forobjects, the value of this property is always the same as the value of theproperty.
+
+
+
+ Gets the class object that was used to obtain this member.
+
+
+ 1
+ Reflection
+
+
+
+
+ Method
+
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+
+
+
+
+
+
+ If the assembly containing the type is not already loaded into the reflection-only context, using themethod is equivalent to first loading the assembly for reflection only, using themethod, and then loading the type by calling the assembly'smethod. For information about assembly-qualified names, see theproperty. For additional details on specifying type names, see themethod overload.
+ If the assembly is already loaded for execution, another copy is loaded into the reflection-only context.
+ Theparameter specifies what happens when the type is not found, and also suppresses certain other exception conditions, as described in the Exceptions section. Some exceptions are thrown regardless of the value of. For example, if the assembly is not valid, ais thrown even ifis false.
+ For more information about using the reflection-only context, see
+ How to: Load Assemblies into the Reflection-Only Context
+ .
+
+
+
+ Gets thewith the specified name, specifying whether to perform a case-sensitive search and whether to throw an exception if the type is not found. The type is loaded for reflection only, not for execution.
+
+
+
+ The type with the specified name, if found; otherwise, null. If the type is not found, theparameter specifies whether null is returned or an exception is thrown. In some cases, an exception is thrown regardless of the value of. See the Exceptions section.
+
+
+ The assembly-qualified name of theto get.
+
+ true to throw aif the type cannot be found; false to return null if the type cannot be found. Specifying false also suppresses some other exception conditions, but not all of them. See the Exceptions section.
+
+ true to perform a case-insensitive search for; false to perform a case-sensitive search for.
+
+
+
+
+
+ Property
+
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Runtime.InteropServices.StructLayoutAttribute
+
+
+ To be added.
+
+
+
+
+ is not returned by themethod. Instead, use this property to get it.
+
+
+
+ Gets athat describes the layout of the current type.
+
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Void
+
+
+
+
+
+
+
+
+
+ To be added.
+ To be added.
+ To be added.
+ To be added.
+ To be added.
+ To be added.
+ To be added.
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Void
+
+
+
+
+
+
+
+
+
+ This method is for access to managed classes from unmanaged code, and should not be called from managed code. For more information aboutIDispatch::GetTypeInfo, see the MSDN Library.
+
+
+
+ Retrieves the type information for an object, which can then be used to get the type information for an interface.
+
+
+ The type information to return.
+
+ The locale identifier for the type information.
+
+ A pointer to the requested type information object.
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Void
+
+
+
+
+
+ To be added.
+ To be added.
+ To be added.
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Void
+
+
+
+
+
+
+
+
+
+
+
+
+ To be added.
+ To be added.
+ To be added.
+ To be added.
+ To be added.
+ To be added.
+ To be added.
+ To be added.
+ To be added.
+ To be added.
+
+
+
+
+
+
+ Method
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.String
+
+
+
+
+
+ This method returns the fully qualified common language runtime namespace and name for all primitive types. For example, the C# instruction, (long)0.Type().ToString() returns "System.Int64" instead of merely "Int64".
+ If the currentrepresents a generic type, the type and its type arguments are qualified by namespace and by nested type, but not by assembly. If the currentrepresents a type parameter in the definition of a generic type or generic method, this method returns the unqualified name of the type parameter.
+
+
+
+ Returns a String representing the name of the current Type.
+
+
+
+ Arepresenting the name of the current.
+
+
+ 0
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.RuntimeTypeHandle
+
+
+
+
+ Thefor the current.
+
+
+
+ TypeHandle encapsulates a pointer to an internal data structure that represents the type. This handle is unique during the process lifetime. The handle is valid only in the application domain in which it was obtained.
+
+
+
+ Gets the handle for the current.
+
+
+ 1
+ RuntimeInfrastructure
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+
+ System.Runtime.InteropServices.ComVisible(true)
+
+
+
+ System.Reflection.ConstructorInfo
+
+
+
+
+ Acontaining the name of the static
+ constructor for the type represented by the current instance
+
+
+
+ Class initializers are also available through themethod, or through overloads of the,,, andmethods that takeas a parameter.
+ If the currentrepresents a type parameter in the definition of a generic type or generic method, this property returns null.
+
+
+
+ Gets the initializer for the.
+
+
+ 1
+ Reflection
+
+
+
+
+
+ Property
+
+ 1.0.5000.0
+ 2.0.0.0
+ 4.0.0.0
+
+
+ System.Type
+
+
+
+
+ The underlying system type for the.
+
+
+ This property is read-only.
+
+ As described
+ above.
+
+
+
+
+ Indicates the type provided by the common language runtime that represents this type.
+
+
+ 1
+ Reflection
+
+
+ 0
+
diff --git a/Src/CSharpier.Benchmarks/Program.cs b/Src/CSharpier.Benchmarks/Program.cs
index 80a214bb1..e86c5b63d 100644
--- a/Src/CSharpier.Benchmarks/Program.cs
+++ b/Src/CSharpier.Benchmarks/Program.cs
@@ -1,7 +1,10 @@
-using BenchmarkDotNet.Attributes;
+using System.Xml;
+using System.Xml.Linq;
+using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using CSharpier.Core;
using CSharpier.Core.CSharp;
+using CSharpier.Core.Xml;
using Microsoft.CodeAnalysis;
namespace CSharpier.Benchmarks;
@@ -9,6 +12,39 @@ namespace CSharpier.Benchmarks;
[MemoryDiagnoser]
public class Benchmarks
{
+ [Benchmark]
+ public void XmlDocument_Parse()
+ {
+ var root = new XmlDocument();
+ root.LoadXml(this.largeXmlCode);
+ }
+
+ [Benchmark]
+ public void XDocument_Parse()
+ {
+ _ = XDocument.Parse(this.largeXmlCode);
+ }
+
+ [Benchmark]
+ public void CustomParser_Parse()
+ {
+ _ = RawNodeReader.ParseXml(this.largeXmlCode, Environment.NewLine);
+ }
+
+ [Benchmark]
+ public void XmlReader_Parse()
+ {
+ using var xmlReader = XmlReader.Create(
+ new StringReader(this.largeXmlCode),
+ new XmlReaderSettings { IgnoreWhitespace = false }
+ );
+
+ while (xmlReader.Read())
+ {
+ //
+ }
+ }
+
[Benchmark]
public void Default_CodeFormatter_Tests()
{
@@ -48,6 +84,10 @@ public void IsCodeBasicallyEqual_SyntaxNodeComparer()
DisabledTextComparer.IsCodeBasicallyEqual(this.code, this.code);
}
+ private readonly string largeXmlCode = File.ReadAllText(
+ Path.Combine(RepoRoot, "Src/CSharpier.BenchMarks/CodeSamples/Type.xml")
+ );
+
private readonly string largeTestCode = File.ReadAllText(
Path.Combine(RepoRoot, "Src/CSharpier.BenchMarks/CodeSamples/PathAxesTests.cs")
);
diff --git a/Src/CSharpier.Core/CodeFormatter.cs b/Src/CSharpier.Core/CodeFormatter.cs
index 579db6e94..b8724970d 100644
--- a/Src/CSharpier.Core/CodeFormatter.cs
+++ b/Src/CSharpier.Core/CodeFormatter.cs
@@ -26,7 +26,7 @@ CancellationToken cancellationToken
SourceCodeKind.Script,
cancellationToken
),
- Formatter.XML => XmlFormatter.Format(fileContents, options),
+ Formatter.XML => await XmlFormatter.FormatAsync(fileContents, options),
_ => new CodeFormatterResult { FailureMessage = "Is an unsupported file type." },
};
}
diff --git a/Src/CSharpier.Core/Xml/RawAttribute.cs b/Src/CSharpier.Core/Xml/RawAttribute.cs
new file mode 100644
index 000000000..bece2c0cb
--- /dev/null
+++ b/Src/CSharpier.Core/Xml/RawAttribute.cs
@@ -0,0 +1,7 @@
+namespace CSharpier.Core.Xml;
+
+internal class RawAttribute
+{
+ public required string Name { get; set; }
+ public required string Value { get; set; }
+}
diff --git a/Src/CSharpier.Core/Xml/RawNode.cs b/Src/CSharpier.Core/Xml/RawNode.cs
new file mode 100644
index 000000000..d19a4bb3d
--- /dev/null
+++ b/Src/CSharpier.Core/Xml/RawNode.cs
@@ -0,0 +1,34 @@
+using System.Text.Json.Serialization;
+using System.Xml;
+
+namespace CSharpier.Core.Xml;
+
+internal class RawNode
+{
+ [JsonIgnore]
+ public RawNode? Parent { get; set; }
+
+ [JsonIgnore]
+ public RawNode? PreviousNode { get; set; }
+
+ [JsonIgnore]
+ public RawNode? NextNode { get; set; }
+ public string Name { get; set; } = string.Empty;
+
+ [JsonConverter(typeof(JsonStringEnumConverter))]
+ public required XmlNodeType NodeType { get; set; }
+ public bool IsEmpty { get; set; }
+ public RawAttribute[] Attributes { get; set; } = [];
+ public List Nodes { get; set; } = [];
+ public string Value { get; set; } = string.Empty;
+
+ public bool IsTextLike()
+ {
+ return this.NodeType is XmlNodeType.Text or XmlNodeType.Comment or XmlNodeType.CDATA;
+ }
+
+ public RawNode GetLastDescendant()
+ {
+ return this.NodeType is XmlNodeType.Element ? this.Nodes.LastOrDefault() ?? this : this;
+ }
+}
diff --git a/Src/CSharpier.Core/Xml/RawNodeReader.cs b/Src/CSharpier.Core/Xml/RawNodeReader.cs
new file mode 100644
index 000000000..2c8d1631f
--- /dev/null
+++ b/Src/CSharpier.Core/Xml/RawNodeReader.cs
@@ -0,0 +1,488 @@
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Xml;
+
+namespace CSharpier.Core.Xml;
+
+internal
+#if !NETSTANDARD2_0
+partial
+#endif
+class RawNodeReader
+{
+ private readonly string originalXml;
+ private readonly string lineEnding;
+ private int position;
+ private readonly Stack elementStack = new();
+
+#if !NETSTANDARD2_0
+ [GeneratedRegex(@"\r\n|\n|\r", RegexOptions.Compiled)]
+ private static partial Regex NewlineRegex();
+#else
+ private static readonly Regex NewlineRegex = new(@"\r\n|\n|\r", RegexOptions.Compiled);
+#endif
+
+ private RawNodeReader(string xml, string lineEnding)
+ {
+ this.originalXml = NewlineRegex
+#if !NETSTANDARD2_0
+ ()
+#endif
+ .Replace(xml, "\n");
+ this.lineEnding = lineEnding;
+ }
+
+ public static RawNode ParseXml(string originalXml, string lineEnding)
+ {
+ var reader = new RawNodeReader(originalXml, lineEnding);
+ return reader.ParseXml();
+ }
+
+ private RawNode ParseXml()
+ {
+ var rootNode = new RawNode { NodeType = XmlNodeType.Document };
+ this.elementStack.Push(rootNode);
+ while (this.position < this.originalXml.Length)
+ {
+ this.SkipWhitespace();
+ if (this.position >= this.originalXml.Length)
+ {
+ break;
+ }
+
+ if (this.originalXml[this.position] == '<')
+ {
+ this.ParseTag();
+ }
+ else
+ {
+ if (rootNode.Nodes.Count == 0)
+ {
+ throw new XmlException("There do not appear to be any root nodes");
+ }
+ this.ParseText();
+ }
+ }
+
+ return rootNode;
+ }
+
+ private void SkipWhitespace()
+ {
+ while (
+ this.position < this.originalXml.Length
+ && char.IsWhiteSpace(this.originalXml[this.position])
+ )
+ {
+ this.position++;
+ }
+ }
+
+ private void ParseTag()
+ {
+ if (this.position + 1 >= this.originalXml.Length)
+ {
+ return;
+ }
+
+ if (this.originalXml[this.position + 1] == '!')
+ {
+ if (
+ this.position + 4 < this.originalXml.Length
+ && this.originalXml.Substring(this.position, 4) == "")
+ {
+ this.position += 3;
+ break;
+ }
+
+ if (this.originalXml[this.position] == '\n')
+ {
+ content.Append(this.lineEnding);
+ }
+ else
+ {
+ content.Append(this.originalXml[this.position]);
+ }
+ this.position++;
+ }
+
+ var node = new RawNode { NodeType = XmlNodeType.Comment, Value = $"" };
+
+ this.AddNode(node);
+ }
+
+ private void ParseCData()
+ {
+ this.position += 9; // Skip "")
+ {
+ this.position += 3;
+ break;
+ }
+
+ if (this.originalXml[this.position] == '\n')
+ {
+ content.Append(this.lineEnding);
+ }
+ else
+ {
+ content.Append(this.originalXml[this.position]);
+ }
+ this.position++;
+ }
+
+ var node = new RawNode { NodeType = XmlNodeType.CDATA, Value = $"" };
+
+ this.AddNode(node);
+ }
+
+ private void ParseProcessingInstruction()
+ {
+ this.position += 2; // Skip ""
+
+ var name = this.ReadName();
+ this.SkipWhitespace();
+
+ var content = new StringBuilder();
+ while (this.position + 1 < this.originalXml.Length)
+ {
+ if (this.originalXml.Substring(this.position, 2) == "?>")
+ {
+ this.position += 2;
+ break;
+ }
+
+ if (this.originalXml[this.position] == '\n')
+ {
+ content.Append(this.lineEnding);
+ }
+ else
+ {
+ content.Append(this.originalXml[this.position]);
+ }
+ this.position++;
+ }
+
+ var node = new RawNode
+ {
+ Name = name,
+ NodeType = XmlNodeType.ProcessingInstruction,
+ Value = $"{name} {content}?>",
+ };
+
+ this.AddNode(node);
+ }
+
+ private void ParseEndElement()
+ {
+ this.position += 2; // Skip ""
+
+ this.ReadName();
+ this.SkipToChar('>');
+
+ if (this.elementStack.Count > 0)
+ {
+ var element = this.elementStack.Pop();
+ for (var x = 0; x < element.Nodes.Count; x++)
+ {
+ if (x > 0)
+ {
+ element.Nodes[x - 1].NextNode = element.Nodes[x];
+ element.Nodes[x].PreviousNode = element.Nodes[x - 1];
+ }
+
+ if (x == element.Nodes.Count - 2)
+ {
+ element.Nodes[x].NextNode = element.Nodes[x + 1];
+ element.Nodes[x + 1].PreviousNode = element.Nodes[x];
+ }
+ }
+ }
+ }
+
+ private void ParseStartElement()
+ {
+ this.position++; // Skip "<"
+
+ var name = this.ReadName();
+ var attributes = this.ParseAttributes();
+
+ var isEmpty = false;
+ if (this.position < this.originalXml.Length && this.originalXml[this.position] == '/')
+ {
+ isEmpty = true;
+ this.position++;
+ }
+
+ this.SkipToChar('>');
+
+ var node = new RawNode
+ {
+ Name = name,
+ NodeType = XmlNodeType.Element,
+ IsEmpty = isEmpty,
+ Attributes = attributes.ToArray(),
+ };
+
+ this.AddNode(node);
+
+ if (!isEmpty)
+ {
+ this.elementStack.Push(node);
+ }
+ }
+
+ private void ParseText()
+ {
+ var content = new StringBuilder();
+ // we skip all whitespace in the main read, so for parsing text go backwards until we find the actual start
+ while (this.position >= 0 && this.originalXml[this.position - 1] != '>')
+ {
+ this.position--;
+ }
+
+ while (this.position < this.originalXml.Length && this.originalXml[this.position] != '<')
+ {
+ if (this.originalXml[this.position] == '\n')
+ {
+ content.Append(this.lineEnding);
+ }
+ else
+ {
+ content.Append(this.originalXml[this.position]);
+ }
+ this.position++;
+ }
+
+ var text = content.ToString();
+ if (string.IsNullOrEmpty(text))
+ {
+ return;
+ }
+ var node = new RawNode { NodeType = XmlNodeType.Text, Value = text };
+
+ this.AddNode(node);
+ }
+
+ private List ParseAttributes()
+ {
+ var attributes = new List();
+
+ while (this.position < this.originalXml.Length)
+ {
+ this.SkipWhitespace();
+ if (
+ this.position >= this.originalXml.Length
+ || this.originalXml[this.position] == '>'
+ || this.originalXml[this.position] == '/'
+ )
+ {
+ break;
+ }
+
+ var attrName = this.ReadName();
+ this.SkipWhitespace();
+
+ if (this.position < this.originalXml.Length && this.originalXml[this.position] == '=')
+ {
+ this.position++;
+ this.SkipWhitespace();
+
+ var attrValue = this.ReadQuotedValue();
+ attributes.Add(
+ new RawAttribute { Name = attrName, Value = attrValue.Replace("\"", """) }
+ );
+ }
+ else
+ {
+ throw new XmlException("Cannot find next attribute");
+ }
+ }
+
+ return attributes;
+ }
+
+ private string ReadName()
+ {
+ var name = new StringBuilder();
+ while (
+ this.position < this.originalXml.Length
+ && (
+ char.IsLetterOrDigit(this.originalXml[this.position])
+ || this.originalXml[this.position] == '_'
+ || this.originalXml[this.position] == ':'
+ || this.originalXml[this.position] == '-'
+ || this.originalXml[this.position] == '.'
+ )
+ )
+ {
+ name.Append(this.originalXml[this.position]);
+ this.position++;
+ }
+ return name.ToString();
+ }
+
+ private string ReadQuotedValue()
+ {
+ if (this.position >= this.originalXml.Length)
+ {
+ return string.Empty;
+ }
+
+ var quote = this.originalXml[this.position];
+ if (quote is not ('"' or '\''))
+ {
+ return string.Empty;
+ }
+
+ this.position++; // Skip opening quote
+
+ var value = new StringBuilder();
+ while (this.position < this.originalXml.Length && this.originalXml[this.position] != quote)
+ {
+ if (this.originalXml[this.position] == '\n')
+ {
+ value.Append(this.lineEnding);
+ }
+ else
+ {
+ value.Append(this.originalXml[this.position]);
+ }
+ this.position++;
+ }
+
+ if (this.position < this.originalXml.Length)
+ {
+ this.position++; // Skip closing quote
+ }
+
+ return value.ToString();
+ }
+
+ private void SkipToChar(char target)
+ {
+ while (this.position < this.originalXml.Length && this.originalXml[this.position] != target)
+ {
+ this.position++;
+ }
+
+ if (this.position < this.originalXml.Length)
+ {
+ this.position++; // Skip the target character
+ }
+ }
+
+ private void AddNode(RawNode node)
+ {
+ if (this.elementStack.Count > 0)
+ {
+ var parent = this.elementStack.Peek();
+ node.Parent = parent;
+ parent.Nodes.Add(node);
+ }
+ }
+
+ private void ParseDocType()
+ {
+ this.position += 9; // Skip "' && bracketCount == 0)
+ {
+ content.Append(ch);
+ this.position++;
+ break;
+ }
+ }
+ else if (ch == quoteChar)
+ {
+ inQuotes = false;
+ quoteChar = '\0';
+ }
+
+ if (ch == '\n')
+ {
+ content.Append(this.lineEnding);
+ }
+ else
+ {
+ content.Append(ch);
+ }
+ this.position++;
+ }
+
+ var node = new RawNode { NodeType = XmlNodeType.DocumentType, Value = content.ToString() };
+
+ this.AddNode(node);
+ }
+}
diff --git a/Src/CSharpier.Core/Xml/RawNodeSyntaxWriter.cs b/Src/CSharpier.Core/Xml/RawNodeSyntaxWriter.cs
new file mode 100644
index 000000000..c1a19af15
--- /dev/null
+++ b/Src/CSharpier.Core/Xml/RawNodeSyntaxWriter.cs
@@ -0,0 +1,11 @@
+using System.Text.Json;
+
+namespace CSharpier.Core.Xml;
+
+internal static class RawNodeSyntaxWriter
+{
+ public static string Write(RawNode rootNode)
+ {
+ return JsonSerializer.Serialize(rootNode);
+ }
+}
diff --git a/Src/CSharpier.Core/Xml/XNodePrinters/Attributes.cs b/Src/CSharpier.Core/Xml/XNodePrinters/Attributes.cs
index 5d433d836..2f1a8d5ae 100644
--- a/Src/CSharpier.Core/Xml/XNodePrinters/Attributes.cs
+++ b/Src/CSharpier.Core/Xml/XNodePrinters/Attributes.cs
@@ -1,33 +1,28 @@
-using System.Text;
using System.Xml;
-using System.Xml.Linq;
+using CSharpier.Core.CSharp.SyntaxPrinter;
using CSharpier.Core.DocTypes;
namespace CSharpier.Core.Xml.XNodePrinters;
internal static class Attributes
{
- public static Doc Print(XElement element, XmlPrintingContext context)
+ public static Doc Print(RawNode rawNode, PrintingContext context)
{
- if (!element.Attributes().Any())
+ if (rawNode.Attributes.Length == 0)
{
- return element.IsEmpty ? " " : Doc.Null;
+ return rawNode.IsEmpty ? " " : Doc.Null;
}
var printedAttributes = new List();
- var index = 0;
- var xmlNode = context.Mapping[element];
- foreach (var attribute in element.Attributes())
+ foreach (var attribute in rawNode.Attributes)
{
- printedAttributes.Add(PrintAttribute(attribute, xmlNode.Attributes![index]));
-
- index++;
+ printedAttributes.Add($"{attribute.Name}=\"{attribute.Value}\"");
}
var doNotBreakAttributes =
- element.Attributes().Count() == 1
- && !context.Mapping[element].Attributes![0].Value.Contains('\n')
- && (element.Nodes().Any(o => o is XElement) || element.IsEmpty);
+ rawNode.Attributes.Length == 1
+ && !rawNode.Attributes[0].Value.Contains('\n')
+ && (rawNode.Nodes.Any(o => o.NodeType is XmlNodeType.Element) || rawNode.IsEmpty);
var attributeLine = Doc.Line;
var parts = new List
@@ -46,93 +41,18 @@ public static Doc Print(XElement element, XmlPrintingContext context)
* >456
*/
(
- element.Nodes().Any()
- && Tag.NeedsToBorrowParentOpeningTagEndMarker(element.Nodes().First())
- )
- /*
- * 123
- */
- || (element.IsEmpty && Tag.NeedsToBorrowLastChildClosingTagEndMarker(element.Parent!))
- || doNotBreakAttributes
+ rawNode.Nodes.Count != 0
+ && Tag.NeedsToBorrowParentOpeningTagEndMarker(rawNode.Nodes.First())
+ ) || doNotBreakAttributes
)
{
- parts.Add(element.IsEmpty ? " " : "");
+ parts.Add(rawNode.IsEmpty ? " " : "");
}
else
{
- parts.Add(element.IsEmpty ? Doc.Line : Doc.SoftLine);
+ parts.Add(rawNode.IsEmpty ? Doc.Line : Doc.SoftLine);
}
return Doc.Concat(parts);
}
-
- private static Doc PrintAttribute(XAttribute attribute, XmlAttribute xmlAttribute)
- {
- // XAttribute mostly gets us what we want, but it removes new lines (per spec)
- // XmlAttribute gives us those new lines
- // this makes use of both values to get the final value we want to display
- // we want the new lines because it is common to add them with long conditions in csproj files
- string GetAttributeValue()
- {
- // this gives us the attribute value with everything encoded after we remove the name + quotes
- var xValue = attribute.ToString();
- xValue = xValue[(xValue.IndexOf('=') + 2)..];
- xValue = xValue[..^1];
- var xmlValue = xmlAttribute.Value;
-
- if (xValue == xmlValue)
- {
- return xValue;
- }
-
- var valueBuilder = new StringBuilder();
- var xmlIndex = 0;
- var xIndex = 0;
- while (xIndex < xValue.Length)
- {
- var xChar = xValue[xIndex];
- var xmlChar = xmlValue[xmlIndex];
-
- if (xChar == ' ' && xmlChar == '\r')
- {
- valueBuilder.Append(xmlChar);
- xmlIndex++;
- xmlChar = xmlValue[xmlIndex];
- }
-
- if (xChar == '&')
- {
- do
- {
- valueBuilder.Append(xChar);
- xIndex++;
- xChar = xValue[xIndex];
- } while (xChar != ';');
- valueBuilder.Append(xChar);
- }
-
- if (xChar == xmlChar || (xChar == ' ' && xmlChar == '\n'))
- {
- valueBuilder.Append(xmlChar);
- }
-
- xIndex++;
- xmlIndex++;
- }
-
- return valueBuilder.ToString();
- }
-
- var name = attribute.Name.LocalName;
- var prefix = attribute.Parent!.GetPrefixOfNamespace(attribute.Name.Namespace);
- if (!string.IsNullOrEmpty(prefix))
- {
- name = $"{prefix}:{name}";
- }
-
- return $"{name}=\"{GetAttributeValue()}\"";
- }
}
diff --git a/Src/CSharpier.Core/Xml/XNodePrinters/Element.cs b/Src/CSharpier.Core/Xml/XNodePrinters/Element.cs
index 9cf6b2fcb..bfe07d7f3 100644
--- a/Src/CSharpier.Core/Xml/XNodePrinters/Element.cs
+++ b/Src/CSharpier.Core/Xml/XNodePrinters/Element.cs
@@ -1,23 +1,29 @@
-using System.Xml.Linq;
+using System.Xml;
+using CSharpier.Core.CSharp.SyntaxPrinter;
using CSharpier.Core.DocTypes;
namespace CSharpier.Core.Xml.XNodePrinters;
internal static class Element
{
- internal static Doc Print(XElement node, XmlPrintingContext context)
+ internal static Doc Print(RawNode rawNode, PrintingContext context)
{
var shouldHugContent = false;
var attrGroupId = context.GroupFor("element-attr-group-id");
- Doc PrintChildrenDoc(params Doc[] childrenDoc)
+ Doc PrintChildrenDoc()
{
+ var childContent = ElementChildren.Print(rawNode, context);
+
if (shouldHugContent)
{
- return Doc.IndentIfBreak(Doc.Concat(childrenDoc), attrGroupId);
+ return Doc.IndentIfBreak(
+ Doc.Concat(PrintLineBeforeChildren(), childContent),
+ attrGroupId
+ );
}
- return Doc.Indent(childrenDoc);
+ return Doc.Indent(PrintLineBeforeChildren(), childContent);
}
Doc PrintLineBeforeChildren()
@@ -28,19 +34,23 @@ Doc PrintLineBeforeChildren()
}
if (
- node.Nodes().FirstOrDefault()
- is not XCData
- and XText { Value: ['\n', ..] or ['\r', ..] }
+ rawNode.Nodes.FirstOrDefault() is
+ { NodeType: XmlNodeType.Text, Value: ['\n', ..] or ['\r', ..] }
)
{
return Doc.LiteralLine;
}
- if (!node.Attributes().Any() && node.Nodes().ToList() is [XText] and not [XCData])
+ if (rawNode.Attributes.Length == 0 && rawNode.Nodes is [{ NodeType: XmlNodeType.Text }])
{
return Doc.Null;
}
+ if (rawNode.Nodes.Any(o => o.NodeType is XmlNodeType.Text && o.Value.Contains('\n')))
+ {
+ return Doc.HardLine;
+ }
+
return Doc.SoftLine;
}
;
@@ -52,32 +62,34 @@ Doc PrintLineAfterChildren()
return Doc.IfBreak(Doc.SoftLine, "", attrGroupId);
}
- if (!node.Attributes().Any() && node.Nodes().ToList() is [XText] and not [XCData])
+ if (rawNode.Attributes.Length == 0 && rawNode.Nodes is [{ NodeType: XmlNodeType.Text }])
{
return Doc.Null;
}
return Doc.SoftLine;
}
- var elementContent = !node.Nodes().Any()
- ? Doc.Null
- : Doc.Concat(
- ForceBreakContent(node) ? Doc.BreakParent : "",
- PrintChildrenDoc(PrintLineBeforeChildren(), ElementChildren.Print(node, context)),
- PrintLineAfterChildren()
- );
+ var elementContent =
+ rawNode.IsEmpty || rawNode.Nodes.Count == 0
+ ? Doc.Null
+ : Doc.Concat(
+ ForceBreakContent(rawNode) ? Doc.BreakParent : "",
+ PrintChildrenDoc(),
+ PrintLineAfterChildren()
+ );
return Doc.Group(
- Doc.GroupWithId(attrGroupId, Tag.PrintOpeningTag(node, context)),
+ Doc.GroupWithId(attrGroupId, Tag.PrintOpeningTag(rawNode, context)),
elementContent,
- Tag.PrintClosingTag(node, context)
+ Tag.PrintClosingTag(rawNode, context)
);
}
- private static bool ForceBreakContent(XElement node)
+ private static bool ForceBreakContent(RawNode rawNode)
{
- var childNode = node.Nodes().Count() == 1 ? node.Nodes().First() : null;
+ var childNode = rawNode.Nodes.Count == 1 ? rawNode.Nodes.First() : null;
- return childNode is not null and (XCData or not XText);
+ return childNode is not null
+ && childNode.NodeType is XmlNodeType.CDATA or not XmlNodeType.Text;
}
}
diff --git a/Src/CSharpier.Core/Xml/XNodePrinters/ElementChildren.cs b/Src/CSharpier.Core/Xml/XNodePrinters/ElementChildren.cs
index 521106b18..4c34176c6 100644
--- a/Src/CSharpier.Core/Xml/XNodePrinters/ElementChildren.cs
+++ b/Src/CSharpier.Core/Xml/XNodePrinters/ElementChildren.cs
@@ -1,4 +1,5 @@
-using System.Xml.Linq;
+using System.Xml;
+using CSharpier.Core.CSharp.SyntaxPrinter;
using CSharpier.Core.DocTypes;
using CSharpier.Core.Utilities;
@@ -6,18 +7,17 @@ namespace CSharpier.Core.Xml.XNodePrinters;
internal static class ElementChildren
{
- public static Doc Print(XElement element, XmlPrintingContext context)
+ public static Doc Print(RawNode node, PrintingContext context)
{
var groupIds = new List();
- var childNodes = element.Nodes().ToList();
- foreach (var _ in childNodes)
+ foreach (var _ in node.Nodes)
{
groupIds.Add(context.GroupFor("symbol"));
}
- var result = new ValueListBuilder(childNodes.Count * 5);
+ var result = new ValueListBuilder(node.Nodes.Count * 5);
var x = 0;
- foreach (var childNode in childNodes)
+ foreach (var childNode in node.Nodes)
{
var prevParts = new ValueListBuilder([null, null]);
var leadingParts = new ValueListBuilder([null, null]);
@@ -38,7 +38,7 @@ public static Doc Print(XElement element, XmlPrintingContext context)
{
prevParts.Append(Doc.HardLine);
}
- else if (childNode.PreviousNode is XText)
+ else if (childNode.PreviousNode?.NodeType is XmlNodeType.Text)
{
leadingParts.Append(prevBetweenLine);
}
@@ -52,7 +52,7 @@ public static Doc Print(XElement element, XmlPrintingContext context)
{
if (nextBetweenLine is HardLine)
{
- if (childNode.NextNode is XText)
+ if (childNode.NextNode?.NodeType is XmlNodeType.Text)
{
nextParts.Append(Doc.HardLine);
}
@@ -81,7 +81,7 @@ public static Doc Print(XElement element, XmlPrintingContext context)
return Doc.Concat(ref result);
}
- public static Doc PrintChild(XNode child, XmlPrintingContext context)
+ public static Doc PrintChild(RawNode child, PrintingContext context)
{
// should we try to support csharpier-ignore some day?
// if (HasPrettierIgnore(child))
@@ -104,13 +104,18 @@ public static Doc PrintChild(XNode child, XmlPrintingContext context)
return Node.Print(child, context);
}
- public static Doc PrintBetweenLine(XNode prevNode, XNode nextNode)
+ public static Doc PrintBetweenLine(RawNode prevNode, RawNode nextNode)
{
return
- (prevNode is XText && nextNode is XComment)
- || (prevNode is XComment && nextNode is XText)
- || (prevNode is XText && nextNode is XElement)
- || (prevNode is XElement && nextNode is XText)
+ (prevNode.IsTextLike() && nextNode.IsTextLike())
+ || (
+ prevNode.NodeType is XmlNodeType.Text or XmlNodeType.CDATA
+ && nextNode.NodeType is XmlNodeType.Element
+ )
+ || (
+ prevNode.NodeType is XmlNodeType.Element
+ && nextNode.NodeType is XmlNodeType.Text or XmlNodeType.CDATA
+ )
? Doc.Null
: Doc.HardLine;
}
diff --git a/Src/CSharpier.Core/Xml/XNodePrinters/Node.cs b/Src/CSharpier.Core/Xml/XNodePrinters/Node.cs
index bcb64eede..547a5021b 100644
--- a/Src/CSharpier.Core/Xml/XNodePrinters/Node.cs
+++ b/Src/CSharpier.Core/Xml/XNodePrinters/Node.cs
@@ -1,61 +1,66 @@
-using System.Text.RegularExpressions;
-using System.Xml.Linq;
+using System.Xml;
+using CSharpier.Core.CSharp.SyntaxPrinter;
using CSharpier.Core.DocTypes;
using CSharpier.Core.Utilities;
namespace CSharpier.Core.Xml.XNodePrinters;
-internal static
-#if !NETSTANDARD2_0
-partial
-#endif
-class Node
+internal static class Node
{
-#if NETSTANDARD2_0
- private static readonly Regex NewlineRegex = new(@"\r\n|\n|\r", RegexOptions.Compiled);
-#else
- [GeneratedRegex(@"\r\n|\n|\r", RegexOptions.Compiled)]
- private static partial Regex NewlineRegex();
-#endif
-
- internal static Doc Print(XNode xNode, XmlPrintingContext context)
+ internal static Doc Print(RawNode node, PrintingContext context)
{
- if (xNode is XDocument xDocument)
+ if (node.NodeType is XmlNodeType.Document)
{
- var result = new List();
+ var result = new ValueListBuilder(node.Nodes.Count * 2 + 1);
- if (xDocument.Declaration is not null)
+ foreach (var childNode in node.Nodes)
{
- result.Add(xDocument.Declaration.ToString(), Doc.HardLine);
+ result.Append(Print(childNode, context), Doc.HardLine);
}
- foreach (var node in xDocument.Nodes())
+ result.Append(Doc.HardLine);
+
+ return Doc.Concat(ref result);
+ }
+ if (node.NodeType == XmlNodeType.XmlDeclaration)
+ {
+ var version = node.Attributes.FirstOrDefault(o => o.Name == "version")?.Value;
+ var encoding = node.Attributes.FirstOrDefault(o => o.Name == "encoding")?.Value;
+ var standalone = node.Attributes.FirstOrDefault(o => o.Name == "standalone")?.Value;
+
+ var declaration = $"";
- return Doc.Concat(result);
+ return declaration;
}
- if (xNode is XDocumentType xDocumentType)
+ if (node.NodeType == XmlNodeType.DocumentType)
{
- return xDocumentType.ToString().Replace("[]", string.Empty);
+ return node.Value;
}
- if (xNode is XElement xElement)
+ if (node.NodeType == XmlNodeType.Element)
{
- return Element.Print(xElement, context);
+ return Element.Print(node, context);
}
- if (xNode is XText xText)
+ if (node.NodeType is XmlNodeType.Text)
{
List doc =
[
- Tag.PrintOpeningTagPrefix(xText),
- GetEncodedTextValue(xText),
- Tag.PrintClosingTagSuffix(xText, context),
+ Tag.PrintOpeningTagPrefix(node),
+ GetTextValue(node),
+ Tag.PrintClosingTagSuffix(node, context),
];
if (doc.All(o => o is StringDoc))
@@ -67,32 +72,34 @@ internal static Doc Print(XNode xNode, XmlPrintingContext context)
return Doc.Concat(doc);
}
- if (xNode is XComment or XProcessingInstruction)
+ if (
+ node.NodeType
+ is XmlNodeType.Comment
+ or XmlNodeType.ProcessingInstruction
+ or XmlNodeType.CDATA
+ )
{
- return NewlineRegex
-#if !NETSTANDARD2_0
- ()
-#endif
- .Replace(xNode.ToString(), context.Options.LineEnding);
+ if (node.Parent is null)
+ {
+ return Doc.Concat(node.Value, Doc.HardLine);
+ }
+
+ return node.Value;
}
- throw new Exception("Need to handle + " + xNode.GetType());
+ throw new Exception("Need to handle + " + node.NodeType);
}
- private static Doc GetEncodedTextValue(XText xText)
+ private static Doc GetTextValue(RawNode rawNode)
{
- if (xText.Value is null)
- {
- return Doc.Null;
- }
+ var textValue = rawNode.Value;
- if (xText is XCData xcData)
+ if (string.IsNullOrEmpty(textValue))
{
- return xcData.ToString();
+ return Doc.Null;
}
- var textValue = xText.Value;
- if (xText.Parent?.FirstNode == xText)
+ if (rawNode.Parent?.Nodes.First() == rawNode)
{
if (textValue[0] is '\r')
{
@@ -105,6 +112,6 @@ private static Doc GetEncodedTextValue(XText xText)
}
}
- return new XElement("EncodeText", textValue).LastNode!.ToString();
+ return textValue;
}
}
diff --git a/Src/CSharpier.Core/Xml/XNodePrinters/Tag.cs b/Src/CSharpier.Core/Xml/XNodePrinters/Tag.cs
index 9185a6857..f7932cbb6 100644
--- a/Src/CSharpier.Core/Xml/XNodePrinters/Tag.cs
+++ b/Src/CSharpier.Core/Xml/XNodePrinters/Tag.cs
@@ -1,179 +1,119 @@
-using System.Xml.Linq;
+using System.Xml;
+using CSharpier.Core.CSharp.SyntaxPrinter;
using CSharpier.Core.DocTypes;
namespace CSharpier.Core.Xml.XNodePrinters;
internal static class Tag
{
- public static Doc PrintOpeningTag(XElement element, XmlPrintingContext context)
+ public static Doc PrintOpeningTag(RawNode rawNode, PrintingContext context)
{
return Doc.Concat(
- PrintOpeningTagStart(element, context),
- Attributes.Print(element, context),
- element.IsEmpty ? Doc.Null : PrintOpeningTagEnd(element)
+ PrintOpeningTagStart(rawNode, context),
+ Attributes.Print(rawNode, context),
+ rawNode.IsEmpty ? Doc.Null : PrintOpeningTagEnd(rawNode)
);
}
- private static Doc PrintOpeningTagStart(XElement element, XmlPrintingContext context)
+ private static Doc PrintOpeningTagStart(RawNode rawNode, PrintingContext context)
{
return
- element.PreviousNode is not null
- && NeedsToBorrowNextOpeningTagStartMarker(element.PreviousNode)
+ rawNode.PreviousNode is not null
+ && NeedsToBorrowNextOpeningTagStartMarker(rawNode.PreviousNode)
? Doc.Null
: Doc.Concat(
- PrintOpeningTagPrefix(element),
- PrintOpeningTagStartMarker(element, context)
+ PrintOpeningTagPrefix(rawNode),
+ PrintOpeningTagStartMarker(rawNode, context)
);
}
- private static Doc PrintOpeningTagEnd(XElement node)
+ private static Doc PrintOpeningTagEnd(RawNode rawNode)
{
- return node.FirstNode is not null && NeedsToBorrowParentOpeningTagEndMarker(node.FirstNode)
+ return
+ rawNode.Nodes.FirstOrDefault() is { } firstNode
+ && NeedsToBorrowParentOpeningTagEndMarker(firstNode)
? Doc.Null
- : PrintOpeningTagEndMarker(node);
+ : ">";
}
- public static Doc PrintOpeningTagPrefix(XNode element)
+ public static Doc PrintOpeningTagPrefix(RawNode rawNode)
{
- return NeedsToBorrowParentOpeningTagEndMarker(element)
- ? PrintOpeningTagEndMarker(element.Parent!)
- : NeedsToBorrowPrevClosingTagEndMarker(element)
- ? PrintClosingTagEndMarker((element.PreviousNode as XElement)!)
- : "";
+ return NeedsToBorrowParentOpeningTagEndMarker(rawNode) ? ">" : "";
}
- private static bool NeedsToBorrowPrevClosingTagEndMarker(XNode node)
- {
- /*
- * 123
- * ^
- *
- *
*/
- return node.NextNode is not null
- && !node.NextNode.IsTextLike()
- // && node.IsTextLike()
- && node is XText and not XCData
+ return rawNode.NextNode is not null
+ && !rawNode.NextNode.IsTextLike()
+ && rawNode.IsTextLike()
+ && rawNode.NodeType is XmlNodeType.Text and not XmlNodeType.CDATA
// && node.isTrailingSpaceSensitive
// prettier does something with removing end of line nodes and setting this value, I don't know
- // that we have that funcionality
+ // that we have that functionality
// && !node.hasTrailingSpaces
;
}
- private static bool NeedsToBorrowParentClosingTagStartMarker(XNode node)
+ private static bool NeedsToBorrowParentClosingTagStartMarker(RawNode rawNode)
{
/*
*
@@ -186,21 +126,12 @@ private static bool NeedsToBorrowParentClosingTagStartMarker(XNode node)
* ^^^
* >
*/
- return node.NextNode is null
- && node.IsTextLike()
- && node.GetLastDescendant() is XText and not XCData;
- // && !node.hasTrailingSpaces
- }
-
- public static Doc PrintClosingTagPrefix(XElement node)
- {
- return Doc.Null;
- // return needsToBorrowLastChildClosingTagEndMarker(node)
- // ? printClosingTagEndMarker(node.lastChild, options)
- // : "";
+ return rawNode.NextNode is null
+ && rawNode.IsTextLike()
+ && rawNode.GetLastDescendant().NodeType is XmlNodeType.Text;
}
- public static bool NeedsToBorrowParentOpeningTagEndMarker(XNode node)
+ public static bool NeedsToBorrowParentOpeningTagEndMarker(RawNode rawNode)
{
/*
*