Repository navigation
Write a quoted empty default as "" instead of dropping it [patch] - #177
Conversation
With DefaultValueIsQuoted set, empty raw text is the empty string, not "no initialiser". WriteDefaultValueTo and PropertyTemplate now treat a default as set when it is quoted or non-empty, so `string separator = ""` stays optional and `const string Empty = ""` keeps its value. Fixes #174 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW4VgeC1VNAtTYhxCrm
# Conflicts: # CodeBlocker/Templates/TemplateBase.cs
|
I merged Update: the red CI described below is now fixed on main. #162 changed Original note
Generated by Claude Code |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5jpiuVuBRXSgitSY1
|



Fixes #174
What changed
WriteDefaultValueToandPropertyTemplateused to skip the initialiser wheneverDefaultValuewas empty. They did this even withDefaultValueIsQuotedset, where empty raw text means the empty string"". Both now go through oneprivate protected HasDefaultValue => DefaultValueIsQuoted || !string.IsNullOrEmpty(DefaultValue), so the following now render correctly:string separator = ""stays optional. Before, it became required, which gave CS1737 after an earlier optional parameter.public const string Empty = "";keeps its value. Before, the missing value gave CS0145.= "";.An empty default without quoting still writes no initialiser. The
DefaultValuedoc now explains the quoted case. The new member isprivate protected, so the public API does not change.Tests
TemplateTests, covering a parameter, a method with a trailing optional parameter, a const field, a shorthand property and a braced property. They also confirm that an unquoted empty default still writes nothing..sonarlint/sonar-local.props) reports only the five existing S2699 findings in the test project.Generated by Claude Code