Skip to content

fix: restore programmatic parameter loading in RdlViewer (issue #274)#278

Closed
majorsilence wants to merge 1 commit into
mainfrom
claude/issue-274-20260616-1010
Closed

fix: restore programmatic parameter loading in RdlViewer (issue #274)#278
majorsilence wants to merge 1 commit into
mainfrom
claude/issue-274-20260616-1010

Conversation

@majorsilence

Copy link
Copy Markdown
Owner

Fixes #274

The GetParameters() method introduced in 5.0.19 silently ignored programmatically-set parameters (via viewer.Parameters or SetReportParameters*) due to incorrect merge priority.

See issue for full analysis.

Generated with Claude Code

The GetParameters() method introduced in 5.0.19 preferred UserReportParameters.GetValueAsync()
over the _Parameters dictionary. On initial load, the runtime cache is empty so GetValueAsync()
returns null/default, and the merge skipped _Parameters values because the key was already
present. This caused programmatically-set parameters to be silently ignored.

Fix:
- GetParameters(): check _Parameters first for each UserReportParameter; fall back to
  GetValueAsync() only when no explicit value is set
- SetParameterValue(): initialize _Parameters if null (supports UI-only workflows)
- ParametersTextValidated/ParametersLeave: also persist UI-entered values back to _Parameters
  so they survive subsequent Rebuild() calls
- ParametersBuild: display _Parameters values in UI controls when set programmatically

Co-authored-by: Peter Gill <majorsilence@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 16, 2026 21:57

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 fixes a regression in RdlViewer where programmatically-provided report parameters (via viewer.Parameters / SetReportParameters*) could be silently ignored after the GetParameters() changes introduced in 5.0.19, restoring the intended precedence of explicitly set parameter values.

Changes:

  • Updates GetParameters() to prefer explicitly set _Parameters values over cached runtime parameter values.
  • Initializes _Parameters on-demand and persists UI-entered parameter values back into _Parameters.
  • Pre-populates the parameter UI with _Parameters values when available.

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

Comment thread RdlViewer/RdlViewer.cs
Comment on lines +1697 to +1701
if (_Parameters != null && _Parameters.Contains(rp.Name))
{
v.Text = _Parameters[rp.Name]?.ToString() ?? string.Empty;
}
else if (rp.DefaultValue != null)
Comment thread RdlViewer/RdlViewer.cs
Comment on lines 1502 to 1505
private async Task<IDictionary> GetParameters()
{
// If we have a loaded report with user parameters, use those runtime values
// instead of the _Parameters dictionary which may be stale
if (_Report != null && _Report.UserReportParameters != null && _Report.UserReportParameters.Count > 0)
{
Comment thread RdlViewer/RdlViewer.cs
Comment on lines +1509 to +1519
// Prefer explicitly-set _Parameters values over the runtime cache.
// _Parameters is populated programmatically and by UI interaction handlers,
// so it always reflects the most recent intended value.
if (_Parameters != null && _Parameters.Contains(urp.Name))
{
runtimeParams[urp.Name] = _Parameters[urp.Name];
}
else
{
runtimeParams[urp.Name] = await urp.GetValueAsync();
}
@majorsilence

Copy link
Copy Markdown
Owner Author

superseded by #280

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RdlViewer version 5.0.19

2 participants