Comments for Michael Shim http://michaelshim.com/blog XAML, WPF & Silverlight Fri, 07 May 2010 16:52:53 +0000 hourly 1 http://wordpress.org/?v=3.0.4 Comment on Running FxCop rules against Silverlight or WPF XAML by Michael Shim http://michaelshim.com/blog/2009/11/23/running-fxcop-rules-against-silverlight-xaml/comment-page-1/#comment-187 Michael Shim Fri, 07 May 2010 16:52:53 +0000 http://michaelshim.com/blog/?p=29#comment-187 It's in Microsxoft.Xaml.Tools.XamlDom. Here's a simple sample where we check to see if a property is set more than once: <code> using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xaml.Tools.XamlDom; using System.Xaml; using Microsoft.FxCop.Sdk; namespace Microsoft.Xaml.Tools.FxCop.Rules { public class PropertiesCanOnlyBeSetOnce : BaseXamlRule { public PropertiesCanOnlyBeSetOnce() : base("PropertiesCanOnlyBeSetOnce") { } public override void CheckXaml(XamlDomObject rootObjectNode, System.Xaml.XamlSchemaContext schemaContext, string resourceName) { foreach (XamlDomObject objectNode in rootObjectNode.DescendantsAndSelf()) { List<XamlMember> membersSet = new List<XamlMember>(); foreach (XamlDomMember memberNode in objectNode.MemberNodes) { if (!membersSet.Contains(memberNode.Member)) { membersSet.Add(memberNode.Member); } else { Problems.Add(CreateProblem(GetResolution(memberNode.Member.Name), memberNode.Member.Name, memberNode, resourceName)); } } } } } } </code> It’s in Microsxoft.Xaml.Tools.XamlDom. Here’s a simple sample where we check to see if a property is set more than once:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xaml.Tools.XamlDom;
using System.Xaml;
using Microsoft.FxCop.Sdk;

namespace Microsoft.Xaml.Tools.FxCop.Rules
{
public class PropertiesCanOnlyBeSetOnce : BaseXamlRule
{
public PropertiesCanOnlyBeSetOnce() : base("PropertiesCanOnlyBeSetOnce") { }

public override void CheckXaml(XamlDomObject rootObjectNode, System.Xaml.XamlSchemaContext schemaContext, string resourceName)
{
foreach (XamlDomObject objectNode in rootObjectNode.DescendantsAndSelf())
{
List membersSet = new List();
foreach (XamlDomMember memberNode in objectNode.MemberNodes)
{
if (!membersSet.Contains(memberNode.Member))
{
membersSet.Add(memberNode.Member);
}
else
{
Problems.Add(CreateProblem(GetResolution(memberNode.Member.Name), memberNode.Member.Name, memberNode, resourceName));
}
}
}
}
}
}

]]>
Comment on Running FxCop rules against Silverlight or WPF XAML by Parixit Pandey http://michaelshim.com/blog/2009/11/23/running-fxcop-rules-against-silverlight-xaml/comment-page-1/#comment-181 Parixit Pandey Thu, 06 May 2010 08:04:38 +0000 http://michaelshim.com/blog/?p=29#comment-181 Hi Michael, Now I am able to add XAML Toolkit Rules in FxCop 1.36 and even able to run the silverlight Application against it. But After running the application Not getting any error. In case I want to write my own custom rules for XMAL what steps I have to follow. Could I get any sample code snippets. Already I had added following code public abstract class BaseXamlRule : BaseIntrospectionRule { public abstract void CheckXaml(XamlDomObject rootObjectNode, XamlSchemaContext schemaContext, string resourceName) { } } for XamlSchemaContext added System.XMAL Namespace but still I am not able to get XamlDomObject Class. What namespace I have to add for it ? Please Provide sample code snippets writing XMAL rules. Thanks, Parixit Pandey Hi Michael,

Now I am able to add XAML Toolkit Rules in FxCop 1.36 and even able to run the silverlight Application against it. But After running the application Not getting any error.

In case I want to write my own custom rules for XMAL what steps I have to follow. Could I get any sample code snippets.
Already I had added following code
public abstract class BaseXamlRule : BaseIntrospectionRule
{
public abstract void CheckXaml(XamlDomObject rootObjectNode,
XamlSchemaContext schemaContext,
string resourceName)
{

}
}

for XamlSchemaContext added System.XMAL Namespace but still I am not able to get XamlDomObject Class. What namespace I have to add for it ?

Please Provide sample code snippets writing XMAL rules.

Thanks,
Parixit Pandey

]]>
Comment on Use XamlReader.Load for WPF XAML (not XamlServices.Load) by Michael Shim http://michaelshim.com/blog/2009/12/10/use-xamlreader-load-for-wpf-xaml-not-xamlservices-load/comment-page-1/#comment-170 Michael Shim Tue, 04 May 2010 04:18:03 +0000 http://michaelshim.com/blog/2009/12/10/use-xamlreader-load-for-wpf-xaml-not-xamlservices-load/#comment-170 Could you give me a little more detail on what you're trying to accomplish? Email me at mishim at microsoft dot com. Thanks! Could you give me a little more detail on what you’re trying to accomplish? Email me at mishim at microsoft dot com.

