CA1811 warning for private imported properties in WPF

.net, c#, mef, properties, wpf

Solution

It is "normal" warning when using MEF and Code Analysis together.

Your property will be set at run-time by MEF container via reflection, hence, there's no any call of property setter, which could be proven statically by CA. The only way is to suppress this message by `SuppressMessage` attribute:

[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[Import]
private Lazy<IVoiceController> VoiceController { get; set; }

Problem

I have a public Controller class inside which I am using following properties ``` [Import] private TransferRegionViewModel TransferRegionView { get; set; } [Import] private Lazy<IVoiceController> VoiceController { get; set; } ``` I am getting following CA warning: CA1811 : Microsoft.Performance: 'TransferController.VoiceController.set(Lazy)' appears to have no upstream public or protected callers. I am using VoicdeController property as : ``` VoiceController.Value.CallTransfer(phoneNumber.PhoneNumber, true); ``` I referred this one - Properties private set; but don't understand if I need to set property internal or private.

Original source

Related problems