You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You are working on the DAQiFi Core library - a .NET library that provides foundational interfaces and implementations for interacting with DAQiFi hardware devices. This library serves as the core foundation that will be used by desktop applications, web services, and other DAQiFi software.
5
+
6
+
## Architecture & Patterns
7
+
8
+
### Device Interface Pattern
9
+
- All device classes should implement `IDevice` or `IStreamingDevice` interfaces
10
+
- Use event-driven architecture with `StatusChanged` and `MessageReceived` events
11
+
- Implement virtual methods that can be overridden for testing and customization
12
+
- Use generic `Send<T>(IOutboundMessage<T>)` methods for type safety
13
+
14
+
### Message System
15
+
- All outbound messages implement `IOutboundMessage<T>` with strongly-typed data payloads
16
+
- All inbound messages implement `IInboundMessage<T>`
17
+
- Use `ScpiMessageProducer` for creating SCPI command messages
18
+
- Support multiple message formats: SCPI strings, Protocol Buffers, JSON
19
+
20
+
### Connection Management
21
+
- Use `ConnectionStatus` enum for device states: Disconnected, Connecting, Connected, Lost
22
+
- Implement connection state transitions with proper event notifications
23
+
- Always check `IsConnected` before sending messages
24
+
- Throw `InvalidOperationException` for operations on disconnected devices
25
+
26
+
## Code Style & Standards
27
+
28
+
### C# Conventions
29
+
- Use nullable reference types (`#nullable enable`)
30
+
- Prefer `var` only when type is obvious from right-hand side
31
+
- Use expression-bodied members for simple properties and methods
32
+
- Follow Microsoft C# naming conventions (PascalCase for public members, camelCase for private)
33
+
34
+
### Documentation
35
+
- ALL public classes, interfaces, and members MUST have XML documentation
36
+
- Use `<summary>`, `<param>`, `<returns>`, `<exception>` tags appropriately
37
+
- Include code examples in documentation for complex APIs
38
+
- Document thread safety characteristics
39
+
- Use `<see cref=""/>` for cross-references
40
+
41
+
### Error Handling
42
+
- Use specific exception types (`InvalidOperationException`, `ArgumentException`, etc.)
43
+
- Include clear, actionable error messages
44
+
- Document all exceptions that public methods can throw
45
+
- Validate parameters and throw appropriate exceptions early
46
+
47
+
### Testing Patterns
48
+
- Create testable versions of classes using inheritance and virtual methods
49
+
- Use `TestableDaqifiDevice` pattern for mocking device behavior
50
+
- Test all public methods, properties, and events
51
+
- Include tests for error conditions and edge cases
52
+
- Use meaningful test method names: `MethodName_Scenario_ExpectedResult`
0 commit comments