Files
DP44/enriched-qwen3-coder-next/Common/DTS.Common.Service/Properties.md

99 lines
4.8 KiB
Markdown
Raw Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- Common/DTS.Common.Service/Properties/AssemblyInfo.cs
- Common/DTS.Common.Service/Properties/Settings.Designer.cs
generated_at: "2026-04-16T03:43:57.997232+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "d8e42dfbcf704680"
---
# Properties
## Documentation: `DTS.Common.Service.Properties` Module
---
### 1. **Purpose**
This module provides strongly-typed, auto-generated application and user settings for the `DTS.Common.Service` assembly via .NETs `ApplicationSettingsBase`. It enables centralized, type-safe access to configuration values such as monitoring state, polling interval, and service names, which are persisted at application and user scopes respectively. It exists to decouple runtime configuration from code logic and to support design-time tooling (e.g., Visual Studio Settings Designer) for managing settings.
---
### 2. **Public Interface**
The module exposes a single internal sealed class: `DTS.Common.Service.Properties.Settings`.
#### `Settings.Default` (static property)
```csharp
public static Settings Default { get; }
```
- Returns the singleton instance of `Settings`, thread-safe due to `Synchronized()` wrapping.
- Used to access all settings properties.
#### `Settings.Monitoring` (read-only application-scoped property)
```csharp
public bool Monitoring { get; }
```
- Default value: `false`.
- Indicates whether monitoring is enabled for the service.
- Application-scoped → read-only at runtime; value is fixed at compile time.
#### `Settings.Interval` (read-only application-scoped property)
```csharp
public int Interval { get; }
```
- Default value: `60000` (milliseconds).
- Represents the polling or monitoring interval.
- Application-scoped → immutable at runtime.
#### `Settings.ServiceName` (read-only application-scoped property)
```csharp
public string ServiceName { get; }
```
- Default value: `"DTS Common Service"`.
- The canonical name of the service (e.g., for registration or logging).
- Application-scoped.
#### `Settings.Service` (read-write user-scoped property)
```csharp
public string Service { get; set; }
```
- Default value: `"DTS Service"`.
- User-scoped → can be modified at runtime and persisted per-user.
- Intended for customization (e.g., instance-specific service name overrides).
---
### 3. **Invariants**
- `Settings.Default` is guaranteed to be non-null and thread-safe (via `Synchronized()`).
- Application-scoped settings (`Monitoring`, `Interval`, `ServiceName`) are immutable at runtime; their values are fixed by the compiled `.config` file or designer defaults.
- User-scoped setting `Service` may be modified at runtime, but changes are *not* persisted automatically—explicit `Save()` call (on `Settings.Default`) is required to persist user changes.
- All settings values are validated only by their declared types (e.g., `bool`, `int`, `string`); no additional runtime validation is present in this module.
---
### 4. **Dependencies**
#### Dependencies *of* this module:
- `System.Configuration` (for `ApplicationSettingsBase`, attributes like `[ApplicationScopedSettingAttribute]`, `[UserScopedSettingAttribute]`)
- `System.Runtime.CompilerServices` (for `[CompilerGeneratedAttribute]`)
- `System.CodeDom.Compiler` (for `[GeneratedCodeAttribute]`)
- `System.Diagnostics` (for `[DebuggerNonUserCodeAttribute]`)
#### Dependencies *on* this module:
- The broader `DTS.Common.Service` assembly (and likely its Windows Service entry point) consumes `Settings.Default` to configure behavior (e.g., `Settings.Monitoring`, `Settings.Interval`).
- No other modules *in this repository* are visible as consumers, but the assembly is intended for reuse (per namespace `DTS.Common.Service`).
---
### 5. **Gotchas**
- **Settings are not auto-saved**: User-scoped setting `Service` requires explicit `Settings.Default.Save()` to persist changes across sessions. Omitting this will cause changes to be lost on restart.
- **Application-scoped settings are compile-time constants**: Modifying values in `App.config` *after* compilation will not affect `Monitoring`, `Interval`, or `ServiceName` unless the assembly is recompiled. These values are baked into the generated `Settings.Designer.cs`.
- **Thread-safety is limited**: While `Synchronized()` ensures thread-safe *access* to the singleton instance, concurrent writes to user-scoped settings (e.g., `Settings.Default.Service = "..."`) are *not* protected—external synchronization is required if multi-threaded mutation occurs.
- **Auto-generated code**: The `Settings.Designer.cs` file is marked with `<auto-generated>` and warns that manual edits will be lost on regeneration (e.g., after re-saving settings in Visual Studio).
- **No versioning or migration logic**: No `SettingsUpgradeRequired` or migration handling is present; changes to settings structure may require manual migration or reset.
None identified beyond the above.