-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ProcessLinkerXmlBase to NativeAOT (#63666)
Add Xml Parsing linker files as a reference source to NativeAOT Rename NativeAOT ProcessLinkerXmlBase version to ProcessXmlBase (uses XmlReader) Add ProcessLinkerXmlBase from linker and fix it so it can be used in NativeAOT (uses XPath)
- Loading branch information
Showing
13 changed files
with
2,696 additions
and
186 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/FeatureSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Xml.XPath; | ||
using ILLink.Shared; | ||
using Internal.TypeSystem; | ||
|
||
namespace ILCompiler | ||
{ | ||
public static class FeatureSettings | ||
{ | ||
public static bool ShouldProcessElement(XPathNavigator nav, IReadOnlyDictionary<string, bool> featureSwitchValues) | ||
{ | ||
var feature = GetAttribute(nav, "feature"); | ||
if (string.IsNullOrEmpty(feature)) | ||
return true; | ||
|
||
var value = GetAttribute(nav, "featurevalue"); | ||
if (string.IsNullOrEmpty(value)) | ||
{ | ||
//context.LogError(null, DiagnosticId.XmlFeatureDoesNotSpecifyFeatureValue, documentLocation, feature); | ||
return false; | ||
} | ||
|
||
if (!bool.TryParse(value, out bool bValue)) | ||
{ | ||
//context.LogError(null, DiagnosticId.XmlUnsupportedNonBooleanValueForFeature, documentLocation, feature); | ||
return false; | ||
} | ||
|
||
var isDefault = GetAttribute(nav, "featuredefault"); | ||
bool bIsDefault = false; | ||
if (!string.IsNullOrEmpty(isDefault) && (!bool.TryParse(isDefault, out bIsDefault) || !bIsDefault)) | ||
{ | ||
//context.LogError(null, DiagnosticId.XmlDocumentLocationHasInvalidFeatureDefault, documentLocation); | ||
return false; | ||
} | ||
|
||
if (!featureSwitchValues.TryGetValue(feature, out bool featureSetting)) | ||
return bIsDefault; | ||
|
||
return bValue == featureSetting; | ||
} | ||
|
||
public static string GetAttribute(XPathNavigator nav, string attribute) | ||
{ | ||
return nav.GetAttribute(attribute, String.Empty); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.