diff --git a/src/Controls/src/Build.Tasks/ILContext.cs b/src/Controls/src/Build.Tasks/ILContext.cs index c1e4a3942115..3a0f8cac3686 100644 --- a/src/Controls/src/Build.Tasks/ILContext.cs +++ b/src/Controls/src/Build.Tasks/ILContext.cs @@ -44,5 +44,7 @@ public ILContext(ILProcessor il, MethodBody body, ModuleDefinition module, XamlC public string XamlFilePath { get; internal set; } public TaskLoggingHelper LoggingHelper { get; internal set; } + + public bool ValidateOnly { get; set; } } } diff --git a/src/Controls/src/Build.Tasks/NodeILExtensions.cs b/src/Controls/src/Build.Tasks/NodeILExtensions.cs index ec2a873b1fc1..c804f1070384 100644 --- a/src/Controls/src/Build.Tasks/NodeILExtensions.cs +++ b/src/Controls/src/Build.Tasks/NodeILExtensions.cs @@ -422,6 +422,10 @@ static Instruction PushParsedEnum(XamlCache cache, TypeReference enumRef, string public static IEnumerable PushXmlLineInfo(this INode node, ILContext context) { + if (context.ValidateOnly) + { + yield break; + } var module = context.Body.Method.Module; var xmlLineInfo = node as IXmlLineInfo; @@ -447,6 +451,10 @@ public static IEnumerable PushXmlLineInfo(this INode node, ILContex public static IEnumerable PushParentObjectsArray(this INode node, ILContext context) { + if (context.ValidateOnly) + { + yield break; + } var module = context.Body.Method.Module; var nodes = new List(); @@ -585,6 +593,10 @@ static IEnumerable PushNamescopes(INode node, ILContext context, Mo public static IEnumerable PushServiceProvider(this INode node, ILContext context, FieldReference bpRef = null, PropertyReference propertyRef = null, TypeReference declaringTypeReference = null) { + if (context.ValidateOnly) + { + yield break; + } var module = context.Body.Method.Module; #if NOSERVICEPROVIDER diff --git a/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs b/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs index b3a34d4b2ff6..440ddab23204 100644 --- a/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs +++ b/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs @@ -1666,6 +1666,7 @@ static void SetDataTemplate(IElementNode parentNode, ElementNode node, ILContext Root = root, XamlFilePath = parentContext.XamlFilePath, LoggingHelper = parentContext.LoggingHelper, + ValidateOnly = parentContext.ValidateOnly, }; //Instanciate nested class diff --git a/src/Controls/src/Build.Tasks/XamlCTask.cs b/src/Controls/src/Build.Tasks/XamlCTask.cs index 4b975c1ff012..c8fad9033484 100644 --- a/src/Controls/src/Build.Tasks/XamlCTask.cs +++ b/src/Controls/src/Build.Tasks/XamlCTask.cs @@ -354,6 +354,7 @@ bool TryCoreCompile(MethodDefinition initComp, ILRootNode rootnode, string xamlF { XamlFilePath = xamlFilePath, LoggingHelper = loggingHelper, + ValidateOnly = ValidateOnly, };