Skip to content
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

Add readonly modifier to fields #876

Merged
merged 1 commit into from
Jan 13, 2024

Conversation

Dennis40816
Copy link
Contributor

Made several fields readonly based on Code QL suggestions (#875). This ensures they are only assigned during declaration or inside constructors.

Affected files:

  • src/Caliburn.Micro.Core/SimpleContainer.cs
  • src/Caliburn.Micro.Platform/Bind.cs
  • src/Caliburn.Micro.Platform/Platforms/Maui/Windows/MauiPlatformProvider.cs
  • src/Caliburn.Micro.Platform/Platforms/uap/FrameAdapter.cs
  • src/Caliburn.Micro.Platform/Platforms/uap/XamlMetadataProvider.cs
  • src/Caliburn.Micro.Platform/XamlPlatformProvider.cs

Made several fields `readonly` based on Code QL suggestions (Caliburn-Micro#875).
This ensures they are only assigned during declaration or inside constructors.

Affected files:
- src/Caliburn.Micro.Core/SimpleContainer.cs
- src/Caliburn.Micro.Platform/Bind.cs
- src/Caliburn.Micro.Platform/Platforms/Maui/Windows/MauiPlatformProvider.cs
- src/Caliburn.Micro.Platform/Platforms/uap/FrameAdapter.cs
- src/Caliburn.Micro.Platform/Platforms/uap/XamlMetadataProvider.cs
- src/Caliburn.Micro.Platform/XamlPlatformProvider.cs
@Dennis40816 Dennis40816 changed the title Caliburn-Micro#875: Add readonly modifier to fields Add readonly modifier to fields Oct 10, 2023
@vb2ae vb2ae linked an issue Oct 10, 2023 that may be closed by this pull request
@@ -15,7 +15,7 @@ public class SimpleContainer
private static readonly Type enumerableType = typeof(IEnumerable);
private static readonly TypeInfo enumerableTypeInfo = enumerableType.GetTypeInfo();
private static readonly TypeInfo delegateTypeInfo = delegateType.GetTypeInfo();
private Type simpleContainerType = typeof(SimpleContainer);
private readonly Type simpleContainerType = typeof(SimpleContainer);
Copy link
Member

Choose a reason for hiding this comment

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

thanks

@@ -53,7 +53,7 @@ public static class Bind {
null,
ModelWithoutContextChanged);

internal static DependencyProperty NoContextProperty =
internal static readonly DependencyProperty NoContextProperty =
Copy link
Member

Choose a reason for hiding this comment

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

thanks

@@ -17,7 +17,7 @@ namespace Caliburn.Micro
public class FrameAdapter : INavigationService, IDisposable
{
#if WINDOWS_UWP
private SystemNavigationManager navigationManager;
private readonly SystemNavigationManager navigationManager;
#endif
Copy link
Member

Choose a reason for hiding this comment

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

thanks

private Dictionary<string, IXamlType> _xamlTypes = new Dictionary<string, IXamlType>();
private Dictionary<string, IXamlMember> _xamlMembers = new Dictionary<string, IXamlMember>();
private Dictionary<Type, string> _xamlTypeToStandardName = new Dictionary<Type, string>();
private readonly Dictionary<string, IXamlType> _xamlTypes = new Dictionary<string, IXamlType>();
Copy link
Member

Choose a reason for hiding this comment

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

thanks

@@ -152,8 +152,8 @@ internal class XamlTypeInfoProvider {


internal class XamlSystemBaseType : IXamlType {
private string _fullName;
private Type _underlyingType;
private readonly string _fullName;
Copy link
Member

Choose a reason for hiding this comment

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

thanks

private string _fullName;
private Type _underlyingType;
private readonly string _fullName;
private readonly Type _underlyingType;

public XamlSystemBaseType(string fullName, Type underlyingType) {
Copy link
Member

Choose a reason for hiding this comment

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

thanks

@@ -17,9 +17,9 @@
/// </summary>
public class XamlPlatformProvider : IPlatformProvider {
#if WINDOWS_UWP
private CoreDispatcher dispatcher;
private readonly CoreDispatcher dispatcher;
Copy link
Member

Choose a reason for hiding this comment

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

thanks

#else
private Dispatcher dispatcher;
private readonly Dispatcher dispatcher;
Copy link
Member

Choose a reason for hiding this comment

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

thanks

Copy link
Member

@vb2ae vb2ae left a comment

Choose a reason for hiding this comment

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

Looks good

@vb2ae vb2ae merged commit 680de02 into Caliburn-Micro:master Jan 13, 2024
3 checks passed
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.

Make variables readonly
2 participants