Thanks!

]]>
Comment on Running FxCop rules against Silverlight or WPF XAML by Michael Shim http://michaelshim.com/blog/2009/11/23/running-fxcop-rules-against-silverlight-xaml/comment-page-1/#comment-169 Michael Shim Tue, 04 May 2010 04:15:30 +0000 http://michaelshim.com/blog/?p=29#comment-169 We're currently working on getting a build of the Xaml Toolkit that works well against VS2010 RTM & FxCop 10. We'll update you when we fix this. We’re currently working on getting a build of the Xaml Toolkit that works well against VS2010 RTM & FxCop 10. We’ll update you when we fix this.

]]>
Comment on Use XamlReader.Load for WPF XAML (not XamlServices.Load) by akjoshi http://michaelshim.com/blog/2009/12/10/use-xamlreader-load-for-wpf-xaml-not-xamlservices-load/comment-page-1/#comment-162 akjoshi Fri, 30 Apr 2010 13:37:58 +0000 http://michaelshim.com/blog/2009/12/10/use-xamlreader-load-for-wpf-xaml-not-xamlservices-load/#comment-162 Can you please look at this thread and give some solution for problems in XAMALReader - http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ef97f8a1-2773-46a3-8133-d895c4486b12 Can you please look at this thread and give some solution for problems in XAMALReader -

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ef97f8a1-2773-46a3-8133-d895c4486b12

]]>
Comment on Running FxCop rules against Silverlight or WPF XAML by Parixit Pandey http://michaelshim.com/blog/2009/11/23/running-fxcop-rules-against-silverlight-xaml/comment-page-1/#comment-136 Parixit Pandey Fri, 23 Apr 2010 10:51:06 +0000 http://michaelshim.com/blog/?p=29#comment-136 Hi Michael, In my Machine I had Installed VS2010 Ultimate edition. even I had Installed FxCop 1.36 and Downloaded XAML Toolkit Rules. in Fxcop FxCop.exe.config file changed VS2010 Version But when I am trying to add rules in Fxcorp it giving error rules are not valid. Hi Michael,

In my Machine I had Installed VS2010 Ultimate edition. even I had Installed FxCop 1.36 and Downloaded XAML Toolkit Rules. in Fxcop FxCop.exe.config file changed VS2010 Version But when I am trying to add rules in Fxcorp it giving error rules are not valid.

]]>
Comment on Use XamlReader.Load for WPF XAML (not XamlServices.Load) by George http://michaelshim.com/blog/2009/12/10/use-xamlreader-load-for-wpf-xaml-not-xamlservices-load/comment-page-1/#comment-117 George Wed, 14 Apr 2010 21:09:03 +0000 http://michaelshim.com/blog/2009/12/10/use-xamlreader-load-for-wpf-xaml-not-xamlservices-load/#comment-117 How does it compare with using XamlXmlReader with WPF Schema context? I have a configuration XAML that contains a wpf datatemplate xaml in it. I am hoping that I can parse through it using XamlXmlReader and use WPF schema context to get the Data template and a custom schema context for the rest of the xaml. Is that the right approach? Guidance will be very much appreciated. Thanks, -George How does it compare with using XamlXmlReader with WPF Schema context?
I have a configuration XAML that contains a wpf datatemplate xaml in it. I am hoping that I can parse through it using XamlXmlReader and use WPF schema context to get the Data template and a custom schema context for the rest of the xaml.
Is that the right approach? Guidance will be very much appreciated.
Thanks,
-George

]]>
Comment on GetObject vs StartObject in System.Xaml by Markus Tamm » Blog Archive » Links 23.03.2010 http://michaelshim.com/blog/2010/03/18/getobject-vs-startobject/comment-page-1/#comment-75 Markus Tamm » Blog Archive » Links 23.03.2010 Tue, 23 Mar 2010 08:51:18 +0000 http://michaelshim.com/blog/?p=46#comment-75 [...] GetObject vs StartObject in System.Xaml (Michael Shim) [...] [...] GetObject vs StartObject in System.Xaml (Michael Shim) [...]

]]>
Comment on GetObject vs StartObject in System.Xaml by Dew Drop – March 19, 2010 | Alvin Ashcraft's Morning Dew http://michaelshim.com/blog/2010/03/18/getobject-vs-startobject/comment-page-1/#comment-68 Dew Drop – March 19, 2010 | Alvin Ashcraft's Morning Dew Fri, 19 Mar 2010 12:48:27 +0000 http://michaelshim.com/blog/?p=46#comment-68 [...] GetObject vs StartObject in System.Xaml (Michael Shim) [...] [...] GetObject vs StartObject in System.Xaml (Michael Shim) [...]

]]>
Comment on XAML Toolkit CTP by WP Themes http://michaelshim.com/blog/2009/11/19/xaml-toolkit-ctp/comment-page-1/#comment-63 WP Themes Sat, 13 Mar 2010 19:33:45 +0000 http://michaelshim.com/blog/?p=11#comment-63 Nice brief and this enter helped me alot in my college assignement. Thank you on your information. Nice brief and this enter helped me alot in my college assignement. Thank you on your information.

]]>