Overview
Testing is crucial for ensuring your struct definitions and function signatures work correctly. This guide covers building the project, testing signatures, and verifying your changes.Building the Project
Prerequisites
- .NET SDK: Install the version required by the project
- Visual Studio or Rider (recommended) or VS Code
- Git: For version control
Clone and Build
Build Configuration
Common Build Errors
Missing FieldOffset
[FieldOffset(0xXX)] to every field.
Invalid Signature Format
?? for wildcards and 2 hex digits per byte.
Type Not Unmanaged
byte* or FixedSizeArray instead of managed types.
Missing partial Keyword
partial keyword to the method.
Project Structure
The solution contains several projects:FFXIVClientStructs
The main library with all struct and function definitions. Location:source/FFXIVClientStructs/
InteropGenerator
Source generator that creates function wrappers. Location:source/InteropGenerator/
InteropGenerator.Runtime
Runtime support library with attributes and resolver. Location:source/InteropGenerator.Runtime/
InteropGenerator.Tests
Unit tests for the source generator. Location:source/InteropGenerator.Tests/
Run tests:
FFXIVClientStructs.ResolverTester
Test project for verifying signatures resolve correctly at runtime. Location:source/FFXIVClientStructs.ResolverTester/
FFXIVClientStructs.StdContainerTester
Test project for STD container wrappers (vector, map, etc.). Location:source/FFXIVClientStructs.StdContainerTester/
Testing Struct Layouts
Verify Field Offsets
In your IDE, check the generated code to ensure field offsets are correct.Using Visual Studio/Rider
- Build the project
- Navigate to your struct definition
- Right-click on the struct name → Go to Implementation or Generated Files
- Review the generated code
Memory Size Verification
Ensure the struct size matches the native size:Check for Overlaps
Be careful not to overlap fields unintentionally:Testing Signatures
Using ResolverTester
The ResolverTester project tests signature resolution against a running FFXIV process.Setup
- Start FFXIV
- Open
source/FFXIVClientStructs.ResolverTester/Program.cs - Add code to test your signatures
Example Test Code
Build and Run
Interpreting Results
Success:- Check the signature is correct
- Verify the signature is unique (use IDA/Ghidra)
- Ensure the offset is correct for StaticAddress
- Check that the game version matches your binary
Testing Function Resolution
Test that function signatures resolve:Signature Resolution Reports
The resolver can generate reports of failed signatures:Testing Function Behavior
Using Dalamud Plugin
The best way to test functions is with a Dalamud plugin:Verify Return Values
Check that functions return sensible values:Testing Virtual Functions
Verify VTable Index
Ensure the virtual function index is correct:Test Virtual Calls
Testing Arrays
FixedSizeArray
Test that array access works:String Arrays
Testing in Production
Dalamud Plugin Testing
- Create a test Dalamud plugin
- Reference your local build of FFXIVClientStructs
- Test struct access and function calls
- Verify behavior in various game scenarios
Beta Testing
- Ask community members to test your changes
- Test across different game content (duties, overworld, etc.)
- Monitor for crashes or incorrect behavior
- Gather feedback on API usability
Automated Testing
Unit Tests
The InteropGenerator.Tests project has unit tests for the generator:- Generator produces correct code
- Attributes are parsed correctly
- Analyzers catch errors
CI/CD
The repository uses GitHub Actions for CI:- Builds on every commit
- Runs unit tests
- Checks code formatting
Common Testing Issues
Signature Doesn’t Resolve
Symptoms: Function returns null or throws exception Solutions:- Check signature uniqueness in IDA/Ghidra
- Verify signature format (use
??, not?) - Test with ResolverTester
- Check game version matches your reverse engineering binary
Wrong Function Called
Symptoms: Function has unexpected side effects Solutions:- Verify signature points to correct function
- Check parameter types and order
- Ensure calling convention is correct (should be automatic)
- Verify virtual function index
Crashes
Symptoms: Game crashes when calling function Solutions:- Check parameter types match native function
- Verify struct pointer is valid (not null)
- Ensure you’re not passing managed types
- Check that pointers point to valid memory
- Verify function signature is correct
Incorrect Return Values
Symptoms: Function returns garbage or wrong data Solutions:- Check return type matches native function
- Verify you’re calling the right function
- Ensure struct layout is correct
- Check for calling convention issues
Best Practices
- Test Early: Build and test as you add definitions
- Test Thoroughly: Don’t just test happy paths
- Test In-Game: Runtime testing is essential
- Test Edge Cases: Null pointers, invalid IDs, etc.
- Document Behavior: Note any quirks or special cases
- Use ResolverTester: Verify signatures before committing
- Get Feedback: Have others test your changes
Checklist Before Submitting PR
- Project builds without errors
- All signatures are tested with ResolverTester
- Functions tested in-game (via Dalamud plugin or tool)
- Return values verified as sensible
- No crashes when calling functions
- Field offsets verified against IDA/Ghidra
- Struct size is correct
- Code follows style guidelines
- Comments added for complex/uncertain parts
- No unrelated changes included
Getting Help
- GitHub Issues: Report bugs or ask questions
- Discord: Dalamud Discord for community support
- PR Comments: Ask maintainers for feedback
Next Steps
- Contributing Guide - Submit your changes
- Adding Structs - Add new struct definitions
- Adding Functions - Add function definitions
- Signatures Guide - Create robust signatures