Caliburn-Micro / Caliburn.Micro

A small, yet powerful framework, designed for building applications across all XAML platforms. Its strong support for MV* patterns will enable you to build your solution quickly, without the need to sacrifice code quality or testability.
http://caliburnmicro.com/
MIT License
2.79k stars 775 forks source link

Make variables readonly #875

Closed vb2ae closed 7 months ago

vb2ae commented 10 months ago

private field where all assignments occur as part of the declaration or in a constructor in the same class can be readonly. Making a field readonly prevents unintended assignments after object initialization.

Please fix the following Code QL issues

src/Caliburn.Micro.Platform/XamlPlatformProvider.cs:20

      /// </summary>
      public class XamlPlatformProvider : IPlatformProvider {
     #if WINDOWS_UWP
          private CoreDispatcher dispatcher;

  Field 'dispatcher' can be 'readonly'.

src/Caliburn.Micro.Platform/Platforms/uap/XamlMetadataProvider.cs:91

        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>();

Field '_xamlTypeToStandardName' can be 'readonly'.

src/Caliburn.Micro.Platform/Platforms/uap/XamlMetadataProvider.cs:90 }

        private Dictionary<string, IXamlType> _xamlTypes = new Dictionary<string, IXamlType>();
        private Dictionary<string, IXamlMember> _xamlMembers = new Dictionary<string, IXamlMember>();

Field '_xamlMembers' can be 'readonly'.

src/Caliburn.Micro.Platform/Platforms/uap/XamlMetadataProvider.cs:156

     internal class XamlSystemBaseType : IXamlType {
        private string _fullName;
        private Type _underlyingType;

Field '_underlyingType' can be 'readonly'.

src/Caliburn.Micro.Platform/Platforms/uap/XamlMetadataProvider.cs:89 return xamlMember; }

        private Dictionary<string, IXamlType> _xamlTypes = new Dictionary<string, IXamlType>();

Field '_xamlTypes' can be 'readonly'.

src/Caliburn.Micro.Platform/Platforms/uap/XamlMetadataProvider.cs:155

    internal class XamlSystemBaseType : IXamlType {
        private string _fullName;

        Field '_fullName' can be 'readonly'.

src/Caliburn.Micro.Platform/Platforms/uap/FrameAdapter.cs:20

     public class FrameAdapter : INavigationService, IDisposable
     {
 #if WINDOWS_UWP
        private SystemNavigationManager navigationManager;

 Field 'navigationManager' can be 'readonly'.

src/Caliburn.Micro.Platform/Platforms/Maui/Windows/MauiPlatformProvider.cs:19

    /// </summary>
    public class MauiPlatformProvider : IPlatformProvider 
    {
        private CoreDispatcher dispatcher;

Field 'dispatcher' can be 'readonly'.

src/Caliburn.Micro.Platform/XamlPlatformProvider.cs:22

   #if WINDOWS_UWP
          private CoreDispatcher dispatcher;
  #else
          private Dispatcher dispatcher;

Field 'dispatcher' can be 'readonly'.

src/Caliburn.Micro.Platform/Bind.cs:56

                null, 
                ModelWithoutContextChanged);

        internal static DependencyProperty NoContextProperty =

Field 'NoContextProperty' can be 'readonly'.

src/Caliburn.Micro.Core/SimpleContainer.cs:18

        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);

Field 'simpleContainerType' can be 'readonly'.
Dennis40816 commented 10 months ago

Hi, I'm interested in this task. Can I give it a try?

vb2ae commented 10 months ago

@Dennis40816 sure

vb2ae commented 10 months ago

sorry did not realize you could not get to the links. updating ticket now. will review pr in the morning