diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/AssemblyVersionParseException.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/AssemblyVersionParseException.cs
new file mode 100644
index 00000000000..8e540654005
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/AssemblyVersionParseException.cs
@@ -0,0 +1,18 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+
+namespace MS.Internal
+{
+ ///
+ /// A typed exception to allow parse errors on AssemblyVersions to flow to
+ /// the MarkupCompile task execution.
+ ///
+ internal class AssemblyVersionParseException : Exception
+ {
+ public AssemblyVersionParseException(string message) : base(message) { }
+ }
+}
+
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/MarkupCompiler.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/MarkupCompiler.cs
index 76a0aa297a8..dcd53d75bae 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/MarkupCompiler.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/MarkupCompiler.cs
@@ -762,6 +762,13 @@ static void ThrowCompilerExceptionImpl(string message)
internal void OnError(Exception e)
{
+ // Don't treat an AssemblyVersion parsing error as a XamlParseException.
+ // Throw it back to the task execution.
+ if(e is AssemblyVersionParseException)
+ {
+ System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(e).Throw();
+ }
+
if (Error != null)
{
XamlParseException xe = e as XamlParseException;
@@ -2596,8 +2603,31 @@ private void GenerateInitializeComponent(bool isApp)
string uriPart = string.Empty;
- string version = String.IsNullOrEmpty(AssemblyVersion) ? String.Empty : COMPONENT_DELIMITER + VER + AssemblyVersion;
- string token = String.IsNullOrEmpty(AssemblyPublicKeyToken) ? String.Empty : COMPONENT_DELIMITER + AssemblyPublicKeyToken;
+ // Attempt to parse out the AssemblyVersion if it exists. This validates that we can either use an empty version string (wildcards exist)
+ // or we can utilize the passed in string (valid parse).
+ if (!VersionHelper.TryParseAssemblyVersion(AssemblyVersion, allowWildcard: true, version: out _, out bool hasWildcard)
+ && !string.IsNullOrWhiteSpace(AssemblyVersion))
+ {
+ throw new AssemblyVersionParseException(SR.Get(SRID.InvalidAssemblyVersion, AssemblyVersion));
+ }
+
+ // In .NET Framework (non-SDK-style projects), the process to use a wildcard AssemblyVersion is to do the following:
+ // - Modify the AssemblyVersionAttribute to a wildcard string (e.g. "1.2.*")
+ // - Set Deterministic to false in the build
+ // During MarkupCompilation, the AssemblyVersion property would not be set and WPF would correctly generate a resource URI without a version.
+ // In .NET Core/5 (or .NET Framework SDK-style projects), the same process can be used if GenerateAssemblyVersionAttribute is set to false in
+ // the build. However, this isn't really the idiomatic way to set the version for an assembly. Instead, developers are more likely to use the
+ // AssemblyVersion build property. If a developer explicitly sets the AssemblyVersion build property to a wildcard version string, we would use
+ // that as part of the URI here. This results in an error in Version.Parse during InitializeComponent's call tree. Instead, do as we would have
+ // when the developer sets a wildcard version string via AssemblyVersionAttribute and use an empty string.
+ string version = hasWildcard || String.IsNullOrEmpty(AssemblyVersion)
+ ? String.Empty
+ : COMPONENT_DELIMITER + VER + AssemblyVersion;
+
+ string token = String.IsNullOrEmpty(AssemblyPublicKeyToken)
+ ? String.Empty
+ : COMPONENT_DELIMITER + AssemblyPublicKeyToken;
+
uriPart = FORWARDSLASH + AssemblyName + version + token + COMPONENT_DELIMITER + COMPONENT + FORWARDSLASH + resourceID;
//
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/VersionHelper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/VersionHelper.cs
new file mode 100644
index 00000000000..807b3b24e1c
--- /dev/null
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/VersionHelper.cs
@@ -0,0 +1,215 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+// Modified from https://github.com/dotnet/roslyn/blob/91571a3bb038e05e7bf2ab87510273a1017faed0/src/Compilers/Core/Portable/VersionHelper.cs
+
+#nullable enable
+
+using System;
+using System.Diagnostics;
+using System.Globalization;
+
+namespace MS.Internal
+{
+ internal static class VersionHelper
+ {
+ static readonly Version NullVersion = new Version(0, 0, 0, 0);
+
+ ///
+ /// Parses a version string of the form "major [ '.' minor [ '.' build [ '.' revision ] ] ]".
+ ///
+ /// The version string to parse.
+ /// If parsing succeeds, the parsed version. Otherwise a version that represents as much of the input as could be parsed successfully.
+ /// True when parsing succeeds completely (i.e. every character in the string was consumed), false otherwise.
+ internal static bool TryParse(string s, out Version version)
+ {
+ return TryParse(s, allowWildcard: false, maxValue: ushort.MaxValue, allowPartialParse: true, version: out version, hasWildcard: out bool _);
+ }
+
+ ///
+ /// Parses a version string of the form "major [ '.' minor [ '.' ( '*' | ( build [ '.' ( '*' | revision ) ] ) ) ] ]"
+ /// as accepted by System.Reflection.AssemblyVersionAttribute.
+ ///
+ /// The version string to parse.
+ /// Indicates whether or not a wildcard is accepted as the terminal component.
+ ///
+ /// If parsing succeeded, the parsed version. Otherwise a version instance with all parts set to zero.
+ /// If contains * the version build and/or revision numbers are set to .
+ ///
+ /// If parsing succeeds, indicates if a wilcard character was found in the version.
+ /// True when parsing succeeds completely (i.e. every character in the string was consumed), false otherwise.
+ internal static bool TryParseAssemblyVersion(string s, bool allowWildcard, out Version version, out bool hasWildcard)
+ {
+ return TryParse(s, allowWildcard: allowWildcard, maxValue: ushort.MaxValue - 1, allowPartialParse: false, version: out version, hasWildcard: out hasWildcard);
+ }
+
+ ///
+ /// Parses a version string of the form "major [ '.' minor [ '.' ( '*' | ( build [ '.' ( '*' | revision ) ] ) ) ] ]"
+ /// as accepted by System.Reflection.AssemblyVersionAttribute.
+ ///
+ /// The version string to parse.
+ /// Indicates whether or not we're parsing an assembly version string. If so, wildcards are accepted and each component must be less than 65535.
+ /// The maximum value that a version component may have.
+ /// Allow the parsing of version elements where invalid characters exist. e.g. 1.2.2a.1
+ ///
+ /// If parsing succeeded, the parsed version. When is true a version with values up to the first invalid character set. Otherwise a version with all parts set to zero.
+ /// If contains * and wildcard is allowed the version build and/or revision numbers are set to .
+ ///
+ /// True when parsing succeeds completely (i.e. every character in the string was consumed), false otherwise.
+ private static bool TryParse(string s, bool allowWildcard, ushort maxValue, bool allowPartialParse, out Version version, out bool hasWildcard)
+ {
+ Debug.Assert(!allowWildcard || maxValue < ushort.MaxValue);
+
+ if (string.IsNullOrWhiteSpace(s))
+ {
+ hasWildcard = false;
+ version = NullVersion;
+ return false;
+ }
+
+ string[] elements = s.Split('.');
+
+ // If the wildcard is being used, the first two elements must be specified explicitly, and
+ // the last must be a exactly single asterisk without whitespace.
+ hasWildcard = allowWildcard && elements[elements.Length - 1] == "*";
+
+ if ((hasWildcard && elements.Length < 3) || elements.Length > 4)
+ {
+ version = NullVersion;
+ return false;
+ }
+
+ ushort[] values = new ushort[4];
+ int lastExplicitValue = hasWildcard ? elements.Length - 1 : elements.Length;
+ bool parseError = false;
+ for (int i = 0; i < lastExplicitValue; i++)
+ {
+
+ if (!ushort.TryParse(elements[i], NumberStyles.None, CultureInfo.InvariantCulture, out values[i]) || values[i] > maxValue)
+ {
+ if (!allowPartialParse)
+ {
+ version = NullVersion;
+ return false;
+ }
+
+ parseError = true;
+
+ if (string.IsNullOrWhiteSpace(elements[i]))
+ {
+ values[i] = 0;
+ break;
+ }
+
+
+ if (values[i] > maxValue)
+ {
+ //The only way this can happen is if the value was 65536
+ //The old compiler would continue parsing from here
+ values[i] = 0;
+ continue;
+ }
+
+ bool invalidFormat = false;
+ System.Numerics.BigInteger number = 0;
+
+ //There could be an invalid character in the input so check for the presence of one and
+ //parse up to that point. examples of invalid characters are alphas and punctuation
+ for (var idx = 0; idx < elements[i].Length; idx++)
+ {
+ if (!char.IsDigit(elements[i][idx]))
+ {
+ invalidFormat = true;
+
+ TryGetValue(elements[i].Substring(0, idx), out values[i]);
+ break;
+ }
+ }
+
+ if (!invalidFormat)
+ {
+ //if we made it here then there weren't any alpha or punctuation chars in the input so the
+ //element is either greater than ushort.MaxValue or possibly a fullwidth unicode digit.
+ if (TryGetValue(elements[i], out values[i]))
+ {
+ //For this scenario the old compiler would continue processing the remaining version elements
+ //so continue processing
+ continue;
+ }
+ }
+
+ //Don't process any more of the version elements
+ break;
+ }
+ }
+
+
+
+
+ if (hasWildcard)
+ {
+ for (int i = lastExplicitValue; i < values.Length; i++)
+ {
+ values[i] = ushort.MaxValue;
+ }
+ }
+
+ version = new Version(values[0], values[1], values[2], values[3]);
+ return !parseError;
+ }
+
+ private static bool TryGetValue(string s, out ushort value)
+ {
+ System.Numerics.BigInteger number;
+ if (System.Numerics.BigInteger.TryParse(s, NumberStyles.None, CultureInfo.InvariantCulture, out number))
+ {
+ //The old compiler would take the 16 least significant bits and use their value as the output
+ //so we'll do that too.
+ value = (ushort)(number % 65536);
+ return true;
+ }
+
+ //One case that will cause us to end up here is when the input is a Fullwidth unicode digit
+ //so we'll always return zero
+ value = 0;
+ return false;
+ }
+
+ ///
+ /// If build and/or revision numbers are 65535 they are replaced with time-based values.
+ ///
+ public static Version? GenerateVersionFromPatternAndCurrentTime(DateTime time, Version pattern)
+ {
+ if (pattern == null || pattern.Revision != ushort.MaxValue)
+ {
+ return pattern;
+ }
+
+ // MSDN doc on the attribute:
+ // "The default build number increments daily. The default revision number is the number of seconds since midnight local time
+ // (without taking into account time zone adjustments for daylight saving time), divided by 2."
+ if (time == default(DateTime))
+ {
+ time = DateTime.Now;
+ }
+
+ int revision = (int)time.TimeOfDay.TotalSeconds / 2;
+
+ // 24 * 60 * 60 / 2 = 43200 < 65535
+ Debug.Assert(revision < ushort.MaxValue);
+
+ if (pattern.Build == ushort.MaxValue)
+ {
+ TimeSpan days = time.Date - new DateTime(2000, 1, 1);
+ int build = Math.Min(ushort.MaxValue, (int)days.TotalDays);
+
+ return new Version(pattern.Major, pattern.Minor, (ushort)build, (ushort)revision);
+ }
+ else
+ {
+ return new Version(pattern.Major, pattern.Minor, pattern.Build, (ushort)revision);
+ }
+ }
+ }
+}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/PresentationBuildTasks.csproj b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/PresentationBuildTasks.csproj
index 5a05b0abbdf..4ee07f3eb76 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/PresentationBuildTasks.csproj
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/PresentationBuildTasks.csproj
@@ -275,10 +275,12 @@
-
-
-
-
+
+
+
+
+
+
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/Strings.resx b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/Strings.resx
index 4976c426162..372dbc7a056 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/Strings.resx
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/Strings.resx
@@ -243,6 +243,9 @@
MC1004: Project file cannot specify more than one SplashScreen element.
+
+ MC1005: Invalid AssemblyVersion detected: {0}.
+
FC1001: The UICulture value '{0}' set in the project file is not valid.
@@ -834,4 +837,4 @@
MC8002: BracketCharacter '{0}' at Line Number '{1}' and Line Position '{2}' does not have a corresponding opening/closing BracketCharacter.
-
+
\ No newline at end of file
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.cs.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.cs.xlf
index 27ee2659280..7bd3bee260e 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.cs.xlf
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.cs.xlf
@@ -152,6 +152,11 @@
Třída InternalTypeHelper není pro tento projekt požadována, vyprázdněte soubor {0}.
+
+
+ MC1005: Invalid AssemblyVersion detected: {0}.
+
+ MC6018: Název třídy {0} je neplatný pro místně definovaný kořenový prvek XAML.
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.de.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.de.xlf
index 839ee2981da..a551600c20d 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.de.xlf
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.de.xlf
@@ -152,6 +152,11 @@
Die InternalTypeHelper-Klasse ist für dieses Projekt nicht erforderlich, leeren Sie die Datei "{0}".
+
+
+ MC1005: Invalid AssemblyVersion detected: {0}.
+
+ MC6018: Klassenname "{0}" ist für das lokal definierte XAML-Stammelement ungültig.
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.es.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.es.xlf
index 267ead27943..7dff8e6506c 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.es.xlf
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.es.xlf
@@ -152,6 +152,11 @@
No se requiere la clase InternalTypeHelper para este proyecto, vacíe el archivo '{0}'.
+
+
+ MC1005: Invalid AssemblyVersion detected: {0}.
+
+ MC6018: el nombre de clase '{0}' no es válido para el elemento raíz XAML definido localmente.
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.fr.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.fr.xlf
index 1a64a6a5c8f..b9d96aef697 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.fr.xlf
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.fr.xlf
@@ -152,6 +152,11 @@
Classe InternalTypeHelper non obligatoire pour ce projet, fichier Make '{0}' vide.
+
+
+ MC1005: Invalid AssemblyVersion detected: {0}.
+
+ MC6018 : nom de classe '{0}' non valide pour l'élément racine XAML défini localement.
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.it.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.it.xlf
index 1d63840194a..0b1064ba9c4 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.it.xlf
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.it.xlf
@@ -152,6 +152,11 @@
La classe InternalTypeHelper non è richiesta per questo progetto, file make '{0}' vuoto.
+
+
+ MC1005: Invalid AssemblyVersion detected: {0}.
+
+ MC6018: il nome di classe '{0}' non è valido per l'elemento radice XAML definito in locale.
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.ja.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.ja.xlf
index 90a4b191307..cb68de42850 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.ja.xlf
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.ja.xlf
@@ -152,6 +152,11 @@
このプロジェクトには、InternalTypeHelper クラスは不要です。ファイル '{0}' を空にしてください。
+
+
+ MC1005: Invalid AssemblyVersion detected: {0}.
+
+ MC6018: '{0}' クラス名は、ローカルで定義された XAML ルート要素に対して無効です。
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.ko.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.ko.xlf
index 01f90b67234..aa66c9192ee 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.ko.xlf
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.ko.xlf
@@ -152,6 +152,11 @@
이 프로젝트에 InternalTypeHelper 클래스가 필요하지 않습니다. '{0}' 파일을 비우십시오.
+
+
+ MC1005: Invalid AssemblyVersion detected: {0}.
+
+ MC6018: 로컬에 정의된 XAML 루트 요소에 '{0}' 클래스 이름을 사용할 수 없습니다.
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.pl.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.pl.xlf
index 79f96a11589..5e4dfc69b0d 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.pl.xlf
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.pl.xlf
@@ -152,6 +152,11 @@
Klasa InternalTypeHelper nie jest wymagana dla tego projektu. Plik make „{0}” jest pusty.
+
+
+ MC1005: Invalid AssemblyVersion detected: {0}.
+
+ MC6018: Nazwa klasy „{0}” jest nieprawidłowa dla zdefiniowanego lokalnie elementu głównego XAML.
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.pt-BR.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.pt-BR.xlf
index f3c4579bc33..dd5079eb641 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.pt-BR.xlf
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.pt-BR.xlf
@@ -152,6 +152,11 @@
A classe InternalTypeHelper não é necessária para este projeto; esvazie o arquivo '{0}'.
+
+
+ MC1005: Invalid AssemblyVersion detected: {0}.
+
+ MC6018: o nome da classe '{0}' não é válido para o elemento raiz XAML definido localmente.
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.ru.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.ru.xlf
index c85ba8244fb..2b122d68303 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.ru.xlf
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.ru.xlf
@@ -152,6 +152,11 @@
Для данного проекта класс InternalTypeHelper не требуется, сделайте пустой файл "{0}".
+
+
+ MC1005: Invalid AssemblyVersion detected: {0}.
+
+ MC6018: недопустимое имя класса "{0}" для локально определенного корневого элемента XAML.
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.tr.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.tr.xlf
index bb4ac4f1e56..0494c793561 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.tr.xlf
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.tr.xlf
@@ -152,6 +152,11 @@
InternalTypeHelper sınıfı bu proje için gerekli değil, '{0}' dosyasını boşaltın.
+
+
+ MC1005: Invalid AssemblyVersion detected: {0}.
+
+ MC6018: '{0}' sınıf adı yerel olarak tanımlanmış XAML kök öğesi için geçerli değil.
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.zh-Hans.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.zh-Hans.xlf
index de2ae4fd31f..e85378847c8 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.zh-Hans.xlf
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.zh-Hans.xlf
@@ -152,6 +152,11 @@
该项目不需要 InternalTypeHelper 类,使文件“{0}”为空。
+
+
+ MC1005: Invalid AssemblyVersion detected: {0}.
+
+ MC6018:“{0}”类名对本地定义的 XAML 根元素无效。
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.zh-Hant.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.zh-Hant.xlf
index 2894d151c25..a7c002c7f8d 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.zh-Hant.xlf
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Resources/xlf/Strings.zh-Hant.xlf
@@ -152,6 +152,11 @@
對於此專案,InternalTypeHelper 類別不是必要項目,將檔案 '{0}' 清空。
+
+
+ MC1005: Invalid AssemblyVersion detected: {0}.
+
+ MC6018: 對於 XAML 根項目而言,在本機定義的 '{0}' 類別名稱是無效的。
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlParser.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlParser.cs
index 08f07e01caf..ed11a6d13b4 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlParser.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlParser.cs
@@ -69,7 +69,7 @@ internal enum XamlParseMode
internal class XamlParser
{
#if PBTCOMPILER
- #region Constructors
+ #region Constructors
///
/// Constructor that takes a stream and creates an XmlCompatibilityReader on it.
@@ -96,7 +96,7 @@ protected XamlParser(
// entity expansion technique. In System.Xml V2.0, in order to provide protection against DTD DoS attacks there
// is the capability of turning off DTD parsing through the use of the ProhibitDtd property.
-#pragma warning disable 0618
+#pragma warning disable 0618
// CS0618: A class member was marked with the Obsolete attribute, such that a warning
// will be issued when the class member is referenced.
textReader.ProhibitDtd = true;
@@ -123,9 +123,9 @@ protected XamlParser()
{
}
-#endregion Constructors
+ #endregion Constructors
- #region PublicMethods
+ #region PublicMethods
///
@@ -203,6 +203,13 @@ public bool ReadXaml(bool singleRecordMode)
}
else
{
+ // Don't treat an AssemblyVersion parsing error as a XamlParseException.
+ // Throw it back to the task execution.
+ if(e is AssemblyVersionParseException)
+ {
+ throw;
+ }
+
if (e is XamlParseException)
{
throw;
@@ -531,9 +538,9 @@ internal virtual void ProcessXamlNode(
}
-#endregion // PublicMethods
+ #endregion // PublicMethods
- #region Virtuals
+ #region Virtuals
///
/// Called when parsing begins
@@ -1099,7 +1106,7 @@ public virtual bool GetElementType(
}
-#endregion Virtuals
+ #endregion Virtuals
///
@@ -1156,7 +1163,7 @@ void WriteDefAttributeCore(XamlDefAttributeNode xamlDefAttributeNode)
WriteDefAttribute(xamlDefAttributeNode);
}
- #region Methods
+ #region Methods
// virtuals to override the default implementation. used by the compiler
// for internal virtuals review why not public as the others?
@@ -1272,9 +1279,9 @@ internal bool IsXmlNamespaceSupported(string xmlNamespace, out string newXmlName
TokenReader.IsXmlDataIsland();
}
}
-#endregion Methods
+ #endregion Methods
- #region Properties
+ #region Properties
///
/// TokenReader that is being used.
@@ -1380,9 +1387,9 @@ internal virtual bool StrictParsing
}
-#endregion Properties
+ #endregion Properties
- #region Data
+ #region Data
@@ -1407,7 +1414,7 @@ internal virtual bool StrictParsing
XamlReaderHelper.DefaultNamespaceURI,
XamlReaderHelper.DefinitionMetroNamespaceURI
};
- #endregion Data
+ #endregion Data
#endif