| 216 | } |
| 217 | |
| 218 | void FindDebugCommands(BinaryModule* module) |
| 219 | { |
| 220 | if (module == GetBinaryModuleCorlib()) |
| 221 | return; |
| 222 | PROFILE_CPU(); |
| 223 | PROFILE_MEM(EngineDebug); |
| 224 | |
| 225 | #if USE_CSHARP |
| 226 | if (auto* managedModule = dynamic_cast<ManagedBinaryModule*>(module)) |
| 227 | { |
| 228 | const MClass* attribute = ((NativeBinaryModule*)GetBinaryModuleFlaxEngine())->Assembly->GetClass("FlaxEngine.DebugCommand"); |
| 229 | ASSERT_LOW_LAYER(attribute); |
| 230 | const auto& classes = managedModule->Assembly->GetClasses(); |
| 231 | for (const auto& e : classes) |
| 232 | { |
| 233 | MClass* mclass = e.Value; |
| 234 | if (mclass->IsGeneric() || |
| 235 | mclass->IsInterface() || |
| 236 | mclass->IsEnum()) |
| 237 | continue; |
| 238 | const bool useClass = mclass->HasAttribute(attribute); |
| 239 | |
| 240 | // Process methods |
| 241 | const auto& methods = mclass->GetMethods(); |
| 242 | for (MMethod* method : methods) |
| 243 | { |
| 244 | if (!method->IsStatic()) |
| 245 | continue; |
| 246 | const StringAnsiView name = method->GetName(); |
| 247 | if (name.Contains("Internal_") || |
| 248 | mclass->GetFullName().Contains(".Interop.")) |
| 249 | continue; |
| 250 | if (name.StartsWith("get_") || |
| 251 | name.StartsWith("set_") || |
| 252 | name.StartsWith("op_") || |
| 253 | name.StartsWith("add_") || |
| 254 | name.StartsWith("remove_")) |
| 255 | continue; |
| 256 | if (!useClass && !method->HasAttribute(attribute)) |
| 257 | continue; |
| 258 | if (useClass && method->GetVisibility() != MVisibility::Public) |
| 259 | continue; |
| 260 | |
| 261 | auto& commandData = Commands.AddOne(); |
| 262 | BuildName(commandData, mclass, method->GetName()); |
| 263 | commandData.Module = module; |
| 264 | commandData.Method = method; |
| 265 | } |
| 266 | |
| 267 | // Process fields |
| 268 | const auto& fields = mclass->GetFields(); |
| 269 | for (MField* field : fields) |
| 270 | { |
| 271 | if (!field->IsStatic()) |
| 272 | continue; |
| 273 | if (!useClass && !field->HasAttribute(attribute)) |
| 274 | continue; |
| 275 | if (useClass && field->GetVisibility() != MVisibility::Public) |
no test coverage detected