-
Notifications
You must be signed in to change notification settings - Fork 8
Some refactors #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some refactors #14
Conversation
MykhailoDav
commented
Nov 26, 2025
- Added Copilot promts
- added editorconfig
- Refactor SegControlTest1 and Test2ViewModel for consistency; update ElementChildrenChanging constructor
…lementChildrenChanging constructor
…y and consistency; update access modifiers and formatting
…ifiers and formatting across multiple files
There was a problem hiding this comment.
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 refactors the codebase for consistency and adds development guidelines. It includes:
- Addition of GitHub Copilot prompts and instructions for contributors
- Introduction of an
.editorconfigfile with coding standards - Code refactoring across handlers and samples to align with new standards (access modifiers, field naming, formatting)
Reviewed changes
Copilot reviewed 27 out of 28 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| Handler files (iOS, MacCatalyst, Android) | Added explicit private access modifiers to methods and fields; reformatted code for consistency |
| AppHostBuilderExtensions.cs | Converted to file-scoped namespace and updated handler registration syntax |
| SegmentedControlOption.cs | Updated field naming from underscore-prefix to camelCase; changed to file-scoped namespace |
| SegmentedControl.cs, ISegmentedControl.cs | Applied formatting consistency; changed to file-scoped namespace |
| GroupToggleBehavior.cs, ElementChildrenChanging.cs | Converted to file-scoped namespace; used primary constructor |
| Test2ViewModel.cs | Refactored field naming to camelCase; converted to file-scoped namespace; used collection expressions |
| Sample code-behind files | Updated field naming and access modifiers to match editorconfig rules |
| .editorconfig | Added comprehensive coding standards including naming rules, analyzers, and formatting preferences |
| Copilot prompt files | Added coding guidelines, best practices, and testing patterns |
Comments suppressed due to low confidence (1)
samples/SegmentedControlSamples/SegControlTest1.xaml.cs:70
- Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.
if (SegmentedControl.SelectedTextColor != Colors.Red)
{
SegmentedControl.SelectedTextColor = Colors.Red;
}
else
{
SegmentedControl.SelectedTextColor = Colors.Green;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/Plugin.Maui.SegmentedControl/Control/SegmentedControlOption.cs
Outdated
Show resolved
Hide resolved
src/Plugin.Maui.SegmentedControl/Control/SegmentedControlOption.cs
Outdated
Show resolved
Hide resolved
|
@MykhailoDav I've opened a new pull request, #15, to work on those changes. Once the pull request is ready, I'll request review from you. |
…n.cs Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
…olTest1 constructor
Co-authored-by: Copilot <[email protected]>
…n constructor for improved logging consistency
There was a problem hiding this comment.
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 27 out of 28 changed files in this pull request and generated 8 comments.
Comments suppressed due to low confidence (1)
samples/SegmentedControlSamples/SegControlTest1.xaml.cs:62
- Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.
if (SegmentedControl.SelectedTextColor != Colors.Red)
{
SegmentedControl.SelectedTextColor = Colors.Red;
}
else
{
SegmentedControl.SelectedTextColor = Colors.Green;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Test2ViewModel viewModel; | ||
|
|
||
| public SegControlTest2() | ||
| { | ||
| InitializeComponent(); | ||
| SegmentedControl.BindingContext = _viewModel = new Test2ViewModel(); | ||
|
|
||
| SegmentedControl.BindingContext = viewModel = new Test2ViewModel(); | ||
| } | ||
|
|
||
| private void SegmentedControl_ValueChanged(object sender, Plugin.Maui.SegmentedControl.ValueChangedEventArgs e) | ||
| void SegmentedControl_ValueChanged(object sender, Plugin.Maui.SegmentedControl.ValueChangedEventArgs e) | ||
| { | ||
| segmentIndexLabel.Text = e.NewValue.ToString(); | ||
| } | ||
|
|
||
| PlayerStatus _playerStatus = PlayerStatus.Stopped; | ||
| private void SegmentedControl_SegmentTapped(object sender, SegmentTappedEventArgs e) | ||
| PlayerStatus playerStatus = PlayerStatus.Stopped; | ||
| void SegmentedControl_SegmentTapped(object sender, SegmentTappedEventArgs e) | ||
| { | ||
| if (e.Index == 1) | ||
| { | ||
| if (_playerStatus == PlayerStatus.Playing) | ||
| if (playerStatus == PlayerStatus.Playing) | ||
| { | ||
| SegmentedControl.Children[1].Text = "Play"; | ||
| _playerStatus = PlayerStatus.Stopped; | ||
| playerStatus = PlayerStatus.Stopped; | ||
| } | ||
| else | ||
| { | ||
| SegmentedControl.Children[1].Text = "Stop"; | ||
| _playerStatus = PlayerStatus.Playing; | ||
| playerStatus = PlayerStatus.Playing; | ||
| } | ||
| } |
Copilot
AI
Nov 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The private modifiers added to fields and methods contradict the project's coding guidelines. According to .github/copilot-instructions.md line 128: "We do not use the private keyword as it is the default accessibility level in C#."
These access modifiers should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback
| PlayerStatus playerStatus; | ||
| PlayerStatus PlayerStatus | ||
| { | ||
| get { return playerStatus; } | ||
| set | ||
| { | ||
| get { return this.PlayerStatus.ToString(); } | ||
| playerStatus = value; | ||
| OnPropertyChanged(new PropertyChangedEventArgs(nameof(PlayerStatusText))); | ||
| PlayButtonText = playerStatus == PlayerStatus.Playing ? "STOP" : "Play"; | ||
| } | ||
| } | ||
|
|
||
| private string _playButtonText; | ||
| public string PlayButtonText | ||
| { | ||
| get => _playButtonText; | ||
| set { _playButtonText = value; OnPropertyChanged(new PropertyChangedEventArgs(nameof(PlayButtonText))); } | ||
| } | ||
| public string PlayerStatusText | ||
| { | ||
| get { return PlayerStatus.ToString(); } | ||
| } | ||
|
|
||
| private bool _backButtonEnabled = true; | ||
| public bool BackButtonEnabled | ||
| { | ||
| get => _backButtonEnabled; | ||
| set { _backButtonEnabled = value; OnPropertyChanged(new PropertyChangedEventArgs(nameof(BackButtonEnabled))); } | ||
| } | ||
| string playButtonText; | ||
| public string PlayButtonText | ||
| { | ||
| get => playButtonText; | ||
| set { playButtonText = value; OnPropertyChanged(new PropertyChangedEventArgs(nameof(PlayButtonText))); } | ||
| } | ||
|
|
||
| private bool _forwardButtonEnabled = true; | ||
| public bool ForwardButtonEnabled | ||
| { | ||
| get => _forwardButtonEnabled; | ||
| set { _forwardButtonEnabled = value; OnPropertyChanged(new PropertyChangedEventArgs(nameof(ForwardButtonEnabled))); } | ||
| } | ||
| bool backButtonEnabled = true; | ||
| public bool BackButtonEnabled | ||
| { | ||
| get => backButtonEnabled; | ||
| set { backButtonEnabled = value; OnPropertyChanged(new PropertyChangedEventArgs(nameof(BackButtonEnabled))); } | ||
| } | ||
|
|
||
| private string _forwardButtonText; | ||
| public string ForwardButtonText | ||
| { | ||
| get => _forwardButtonText; | ||
| set { _forwardButtonText = value; OnPropertyChanged(new PropertyChangedEventArgs(nameof(ForwardButtonText))); } | ||
| } | ||
| bool forwardButtonEnabled = true; | ||
| public bool ForwardButtonEnabled | ||
| { | ||
| get => forwardButtonEnabled; | ||
| set { forwardButtonEnabled = value; OnPropertyChanged(new PropertyChangedEventArgs(nameof(ForwardButtonEnabled))); } | ||
| } | ||
|
|
||
| string forwardButtonText; | ||
| public string ForwardButtonText | ||
| { | ||
| get => forwardButtonText; | ||
| set { forwardButtonText = value; OnPropertyChanged(new PropertyChangedEventArgs(nameof(ForwardButtonText))); } | ||
| } | ||
|
|
||
| private int _selectedSegment; | ||
| public int SelectedSegment | ||
| { | ||
| get => _selectedSegment; | ||
| set | ||
| { | ||
| _selectedSegment = value; | ||
| OnPropertyChanged(new PropertyChangedEventArgs(nameof(SelectedSegment))); | ||
| } | ||
| } | ||
| private IList<SegmentedControlOption> _segmentItemsSource; | ||
| public IList<SegmentedControlOption> SegmentItemsSource | ||
| int selectedSegment; | ||
| public int SelectedSegment | ||
| { | ||
| get => selectedSegment; | ||
| set | ||
| { | ||
| get => _segmentItemsSource; | ||
| set { _segmentItemsSource = value; OnPropertyChanged(new PropertyChangedEventArgs(nameof(SegmentItemsSource))); } | ||
| selectedSegment = value; | ||
| OnPropertyChanged(new PropertyChangedEventArgs(nameof(SelectedSegment))); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| public event PropertyChangedEventHandler PropertyChanged; | ||
| protected virtual void OnPropertyChanged(PropertyChangedEventArgs e) | ||
| { | ||
| PropertyChanged?.Invoke(this, e); | ||
| } | ||
| IList<SegmentedControlOption> segmentItemsSource; | ||
| public IList<SegmentedControlOption> SegmentItemsSource | ||
| { | ||
| get => segmentItemsSource; | ||
| set { segmentItemsSource = value; OnPropertyChanged(new PropertyChangedEventArgs(nameof(SegmentItemsSource))); } | ||
| } |
Copilot
AI
Nov 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The private modifiers added to fields contradict the project's coding guidelines. According to .github/copilot-instructions.md line 128: "We do not use the private keyword as it is the default accessibility level in C#."
These access modifiers should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback
| private SegmentedControl parent; | ||
|
|
||
| int _instanceId; | ||
| private readonly int instanceId; |
Copilot
AI
Nov 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The private modifiers added to fields contradict the project's coding guidelines. According to .github/copilot-instructions.md line 128: "We do not use the private keyword as it is the default accessibility level in C#."
These access modifiers should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback
Co-authored-by: yurkinh <[email protected]>
… coding guidelines Co-authored-by: yurkinh <[email protected]>
Co-authored-by: yurkinh <[email protected]>
Remove private keyword from fields per coding guidelines
[WIP] Address feedback from review on some refactors PR
Co-authored-by: yurkinh <[email protected]>
…d75-8222-2696c59534da Remove private modifiers per coding guidelines
No changes needed - typo already corrected
Verify removal of private modifiers in Test2ViewModel.cs
Address coding guidelines feedback - private modifiers already removed