Skip to content

Add remarks and examples to Microsoft.Windows.System.Power API docs#124

Draft
GrantMeStrength wants to merge 3 commits into
docsfrom
grantmestrength/improve-power-api-docs
Draft

Add remarks and examples to Microsoft.Windows.System.Power API docs#124
GrantMeStrength wants to merge 3 commits into
docsfrom
grantmestrength/improve-power-api-docs

Conversation

@GrantMeStrength

Copy link
Copy Markdown
Contributor

Questions for SME reviewers

The following questions came up during authoring. Accurate answers would directly improve the docs — and are especially important for AI coding assistants (e.g. GitHub Copilot) that use API reference to generate code.

PowerManager properties

  1. RemainingDischargeTime when on AC — What does RemainingDischargeTime return when the device is plugged in? TimeSpan.Zero? TimeSpan.MaxValue? Should we document the behavior?
  2. RemainingChargePercent on desktop — What does RemainingChargePercent return on a desktop PC with no battery? 0? -1? Should we document the no-battery case?
  3. PowerSupplyStatus.Inadequate threshold — Is there a documented wattage or percentage threshold that distinguishes Inadequate from Adequate, or is this OEM-defined?
  4. EffectivePowerMode vs EffectivePowerMode2 — Why do both exist? Is EffectivePowerMode (async) deprecated in favor of EffectivePowerMode2 (sync)? Should we guide developers toward one?

Events

  1. Event thread/context — Are PowerManager events raised on the UI thread, a background thread, or the thread that subscribed? This affects whether developers need to marshal to the UI thread.
  2. SystemIdleStatusChanged — The existing remark says "Raised when the system is busy," which seems backwards. Is this raised when the system transitions to idle, from idle, or both?
  3. Event unsubscription — Do apps need to explicitly unsubscribe from PowerManager events on shutdown, or does the static event handler handle cleanup?

Enums

  1. BatteryStatus.Idle vs Charging — Is Idle specifically "fully charged and on AC" or can it also mean "on battery but not discharging" (e.g., conservation mode)?
  2. EffectivePowerMode ordering — We described the values as ordered from lowest to highest power. Is this ordering guaranteed/contractual, or just the current layout?
  3. SystemSuspendStatus.AutoResume triggers — What specific conditions cause AutoResume vs ManualResume? Wake timers? Network wake? Power button?

General

  1. Win32 parity — Are there any behavioral differences between these WinRT APIs and the underlying Win32 power setting GUIDs they wrap?
  2. Packaged vs unpackaged — Are there any capabilities or restrictions that differ between packaged (MSIX) and unpackaged apps for these APIs?

Summary

Adds remarks to 12 files in Microsoft.Windows.System.Power (namespace overview, PowerManager class, 6 properties, 4 enums). Adds a C# code example to the PowerManager class showing battery status checks and event subscriptions.

Changes

  • Namespace overview (microsoft_windows_system_power.md): Usage guidance and common scenarios
  • PowerManager class (powermanager.md): Static class guidance, packaged/unpackaged note, full C# example with battery check + event subscription + energy saver handling
  • 6 property files: BatteryStatus, EffectivePowerMode, EffectivePowerMode2, PowerSupplyStatus, RemainingDischargeTime, SystemSuspendStatus — usage guidance, related event/enum cross-references
  • 4 enum files: BatteryStatus, EffectivePowerMode, PowerSupplyStatus, SystemSuspendStatus — contextual remarks explaining when/how each value applies

Motivation

OGF quality scan identified 22/32 files in this namespace with empty or minimal remarks. This PR fills the highest-impact gaps. All claims are derived from the API signatures, enum field descriptions, and existing remarks in sibling files — no unverifiable claims.

Fill empty remarks sections for 12 files across the PowerManager namespace:
- Namespace overview: usage guidance and common scenarios
- PowerManager class: full remarks with C# code example showing
  battery check, event subscription, and energy saver handling
- 6 property files: BatteryStatus, EffectivePowerMode, EffectivePowerMode2,
  PowerSupplyStatus, RemainingDischargeTime, SystemSuspendStatus
- 4 enum files: BatteryStatus, EffectivePowerMode, PowerSupplyStatus,
  SystemSuspendStatus

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the API reference documentation for Microsoft.Windows.System.Power by adding practical remarks and a C# example to help developers correctly interpret power-related properties/events and related enums.

Changes:

  • Expanded remarks across the namespace overview, PowerManager class, several PowerManager properties, and multiple enums to provide usage guidance and cross-references.
  • Added a C# example to PowerManager showing power source checks and event subscriptions.
  • Added contextual explanations for enum values (for example, EffectivePowerMode, PowerSupplyStatus, SystemSuspendStatus, BatteryStatus).

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
microsoft.windows.system.power/microsoft_windows_system_power.md Adds namespace-level usage guidance and common scenarios.
microsoft.windows.system.power/powermanager.md Adds static-class guidance, packaged/unpackaged note, and a C# usage example.
microsoft.windows.system.power/powermanager_batterystatus.md Adds remarks describing how to interpret BatteryStatus and subscribe to changes.
microsoft.windows.system.power/powermanager_effectivepowermode.md Adds remarks describing EffectivePowerMode usage and a sync alternative.
microsoft.windows.system.power/powermanager_effectivepowermode2.md Adds remarks describing the synchronous EffectivePowerMode2 property and event subscription.
microsoft.windows.system.power/powermanager_powersupplystatus.md Adds remarks describing PowerSupplyStatus and subscribing to changes.
microsoft.windows.system.power/powermanager_remainingdischargetime.md Adds remarks describing RemainingDischargeTime meaning and relevant event.
microsoft.windows.system.power/powermanager_systemsuspendstatus.md Adds remarks on using SystemSuspendStatus with its event for suspend/resume handling.
microsoft.windows.system.power/batterystatus.md Adds enum remarks to interpret BatteryStatus values.
microsoft.windows.system.power/effectivepowermode.md Adds enum remarks explaining EffectivePowerMode usage and intended interpretation.
microsoft.windows.system.power/powersupplystatus.md Adds enum remarks to interpret PowerSupplyStatus values.
microsoft.windows.system.power/systemsuspendstatus.md Adds enum remarks explaining SystemSuspendStatus and resume distinctions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread microsoft.windows.system.power/microsoft_windows_system_power.md Outdated
Comment thread microsoft.windows.system.power/powermanager.md Outdated
Comment thread microsoft.windows.system.power/effectivepowermode.md Outdated
Comment thread microsoft.windows.system.power/systemsuspendstatus.md Outdated
Comment thread microsoft.windows.system.power/powersupplystatus.md Outdated
Comment thread microsoft.windows.system.power/powermanager_powersupplystatus.md Outdated
- Namespace overview: clarify enums exist alongside PowerManager class
- PowerManager: remove unverified packaged/unpackaged claim
- EffectivePowerMode enum: remove power-consumption ordering assertion
- SystemSuspendStatus enum: remove specific wake trigger examples
- PowerSupplyStatus enum + property: remove USB charger scenario

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Comment thread microsoft.windows.system.power/powermanager.md
Comment thread microsoft.windows.system.power/batterystatus.md Outdated
Comment thread microsoft.windows.system.power/powermanager_effectivepowermode.md Outdated
Comment thread microsoft.windows.system.power/powermanager_effectivepowermode2.md Outdated
- PowerManager: soften Win32 GUID wrapping claim to 'several correspond to'
- BatteryStatus: fix Idle definition to 'neither charging nor discharging'
- EffectivePowerMode property: use code formatting for enum values, not links
- EffectivePowerMode2: clarify relationship to async EffectivePowerMode

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants