Reflection

Limited runtime type information, GetTypeName, Type class, and attributes.

⚠ Very limited reflection
sharp-runtime provides no real .NET-style reflection. C++ does not have a CLR metadata system. Only very basic runtime type name retrieval is available.

Runtime Type Name via GetTypeName()

include/System/Object.hpp

Every System::Object subclass must implement the pure virtual GetTypeName(). This returns a static string with the type name — it is the closest analog to GetType().Name in .NET.

System::Object* obj = new MyClass();
const std::string& name = obj->GetTypeName();  // "MyClass"

Implementation is assisted by macros:

// In .hpp:
GetTypeNameHPP()
// expands to: [[nodiscard]] virtual const std::string& GetTypeName() const override;

// In .cpp:
GetTypeNameCPP(MyClass, MyClass)
// expands to: const std::string& MyClass::GetTypeName() const {
//               const static std::string type_name = "MyClass";
//               return type_name; }

System::Type

include/System/Type.hpp

A partial stub for the .NET System.Type class. C++ cannot provide full runtime type metadata (member enumeration, method invocation by name, assembly metadata, etc.). The stub exists for compatibility — code that references System::Type will compile, but most functionality is not implemented.

Needs verification
The exact API surface of System::Type in sharp-runtime needs review from the header file. It is expected to be a minimal stub.

Attribute Classes

sharp-runtime provides many attribute header files for API compatibility. These are empty or near-empty stub classes — they allow code to compile but do not implement runtime attribute inspection:

AttributeHeader
System::AttributeSystem/Attribute.hpp
ObsoleteAttributeSystem/ObsoleteAttribute.hpp
FlagsAttributeSystem/FlagsAttribute.hpp
SerializableAttributeSystem/SerializableAttribute.hpp
CLSCompliantAttributeSystem/CLSCompliantAttribute.hpp
AttributeUsageAttributeSystem/AttributeUsageAttribute.hpp
Diagnostics::ConditionalAttributeSystem/Diagnostics/ConditionalAttribute.hpp
Runtime::CompilerServices::MethodImplAttributeSystem/Runtime/CompilerServices/MethodImplAttribute.hpp

No Dynamic Invocation

.NET Activator.CreateInstance(), MethodInfo.Invoke(), and similar reflection-based dynamic invocation are not available. These are listed as ❌ IGNORE in the porting plan, as they require managed runtime support that cannot be replicated in C++.

What to Use Instead