5.0.24-preview now generates CA1810 and CA2207 code analysis warnings

jahmai's Avatar

jahmai

13 May, 2017 09:41 AM

e.g.:

Error CA2207 Microsoft.Usage : Initialize all static fields in 'xxx' when those fields are declared and remove the explicit static constructor.

  1. Support Staff 1 Posted by PostSharp Techn... on 14 May, 2017 03:11 AM

    PostSharp Technologies's Avatar

    Hello,

    Could you please attach a decompilation of the class - at least the static fields and the static constructor.
    Thanks.

    -gael

  2. 2 Posted by jahmai on 14 May, 2017 07:49 AM

    jahmai's Avatar

    Here's an example, I believe it's due to the Initialize method injected into the static constructor.
    I believe this was a problem with a previous release in v4 which was then fixed, and this is a regression since 5.0.23-preview.

    [HasInheritedAttribute(new long[] { 0x5c6ee90f2be2dfd1L })]
    public class StunClientSettings : Sealable
    {
        // Fields
        [CompilerGenerated, DebuggerBrowsable(0)]
        private bool <RetransmissionsEnabled>k__BackingField;
        [CompilerGenerated, DebuggerBrowsable(0)]
        private IWaitStrategy <RetransmissionWaitStrategy>k__BackingField = WaitStrategy.Multiplied(TimeSpan.FromMilliseconds((double) 500.0), 2.0).SetMaxIterations(7);
    
        // Methods
        [CompilerGenerated, DebuggerAspectGeneratedCode]
        static StunClientSettings()
        {
            <>z__a_81.Initialize();
        }
    
        // Properties
        public bool RetransmissionsEnabled
        {
            [CompilerGenerated]
            get => 
                this.<RetransmissionsEnabled>k__BackingField;
            [CompilerGenerated]
            set
            {
                MethodExecutionArgs args = new MethodExecutionArgs(this, null);
                <>z__a_81.a2263.OnEntry(args);
                this.<RetransmissionsEnabled>k__BackingField = value;
            }
        }
    
        [NotNull]
        public IWaitStrategy RetransmissionWaitStrategy
        {
            [CompilerGenerated]
            get => 
                this.<RetransmissionWaitStrategy>k__BackingField;
            [CompilerGenerated]
            set
            {
                Exception exception = <>z__a_81.a2261.ValidateValue(value, "RetransmissionWaitStrategy", LocationKind.Property, LocationValidationContext.Precondition);
                if (exception != null)
                {
                    throw exception;
                }
                MethodExecutionArgs args = new MethodExecutionArgs(this, null);
                <>z__a_81.a2265.OnEntry(args);
                this.<RetransmissionWaitStrategy>k__BackingField = value;
            }
        }
    }
    
    [CompilerGenerated, DebuggerAspectGeneratedCode]
    internal sealed class <>z__a_81
    {
        // Fields
        internal static LocationInfo _1 = ReflectionHelper.GetLocation(typeof(StunClientSettings), (MethodInfo) methodof(StunClientSettings.get_RetransmissionWaitStrategy), (MethodInfo) methodof(StunClientSettings.set_RetransmissionWaitStrategy));
        internal static readonly NotNullAttribute a2261 = new NotNullAttribute();
        internal static readonly SealableAttribute a2263 = ((SealableAttribute) <>z__a_20d.aspects1[0x97]);
        internal static readonly SealableAttribute a2265 = ((SealableAttribute) <>z__a_20d.aspects1[0x98]);
    
        // Methods
        [CompilerGenerated, DebuggerAspectGeneratedCode]
        static <>z__a_81()
        {
            a2261.RuntimeInitialize(_1);
        }
    
        public static void Initialize()
        {
        }
    }
    
  3. Support Staff 3 Posted by PostSharp Techn... on 17 May, 2017 03:25 PM

    PostSharp Technologies's Avatar

    Hello,

    Thanks for the decompilation. Unfortunately we are not able reproduce the issue.

    Please, could you provide us a minimal example project?

    Best Regards,

    Jakub

  4. Support Staff 4 Posted by PostSharp Techn... on 26 Jun, 2017 11:30 AM

    PostSharp Technologies's Avatar

    Hello,

    We are going to close this request as there have not been any further updates. Please feel free to reopen the discussion if you need more help.

    Thanks,
    PostSharp Team

  5. PostSharp Technologies closed this discussion on 26 Jun, 2017 11:30 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac