2011-11-25 2 views
1

내 실버 코드에의 FxCop을 실행하고 CA1051 오류 코드를 많이 받고있는 것으로 나타 오전 :xaml 코드의 필드에 CA1051을 수정하는 방법은 무엇입니까?

Error, Certainty 90, for DoNotDeclareVisibleInstanceFields 

Target  : #msgTextBox (IntrospectionTargetMember) 
Resolution : "Because field 'MessagingControl.msgTextBox' is 
       visible outside of its declaring type, change its accessibility 
       to private and add a property, with the same accessibility 
       as the field has currently, to provide access to it." 
Help   : http://msdn.microsoft.com/library/ms182141(VS.100).aspx (String) 
Category  : Microsoft.Design (String) 
CheckId  : CA1051 (String) 
RuleFile  : Design Rules (String) 
Info   : "Instance fields that are visible outside of the type 
       that declares them, limit your ability to change the 
       implementation details for those data items. Use properties 
       instead. They do not compromise usability or performance 
       and they do provide flexibility in that they conceal 
       the implementation details of the underlying data." 
Created  : 25/11/2011 10:59:54 (DateTime) 
LastSeen  : 25/11/2011 14:57:49 (DateTime) 
Status  : Active (MessageStatus) 
Fix Category : NonBreaking (FixCategories) 

이들의 대부분은 나는 그것이 해결 될 수 있다고 생각하지 않습니다 그래서 XAML에서 x:Name에서 것 같다 ? 이 오류를 모두 제거하지 않고 수정할 수있는 방법이 있습니까?

답변

2

제어 필드의 기본 표시 여부는 내부로 설정됩니다.

x:FieldModifier="<modifier>" 예 : 이 동작을 제어하려면 <TextBox x:Name="msgTextBox" x:FieldModifier="private" />.

+0

글쎄, 간단하고 쉬운 수정! 고맙습니다. 내가 발견 한 또 다른 점은 이러한 경우의 대안은 x : Name을 제거하는 것이고 다른 경고를 제거하는 것처럼 사용되지 않는 경우입니다. – Firedragon