567 instantiations of XElement
aspire (53)
Projects\DotNetBasedAppHostServerProject.cs (20)
176var projectRefGroup = new XElement("ItemGroup");
187projectRefGroup.Add(new XElement("ProjectReference",
189new XElement("IsAspireProjectResource", "false")));
197projectRefGroup.Add(new XElement("ProjectReference",
199new XElement("IsAspireProjectResource", "false")));
216projectRefGroup.Add(new XElement("ProjectReference",
218new XElement("IsAspireProjectResource", "false")));
228doc.Root!.Add(new XElement("ItemGroup",
229otherPackages.Select(p => new XElement("PackageReference",
240doc.Root!.Add(new XElement("Import", new XAttribute("Project", appHostInTargets)));
244doc.Root!.Add(new XElement("Import", new XAttribute("Project", sdkInTargets)));
251doc.Root!.Add(new XElement("ItemGroup",
252new XElement("ProjectReference", new XAttribute("Include", dashboardProject))));
258doc.Root!.Add(new XElement("ItemGroup",
259new XElement("ProjectReference", new XAttribute("Include", remoteHostProject))));
263doc.Root!.Add(new XElement("Target", new XAttribute("Name", "_CSharpWriteHostProjectMetadataSources")));
264doc.Root!.Add(new XElement("Target", new XAttribute("Name", "_CSharpWriteProjectMetadataSources")));
379.Add(new XElement("RestoreAdditionalProjectSources", sourceList));
383doc.Root!.Add(new XElement("ItemGroup",
384new XElement("None",
Projects\PrebuiltAppHostServer.cs (16)
273var propertyGroup = new XElement("PropertyGroup",
274new XElement("TargetFramework", DotNetBasedAppHostServerProject.TargetFramework),
275new XElement("EnableDefaultItems", "false"),
276new XElement("CopyLocalLockFileAssemblies", "true"),
277new XElement("ProduceReferenceAssembly", "false"),
278new XElement("EnableNETAnalyzers", "false"),
279new XElement("GenerateDocumentationFile", "false"),
280new XElement("OutDir", outputDir));
288propertyGroup.Add(new XElement("RestoreAdditionalProjectSources", sourceList));
293new XElement("Project",
299doc.Root!.Add(new XElement("ItemGroup",
306return new XElement("PackageReference",
314doc.Root!.Add(new XElement("ItemGroup",
315projectRefs.Select(p => new XElement("ProjectReference",
322new XElement("Target",
325new XElement("WriteLinesToFile",
Aspire.Hosting.Maui (17)
dotnet-svcutil-lib (13)
Shared\MSBuildProj.cs (12)
84_projectReferenceGroup = new XElement("ItemGroup");
107_referenceGroup = new XElement("ItemGroup");
131_packageReferenceGroup = new XElement("ItemGroup");
450XElement propertyGroup = new XElement(group);
538this.ProjectReferceGroup.Add(new XElement("ProjectReference", new XAttribute("Include", dependency.FullPath)));
541this.ReferenceGroup.Add(new XElement("Reference", new XAttribute("Include", dependency.AssemblyName), new XElement("HintPath", dependency.FullPath)));
544this.PacakgeReferenceGroup.Add(new XElement("PackageReference", new XAttribute("Include", dependency.Name), new XAttribute("Version", dependency.Version)));
547this.ReferenceGroup.Add(new XElement("DotNetCliToolReference", new XAttribute("Include", dependency.Name), new XAttribute("Version", dependency.Version)));
561this.ReferenceGroup.Add(new XElement("Content",
571this.PacakgeReferenceGroup.Add(new XElement("Content",
598XElement element = new XElement(propertyName, null);
dotnet-user-jwts (2)
dotnet-user-secrets (2)
GenerateDocumentationAndConfigFiles (17)
illink (7)
Linker\WarningSuppressionWriter.cs (7)
66var xmlTree = new XElement("linker");
67var xmlAssembly = new XElement("assembly", new XAttribute("fullname", assemblyName.FullName));
73new XElement("attribute",
75new XElement("argument", Constants.ILLink),
76new XElement("argument", $"IL{warning.Code}"),
77new XElement("property", new XAttribute("name", UnconditionalSuppressMessageAttributeState.ScopeProperty),
79new XElement("property", new XAttribute("name", UnconditionalSuppressMessageAttributeState.TargetProperty),
ILLink.Tasks (1)
Microsoft.AspNetCore.DataProtection (46)
KeyManagement\XmlKeyManager.cs (13)
387var revocationElement = new XElement(RevocationElementName,
389new XElement(RevocationDateElementName, revocationDate),
391new XElement(KeyElementName,
393new XElement(ReasonElementName, reason));
524var keyElement = new XElement(KeyElementName,
527new XElement(CreationDateElementName, creationDate),
528new XElement(ActivationDateElementName, activationDate),
529new XElement(ExpirationDateElementName, expirationDate),
530new XElement(DescriptorElementName,
632var revocationElement = new XElement(RevocationElementName,
634new XElement(RevocationDateElementName, revocationDate),
635new XElement(KeyElementName,
637new XElement(ReasonElementName, reason));
Microsoft.AspNetCore.OpenApi.SourceGenerators (2)
Microsoft.AspNetCore.Rewrite (1)
Microsoft.Build.Tasks.Core (14)
Microsoft.CodeAnalysis (1)
Microsoft.CodeAnalysis.Analyzers (17)
Microsoft.CodeAnalysis.AnalyzerUtilities (17)
Microsoft.CodeAnalysis.CodeStyle (17)
Microsoft.CodeAnalysis.ResxSourceGenerator (18)
Microsoft.CodeAnalysis.Workspaces (43)
Log\WorkspaceStructureLogger.cs (24)
40var workspaceElement = new XElement("workspace");
71var workspaceAnalyzerReferencesElement = new XElement("workspaceAnalyzerReferences");
80projectElement.Add(new XElement("workspaceDocuments", await CreateElementsForDocumentCollectionAsync(project.Documents, "document", cancellationToken).ConfigureAwait(false)));
81projectElement.Add(new XElement("workspaceAdditionalDocuments", await CreateElementsForDocumentCollectionAsync(project.AdditionalDocuments, "additionalDocuments", cancellationToken).ConfigureAwait(false)));
82projectElement.Add(new XElement("workspaceAnalyzerConfigDocuments", await CreateElementsForDocumentCollectionAsync(project.AnalyzerConfigDocuments, "analyzerConfigDocument", cancellationToken).ConfigureAwait(false)));
86projectElement.Add(new XElement("workspaceSourceGeneratedDocuments", CreateElementsForSourceGeneratedDocuments(sourceGeneratedDocuments)));
89var generatorDiagnosticsElement = new XElement("generatorDiagnostics");
114var projectElement = new XElement("project");
137var msbuildReferencesElement = new XElement("msbuildReferences");
148var workspaceReferencesElement = new XElement("workspaceReferences");
155var referenceElement = new XElement("projectReference", new XAttribute("id", SanitizePath(projectReference.ProjectId.ToString())));
172var compilationReferencesElement = new XElement("compilationReferences");
180var diagnosticsElement = new XElement("diagnostics");
190=> new("diagnostic",
203var element = new XElement("sourceGeneratedDocument",
246return new XElement("compilationReference",
252return new XElement("peReference",
259return new XElement("metadataReference", new XAttribute("display", SanitizePath(reference.Display)));
264=> new("analyzerReference",
274var typesElement = new XElement("types");
283typesElement.Add(new XElement("type", new XAttribute("name", type.ToDisplayString())));
289return new XElement("compilation",
301var documentElement = new XElement(elementName, new XAttribute("path", SanitizePath(document.FilePath)));
310documentElement.Add(new XElement("loadDiagnostic", loadDiagnostic));
Microsoft.DotNet.Arcade.Sdk (1)
Microsoft.DotNet.Build.Manifest (5)
Microsoft.DotNet.Build.Tasks.Installers (10)
Microsoft.DotNet.HotReload.Watch (2)
Microsoft.DotNet.PackageTesting (9)
Microsoft.DotNet.SharedFramework.Sdk (11)
Microsoft.DotNet.SourceBuild.Tasks (12)
Microsoft.DotNet.XliffTasks (10)
Model\XlfDocument.cs (7)
49new XElement(Xliff,
54new XElement(File,
59new XElement(Body))));
188new(TransUnit,
190new XElement(Source, sourceNode.Source),
191new XElement(Target, new XAttribute("state", "new"), sourceNode.Source),
192new XElement(Note, sourceNode.Note == "" ? null : sourceNode.Note));
Microsoft.Extensions.AI.Evaluation.Safety (3)
Microsoft.Maui.Resizetizer (13)
Microsoft.ML.Maml (16)
HelpCommand.cs (16)
463var content = new XElement("Components",
466select new XElement("Component",
468new XElement("Name", c.Info.UserName),
469string.IsNullOrWhiteSpace(c.Info.Summary) ? null : new XElement("Summary", c.Info.Summary),
470new XElement("LoadNames",
472select new XElement("LoadName", l)),
473new XElement("Type", c.Info.Type.ToString()),
474new XElement("SignatureTypes",
476select new XElement("SignatureType", s.ToString())),
479: new XElement("Arguments",
481select new XElement("Argument",
482new XElement("LongName", a.LongName),
485: new XElement("ShortNames",
487select new XElement("ShortName", sn)),
488new XElement("HelpText", a.HelpText),
509return new XElement("DefaultValue", a.DefaultValue);
Microsoft.NET.Build.Tasks (9)
Microsoft.NET.HostModel (5)
ComHost\RegFreeComManifest.cs (5)
30XElement manifest = new XElement(ns + "assembly", new XAttribute("manifestVersion", "1.0"));
31manifest.Add(new XElement(ns + "assemblyIdentity",
56XElement fileElement = new XElement(ns + "file", new XAttribute("name", comHostName));
67XElement comClassElement = new XElement(ns + "comClass", new XAttribute("clsid", guid.ToString("B")), new XAttribute("threadingModel", "Both"));
90XElement typeLibElement = new XElement(ns + "typelib",
Microsoft.NET.Sdk.BlazorWebAssembly.Tasks (5)
Microsoft.NET.Sdk.Publish.Tasks (4)
Microsoft.NET.Sdk.StaticWebAssets.Tasks (55)
GenerateStaticWebAssetsPropsFile.cs (21)
79var itemGroup = new XElement("ItemGroup");
105itemGroup.Add(new XElement("StaticWebAsset",
107new XElement(SourceType, emittedSourceType),
108new XElement(SourceId, element.GetMetadata(SourceId)),
109new XElement(ContentRoot, @$"$(MSBuildThisFileDirectory)..\{Normalize(PackagePathPrefix)}\"),
110new XElement(BasePath, element.GetMetadata(BasePath)),
111new XElement(RelativePath, relativePath),
112new XElement(AssetKind, element.GetMetadata(AssetKind)),
113new XElement(AssetMode, element.GetMetadata(AssetMode)),
114new XElement(AssetRole, element.GetMetadata(AssetRole)),
115new XElement(RelatedAsset, element.GetMetadata(RelatedAsset)),
116new XElement(AssetTraitName, element.GetMetadata(AssetTraitName)),
117new XElement(AssetTraitValue, element.GetMetadata(AssetTraitValue)),
118new XElement(Fingerprint, element.GetMetadata(Fingerprint)),
119new XElement(Integrity, element.GetMetadata(Integrity)),
120new XElement(CopyToOutputDirectory, element.GetMetadata(CopyToOutputDirectory)),
121new XElement(CopyToPublishDirectory, element.GetMetadata(CopyToPublishDirectory)),
122new XElement(FileLength, element.GetMetadata(FileLength)),
123new XElement(LastWriteTime, element.GetMetadata(LastWriteTime)),
124new XElement(OriginalItemSpec, fullPathExpression)));
128var root = new XElement("Project", itemGroup);
Legacy\GenerateStaticWebAssetsPropsFile50.cs (17)
56var itemGroup = new XElement("ItemGroup");
62itemGroup.Add(new XElement("StaticWebAsset",
64new XElement(SourceType, "Package"),
65new XElement(SourceId, element.GetMetadata(SourceId)),
66new XElement(ContentRoot, @$"$(MSBuildThisFileDirectory)..\{Normalize(PackagePathPrefix)}\"),
67new XElement(BasePath, element.GetMetadata(BasePath)),
68new XElement(RelativePath, element.GetMetadata(RelativePath)),
69new XElement(AssetKind, element.GetMetadata(AssetKind)),
70new XElement(AssetMode, element.GetMetadata(AssetMode)),
71new XElement(AssetRole, element.GetMetadata(AssetRole)),
72new XElement(RelatedAsset, element.GetMetadata(RelatedAsset)),
73new XElement(AssetTraitName, element.GetMetadata(AssetTraitName)),
74new XElement(AssetTraitValue, element.GetMetadata(AssetTraitValue)),
75new XElement(CopyToOutputDirectory, element.GetMetadata(CopyToOutputDirectory)),
76new XElement(CopyToPublishDirectory, element.GetMetadata(CopyToPublishDirectory)),
77new XElement(OriginalItemSpec, fullPathExpression)));
81var root = new XElement("Project", itemGroup);
NuGet.Commands (19)
RestoreCommand\Utility\BuildAssetsUtils.cs (19)
134doc.Root.Add(new XElement(Namespace + "Target",
138new XElement(Namespace + "Warning",
213new XElement(Namespace + "PropertyGroup",
222new XElement(Namespace + "ItemGroup",
235new XElement(Namespace + "Project",
244return new XElement(Namespace + propertyName,
251return new XElement(Namespace + itemName, new XAttribute("Include", path));
256return new XElement(Namespace + "Import",
263var entry = new XElement(Namespace + item.BuildAction.Value,
266new XElement(Namespace + "NuGetPackageId", packageId),
267new XElement(Namespace + "NuGetPackageVersion", packageVersion),
268new XElement(Namespace + "NuGetItemType", item.BuildAction),
269new XElement(Namespace + "Pack", false));
283entry.Add(new XElement(Namespace + "CopyToOutputDirectory", "PreserveNewest"));
285entry.Add(new XElement(Namespace + "TargetPath", outputPath));
291entry.Add(new XElement(Namespace + "DestinationSubDirectory", destinationSubDirectory + Path.DirectorySeparatorChar));
296entry.Add(new XElement(Namespace + "Private", privateFlag.ToString(CultureInfo.CurrentCulture)));
306entry.Add(new XElement(Namespace + "Link", linkPath));
331var itemGroup = new XElement(Namespace + group.RootName, group.Items);
NuGet.Configuration (10)
NuGet.PackageManagement (3)
NuGet.Packaging (42)
PackageCreation\Authoring\PackageBuilder.cs (15)
1192new XElement(relationships + "Relationships",
1193new XElement(relationships + "Relationship",
1197new XElement(relationships + "Relationship",
1217XElement element = new XElement(content + "Types",
1218new XElement(content + "Default",
1221new XElement(content + "Default",
1228new XElement(content + "Default",
1237new XElement(content + "Override",
1265new XElement(core + "coreProperties",
1269new XElement(dc + "creator", string.Join(", ", Authors)),
1270new XElement(dc + "description", Description),
1271new XElement(dc + "identifier", Id),
1272new XElement(core + "version", Version!.ToString()),
1274new XElement(core + "keywords", ((IPackageMetadata)this).Tags),
1276new XElement(core + "lastModifiedBy", CreatorInfo())
PackageCreation\Xml\PackageMetadataXmlExtensions.cs (21)
34var elem = new XElement(ns + "metadata");
40elem.Add(new XElement(ns + "id", metadata.Id));
50elem.Add(new XElement(ns + "developmentDependency", metadata.DevelopmentDependency));
56elem.Add(new XElement(ns + "requireLicenseAcceptance", metadata.RequireLicenseAcceptance));
85elem.Add(new XElement(ns + "serviceable", metadata.Serviceable));
180var groupElem = new XElement(
197return new XElement(ns + parentName, childElements.ToArray());
202return new XElement(ns + NuspecUtility.FrameworkReference, new XAttribute(NuspecUtility.Name, frameworkReference.Name));
207return new XElement(ns + Reference, new XAttribute(File, reference));
231return new XElement(ns + "dependency", attributes);
241return new XElement(
244new XElement(ns + FrameworkAssembly,
258return new XElement(ns + "contentFiles",
273return new XElement(ns + Files, attributes.Where(xAtt => xAtt != null));
286return new XElement(ns + NuspecUtility.License, metadata.License, attributes.Where(xAtt => xAtt != null));
314return new XElement(ns + NuspecUtility.Repository, attributeList);
321var packageTypesElement = new XElement(ns + NuspecUtility.PackageTypes);
342return new XElement(ns + NuspecUtility.PackageType, attributes.Where(xAtt => xAtt != null));
360parent.Add(new XElement(ns + name, value));
372parent.Add(new XElement(ns + name, processed));
384parent.Add(new XElement(ns + name, processed));
PresentationFramework-SystemXmlLinq (1)
Roslyn.Diagnostics.Analyzers (17)
Stress.ApiService (2)
System.Private.DataContractSerialization (1)
System.Private.Xml.Linq (14)
2033 references to XElement
aspire (69)
Aspire.Cli.EndToEnd.Tests (1)
Aspire.Cli.Tests (28)
Aspire.Dashboard (2)
Aspire.Hosting.Maui (5)
Aspire.Hosting.RemoteHost (2)
Aspire.Hosting.Tasks (4)
ConfigurationSchemaGenerator (6)
ConfigurationSchemaGenerator.Tests (8)
dotnet (2)
dotnet-svcutil-lib (47)
Shared\MSBuildProj.cs (45)
71private XElement ProjectNode { get; set; }
73private XElement _projectReferenceGroup;
74private XElement ProjectReferceGroup
80IEnumerable<XElement> refItems = this.ProjectNode.Elements("ProjectReference");
96private XElement _referenceGroup;
97private XElement ReferenceGroup
103IEnumerable<XElement> refItems = this.ProjectNode.Elements("Reference");
120private XElement _packageReferenceGroup;
121private XElement PacakgeReferenceGroup
127IEnumerable<XElement> refItems = this.ProjectNode.Elements("PackageReference");
189IEnumerable<XElement> targetFrameworkElements = GetSubGroupValues(msbuildProj.ProjectNode, msbuildNS, "PropertyGroup", "TargetFramework");
211IEnumerable<XElement> targetFrameworksElements = GetSubGroupValues(msbuildProj.ProjectNode, msbuildNS, "PropertyGroup", "TargetFrameworks");
245IEnumerable<XElement> runtimeIdentifierElements = GetSubGroupValues(msbuildProj.ProjectNode, msbuildNS, "PropertyGroup", "RuntimeIdentifier");
251IEnumerable<XElement> packageReferenceElements = GetSubGroupValues(msbuildProj.ProjectNode, msbuildNS, "ItemGroup", "PackageReference");
252foreach (XElement reference in packageReferenceElements)
268IEnumerable<XElement> toolReferenceElements = GetSubGroupValues(msbuildProj.ProjectNode, msbuildNS, "ItemGroup", "DotNetCliToolReference");
269foreach (XElement reference in toolReferenceElements)
281IEnumerable<XElement> projectReferenceElements = GetSubGroupValues(msbuildProj.ProjectNode, msbuildNS, "ItemGroup", "ProjectReference");
282foreach (XElement reference in projectReferenceElements)
291IEnumerable<XElement> binReferenceElements = GetSubGroupValues(msbuildProj.ProjectNode, msbuildNS, "ItemGroup", "Reference");
292foreach (XElement reference in binReferenceElements)
302XElement hintPath = reference.Element("HintPath");
303XElement path = reference.Element("Path");
429var ele = doc.Root?.Descendants(elementStr).FirstOrDefault();
442private static IEnumerable<XElement> GetGroupValues(XElement projectElement, string group, bool createOnMissing = false)
445IEnumerable<XElement> groups = projectElement.Elements(group);
450XElement propertyGroup = new XElement(group);
452return new XElement[] { propertyGroup };
459private static IEnumerable<XElement> GetSubGroupValues(XElement projectElement, XNamespace msbuildNS, string group, string subGroupName)
461IEnumerable<XElement> groups = GetGroupValues(projectElement, group);
462IEnumerable<XElement> subGroupValues = groups.Elements(msbuildNS + subGroupName);
466private static string GetItemValue(XElement reference, string itemName, bool throwIfMissing = false)
475XElement itemNameElement = null;
489public static bool TryGetItemIdentity(XElement itemName, out string itemIdentity)
503private static string GetItemIdentity(XElement itemName)
598XElement element = new XElement(propertyName, null);
600IEnumerable<XElement> existingElements = GetSubGroupValues(this.ProjectNode, _msbuildNS, "PropertyGroup", propertyName);
607IEnumerable<XElement> propertyGroupItems = GetGroupValues(this.ProjectNode, "PropertyGroup", createOnMissing: true);
608XElement propertyGroup = propertyGroupItems.First();
662IEnumerable<XElement> targetFrameworkElements = GetSubGroupValues(this.ProjectNode, _msbuildNS, "PropertyGroup", "TargetFramework");
665var targetFrameworkNode = targetFrameworkElements.Last();
670IEnumerable<XElement> targetFrameworksElements = GetSubGroupValues(this.ProjectNode, _msbuildNS, "PropertyGroup", "TargetFrameworks");
673var targetFrameworksNode = targetFrameworksElements.Last();
dotnet-user-jwts (4)
dotnet-user-secrets (4)
GenerateDocumentationAndConfigFiles (45)
ilc (10)
illink (2)
ILLink.Tasks (2)
Microsoft.Arcade.Common (3)
Microsoft.AspNetCore.DataProtection (168)
_generated\0\LoggerMessage.g.cs (9)
329private static readonly global::System.Action<global::Microsoft.Extensions.Logging.ILogger, global::System.Xml.Linq.XElement, global::System.Exception?> __ExceptionWhileProcessingRevocationElementCallback =
330global::Microsoft.Extensions.Logging.LoggerMessage.Define<global::System.Xml.Linq.XElement>(global::Microsoft.Extensions.Logging.LogLevel.Error, new global::Microsoft.Extensions.Logging.EventId(21, "ExceptionWhileProcessingRevocationElement"), "An exception occurred while processing the revocation element '{RevocationElement}'. Cannot continue keyring processing.", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true });
337public static partial void ExceptionWhileProcessingRevocationElement(this global::Microsoft.Extensions.Logging.ILogger logger, global::System.Xml.Linq.XElement revocationElement, global::System.Exception exception)
377private static readonly global::System.Action<global::Microsoft.Extensions.Logging.ILogger, global::System.Xml.Linq.XElement, global::System.Exception?> __ExceptionWhileProcessingKeyElementCallback =
378global::Microsoft.Extensions.Logging.LoggerMessage.Define<global::System.Xml.Linq.XElement>(global::Microsoft.Extensions.Logging.LogLevel.Error, new global::Microsoft.Extensions.Logging.EventId(24, "ExceptionOccurredWhileProcessingTheKeyElement"), "An exception occurred while processing the key element '{Element}'.", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true });
385public static partial void ExceptionWhileProcessingKeyElement(this global::Microsoft.Extensions.Logging.ILogger logger, global::System.Xml.Linq.XElement element, global::System.Exception exception)
393private static readonly global::System.Action<global::Microsoft.Extensions.Logging.ILogger, global::System.Xml.Linq.XElement, global::System.Exception?> __AnExceptionOccurredWhileProcessingElementDebugCallback =
394global::Microsoft.Extensions.Logging.LoggerMessage.Define<global::System.Xml.Linq.XElement>(global::Microsoft.Extensions.Logging.LogLevel.Trace, new global::Microsoft.Extensions.Logging.EventId(25, "ExceptionOccurredWhileProcessingTheKeyElementDebug"), "An exception occurred while processing the key element '{Element}'.", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true });
401public static partial void AnExceptionOccurredWhileProcessingElementDebug(this global::Microsoft.Extensions.Logging.ILogger logger, global::System.Xml.Linq.XElement element, global::System.Exception exception)
Microsoft.AspNetCore.OpenApi.SourceGenerators (24)
Microsoft.AspNetCore.Rewrite (20)
IISUrlRewrite\UrlRewriteFileParser.cs (13)
24var xmlRoot = xmlDoc.Descendants(RewriteTags.Rewrite).FirstOrDefault();
39private void ParseRules(XElement? rules, IList<IISUrlRewriteRule> result, bool global)
46foreach (var rule in rules.Elements(RewriteTags.Rule))
58private void ParseRuleAttributes(XElement rule, UrlRewriteRuleBuilder builder)
74var match = rule.Element(RewriteTags.Match);
80var action = rule.Element(RewriteTags.Action);
91private static void ParseMatch(XElement match, UrlRewriteRuleBuilder builder, PatternSyntax patternSyntax)
104private void ParseConditions(XElement? conditions, UrlRewriteRuleBuilder builder, PatternSyntax patternSyntax)
121foreach (var cond in adds)
127private void ParseCondition(XElement conditionElement, UrlRewriteRuleBuilder builder, PatternSyntax patternSyntax)
188private void ParseUrlAction(XElement urlAction, UrlRewriteRuleBuilder builder, bool stopProcessing)
253private static bool ParseBool(XElement element, string rewriteTag, bool defaultValue)
268private static TEnum ParseEnum<TEnum>(XElement element, string rewriteTag, TEnum defaultValue)
Microsoft.Build.Tasks.Core (23)
Microsoft.CodeAnalysis (17)
Microsoft.CodeAnalysis.Analyzers (46)
Microsoft.CodeAnalysis.AnalyzerUtilities (45)
Microsoft.CodeAnalysis.CodeStyle (38)
Microsoft.CodeAnalysis.CodeStyle.Fixes (1)
Microsoft.CodeAnalysis.CSharp (8)
Microsoft.CodeAnalysis.CSharp.CodeStyle (2)
Microsoft.CodeAnalysis.CSharp.Workspaces (2)
Microsoft.CodeAnalysis.Features (8)
Microsoft.CodeAnalysis.ResxSourceGenerator (46)
Microsoft.CodeAnalysis.VisualBasic (6)
Compilation\DocumentationComments\DocumentationCommentCompiler.Includes.vb (6)
273Dim element = DirectCast(node, XElement)
304Dim element = DirectCast(container, XElement)
431Private Shared Function ElementNameIs(element As XElement, name As String) As Boolean
441Private Function RewriteIncludeElement(includeElement As XElement, currentXmlFilePath As String, originatingSyntax As XmlNodeSyntax, <Out> ByRef commentMessage As String) As XNode()
511Dim loadedElements As XElement() = XmlUtilities.TrySelectElements(doc, xpathValue, errorMessage, invalidXPath)
579Private Function GetIncludeElementLocation(includeElement As XElement, ByRef currentXmlFilePath As String, ByRef originatingSyntax As XmlNodeSyntax) As Location
Microsoft.CodeAnalysis.Workspaces (83)
Log\WorkspaceStructureLogger.cs (28)
40var workspaceElement = new XElement("workspace");
54var projectElement = await BuildProjectElementAsync(project, cancellationToken).ConfigureAwait(false);
57var msbuildReferencesElement = CreateMsBuildReferencesElement(project);
71var workspaceAnalyzerReferencesElement = new XElement("workspaceAnalyzerReferences");
89var generatorDiagnosticsElement = new XElement("generatorDiagnostics");
109protected virtual Task<IEnumerable<XElement>> CreateAdditionalProjectElementsAsync(Project project, CancellationToken cancellationToken)
110=> Task.FromResult<IEnumerable<XElement>>([]);
112private static async Task<XElement> BuildProjectElementAsync(Project project, CancellationToken cancellationToken)
114var projectElement = new XElement("project");
129private static XElement? CreateMsBuildReferencesElement(Project project)
137var msbuildReferencesElement = new XElement("msbuildReferences");
146private XElement BuildWorkspaceReferencesElement(Project project)
148var workspaceReferencesElement = new XElement("workspaceReferences");
155var referenceElement = new XElement("projectReference", new XAttribute("id", SanitizePath(projectReference.ProjectId.ToString())));
166private async Task AddCompilationElementsAsync(XElement projectElement, Project project, CancellationToken cancellationToken)
172var compilationReferencesElement = new XElement("compilationReferences");
180var diagnosticsElement = new XElement("diagnostics");
189private static XElement CreateElementForDiagnostic(Diagnostic diagnostic)
196private static IEnumerable<XElement> CreateElementsForSourceGeneratedDocuments(IEnumerable<SourceGeneratedDocument> documents)
198var elements = new List<XElement>();
203var element = new XElement("sourceGeneratedDocument",
240internal XElement CreateElementForPortableExecutableReference(MetadataReference reference)
263private static XElement CreateElementForAnalyzerReference(Microsoft.CodeAnalysis.Diagnostics.AnalyzerReference reference)
268private XElement CreateElementForCompilation(Compilation compilation)
274var typesElement = new XElement("types");
295internal static async Task<IEnumerable<XElement>> CreateElementsForDocumentCollectionAsync(IEnumerable<TextDocument> documents, string elementName, CancellationToken cancellationToken)
297var elements = new List<XElement>();
301var documentElement = new XElement(elementName, new XAttribute("path", SanitizePath(document.FilePath)));
Microsoft.DotNet.Arcade.Sdk (3)
Microsoft.DotNet.Build.Manifest (17)
Microsoft.DotNet.Build.Tasks.Installers (11)
Microsoft.DotNet.Build.Tasks.Packaging (2)
Microsoft.DotNet.Build.Tasks.VisualStudio (1)
Microsoft.DotNet.HotReload.Watch (1)
Microsoft.DotNet.MacOsPkg.Core (7)
Microsoft.DotNet.NuGetRepack.Tasks (10)
Microsoft.DotNet.PackageTesting (4)
Microsoft.DotNet.SharedFramework.Sdk (6)
Microsoft.DotNet.SourceBuild.Tasks (17)
Microsoft.DotNet.XliffTasks (61)
Microsoft.Extensions.AI.Abstractions.Tests (1)
Microsoft.Extensions.AI.Evaluation.Safety (2)
Microsoft.Extensions.FileProviders.Embedded (11)
Microsoft.Maui.Resizetizer (22)
Microsoft.ML.Maml (2)
Microsoft.NET.Build.Tasks (20)
Microsoft.NET.HostModel (7)
ComHost\RegFreeComManifest.cs (7)
30XElement manifest = new XElement(ns + "assembly", new XAttribute("manifestVersion", "1.0"));
36var fileElement = CreateComHostFileElement(clsidMapPath, comHostName, ns);
54private static XElement CreateComHostFileElement(string clsidMapPath, string comHostName, XNamespace ns)
56XElement fileElement = new XElement(ns + "file", new XAttribute("name", comHostName));
67XElement comClassElement = new XElement(ns + "comClass", new XAttribute("clsid", guid.ToString("B")), new XAttribute("threadingModel", "Both"));
78private static void AddTypeLibElementsToFileElement(IReadOnlyDictionary<int, string> typeLibraries, XNamespace ns, XElement fileElement)
90XElement typeLibElement = new XElement(ns + "typelib",
Microsoft.NET.Sdk.BlazorWebAssembly.Tasks (2)
Microsoft.NET.Sdk.Publish.Tasks (18)
WebConfigTransform.cs (17)
21XElement? rootElement = null;
24var firstAspNetCoreElement = webConfig.Root?.Descendants(aspNetCoreElementName).FirstOrDefault();
34var webServerSection = GetOrCreateChild(rootElement, "system.webServer");
36var handlerSection = GetOrCreateChild(webServerSection, HandlersElementName);
45var aspNetCoreSection = GetOrCreateChild(webServerSection, aspNetCoreElementName);
53var aspNetCoreElement = webServerSection?.Element(HandlersElementName)?
64private static void TransformHandlers(XElement handlersElement, string? aspNetCoreModuleName)
66var aspNetCoreElement =
89private static void TransformAspNetCore(XElement aspNetCoreElement, string appName, bool configureForAzure, bool useAppHost, string? extension, string? aspNetCoreModuleName, string? aspNetCoreHostingModelValue, string? projectFullPath)
171private static void SetAspNetCoreHostingModel(string? aspNetCoreHostingModelValue, string? aspNetCoreModuleName, XElement aspNetCoreElement)
194private static void TransformEnvironmentVariables(XElement envVariablesElement, string? environmentName)
196var envVariableElement =
210private static XElement GetOrCreateChild(XElement? parent, string childName)
212var childElement = parent?.Element(childName);
221private static void SetAttributeValueIfEmpty(XElement element, string attributeName, string? value)
226private static void RemoveLauncherArgs(XElement aspNetCoreElement)
Microsoft.NET.Sdk.StaticWebAssets.Tasks (13)
Microsoft.TestPlatform.CrossPlatEngine (1)
Microsoft.VisualStudio.TestPlatform.Common (3)
netstandard (1)
NuGet.Commands (12)
NuGet.Configuration (65)
NuGet.PackageManagement (53)
FileModifiers\XmlTransformer.cs (12)
23private readonly IDictionary<XName, Action<XElement, XElement>> _nodeActions;
31public XmlTransformer(IDictionary<XName, Action<XElement, XElement>> nodeActions)
74var xmlFragment = await GetXmlAsync(streamTaskFactory, projectSystem, cancellationToken);
119var xmlFragment = await GetXmlAsync(streamTaskFactory, projectSystem, cancellationToken);
127var elements = new List<XElement>();
134var mergedFragments = elements.Aggregate(
151private static async Task<XElement> GetXmlAsync(
173return XElement.Parse(content, LoadOptions.PreserveWhitespace);
176private static async Task<XElement> GetXmlAsync(
183return XElement.Parse(content, LoadOptions.PreserveWhitespace);
Utility\XElementExtensions.cs (37)
18public static string GetOptionalAttributeValue(this XElement element, string localName, string namespaceName = null)
34XElement child;
46public static IEnumerable<XElement> ElementsNoNamespace(this XContainer container, string localName)
51public static IEnumerable<XElement> ElementsNoNamespace(this IEnumerable<XContainer> source, string localName)
57public static XElement Except(this XElement source, XElement target)
86var sourceChild = sourceChildNode as XElement;
89var targetChild = FindElement(target, sourceChild);
107public static XElement MergeWith(this XElement source, XElement target)
113public static XElement MergeWith(this XElement source, XElement target, IDictionary<XName, Action<XElement, XElement>> nodeActions)
143var targetChild = targetChildNode as XElement;
146var sourceChild = FindElement(source, targetChild);
161Action<XElement, XElement> nodeAction;
172var newlyAddedElement = source.Elements().Last();
187private static XElement FindElement(XElement source, XElement targetChild)
198private static bool HasComment(XElement element, XComment comment)
204private static int Compare(XElement target, XElement left, XElement right)
224private static int CountMatches(XElement left, XElement right, Func<XAttribute, XAttribute, bool> matcher)
232private static bool HasConflict(XElement source, XElement target)
250public static void RemoveAttributes(this XElement element, Func<XAttribute, bool> condition)
298foreach (var element in container.Elements())
NuGet.Packaging (128)
NuspecReader.cs (13)
130foreach (var depGroup in dependencyGroups)
172foreach (var group in MetadataNode.Elements(XName.Get(References, ns)).Elements(XName.Get(Group, ns)))
273var node = MetadataNode.Elements(XName.Get(Language, MetadataNode.GetDefaultNamespace().NamespaceName)).FirstOrDefault();
282var node = MetadataNode.Elements(XName.Get(LicenseUrl, MetadataNode.GetDefaultNamespace().NamespaceName)).FirstOrDefault();
293foreach (var filesNode in MetadataNode
414var node = MetadataNode.Elements(XName.Get(Repository, MetadataNode.GetDefaultNamespace().NamespaceName)).FirstOrDefault();
436var licenseNode = MetadataNode.Elements(XName.Get(NuspecUtility.License, MetadataNode.GetDefaultNamespace().NamespaceName)).FirstOrDefault();
582var node = MetadataNode.Elements(XName.Get(Icon, MetadataNode.GetDefaultNamespace().NamespaceName)).FirstOrDefault();
592var node = MetadataNode.Elements(XName.Get(Readme, MetadataNode.GetDefaultNamespace().NamespaceName)).FirstOrDefault();
596private bool? AttributeAsNullableBool(XElement element, string attributeName)
627private static string? GetAttributeValue(XElement element, string attributeName)
663private HashSet<PackageDependency> GetPackageDependencies(IEnumerable<XElement> nodes, bool useStrictVersionCheck)
667foreach (var depNode in nodes)
PackageCreation\Extensions\XElementExtensions.cs (19)
14public static string? GetOptionalAttributeValue(this XElement element, string localName, string? namespaceName = null)
28public static IEnumerable<XElement> ElementsNoNamespace(this XContainer container, string localName)
33public static XElement Except(this XElement source, XElement? target)
62var sourceChild = sourceChildNode as XElement;
65var targetChild = FindElement(target, sourceChild);
83private static XElement? FindElement(XElement source, XElement targetChild)
94private static int Compare(XElement target, XElement left, XElement right)
112private static int CountMatches(XElement left, XElement right, Func<XAttribute, XAttribute, bool> matcher)
120private static bool HasComment(XElement element, XComment comment)
126private static bool HasConflict(XElement source, XElement target)
PackageCreation\Xml\PackageMetadataXmlExtensions.cs (24)
27public static XElement ToXElement(this ManifestMetadata metadata, XNamespace ns)
32public static XElement ToXElement(this ManifestMetadata metadata, XNamespace ns, bool generateBackwardsCompatible = true)
34var elem = new XElement(ns + "metadata");
61var licenseElement = GetXElementFromLicenseMetadata(ns, metadata.LicenseMetadata);
95var repoElement = GetXElementFromManifestRepository(ns, metadata.Repository);
139private static XElement? GetXElementFromGroupableItemSets<TSet, TItem>(
145Func<XNamespace, TItem, XElement> getXElementFromItem,
169var childElements = new List<XElement>();
180var groupElem = new XElement(
200private static XElement GetXElementFromFrameworkReference(XNamespace ns, FrameworkReference frameworkReference)
205private static XElement GetXElementFromPackageReference(XNamespace ns, string reference)
210private static XElement GetXElementFromPackageDependency(XNamespace ns, PackageDependency dependency)
234private static XElement? GetXElementFromFrameworkAssemblies(XNamespace ns, IEnumerable<FrameworkAssemblyReference> references)
251private static XElement? GetXElementFromManifestContentFiles(XNamespace ns, IEnumerable<ManifestContentFiles> contentFiles)
262private static XElement GetXElementFromManifestContentFile(XNamespace ns, ManifestContentFiles file)
276private static XElement GetXElementFromLicenseMetadata(XNamespace ns, LicenseMetadata metadata)
289private static XElement? GetXElementFromManifestRepository(XNamespace ns, RepositoryMetadata repository)
319private static XElement GetXElementFromManifestPackageTypes(XNamespace ns, IEnumerable<PackageType> packageTypes)
321var packageTypesElement = new XElement(ns + NuspecUtility.PackageTypes);
325var packageTypeElement = GetXElementFromManifestPackageType(ns, packageType);
332private static XElement GetXElementFromManifestPackageType(XNamespace ns, PackageType packageType)
355private static void AddElementIfNotNull<T>(XElement parent, XNamespace ns, string name, T? value)
364private static void AddElementIfNotNull<T>(XElement parent, XNamespace ns, string name, T? value, Func<T, object> process)
377private static void AddElementIfNotEmpty<T>(XElement parent, XNamespace ns, string name, IEnumerable<T> value, Func<IEnumerable<T>, object> process)
NuGet.Protocol (13)
PresentationFramework-SystemXmlLinq (3)
Roslyn.Diagnostics.Analyzers (45)
Roslyn.Diagnostics.CSharp.Analyzers (2)
sdk-tasks (3)
Shared.Tests (1)
System.ComponentModel.TypeConverter (52)
MS\Internal\Xml\Linq\ComponentModel\XComponentModel.cs (52)
44if (typeof(T) == typeof(XElement))
144internal sealed class XElementAttributePropertyDescriptor : XPropertyDescriptor<XElement, object>
155return _value = new XDeferredSingleton<XAttribute>((e, n) => e.Attribute(n), (component as XElement)!, null);
196internal sealed class XElementDescendantsPropertyDescriptor : XPropertyDescriptor<XElement, IEnumerable<XElement>>
198private XDeferredAxis<XElement>? _value;
207return _value = new XDeferredAxis<XElement>((e, n) => n != null ? e.Descendants(n) : e.Descendants(), (component as XElement)!, null);
218XElement? e = sender as XElement;
225e = sender as XElement;
242XElement? e = sender as XElement;
249internal sealed class XElementElementPropertyDescriptor : XPropertyDescriptor<XElement, object>
251private XDeferredSingleton<XElement>? _value;
252private XElement? _changeState;
260return _value = new XDeferredSingleton<XElement>((e, n) => e.Element(n), (component as XElement)!, null);
270XElement? e = sender as XElement;
277e = sender as XElement;
285e = sender as XElement;
310XElement? e = sender as XElement;
317internal sealed class XElementElementsPropertyDescriptor : XPropertyDescriptor<XElement, IEnumerable<XElement>>
319private XDeferredAxis<XElement>? _value;
328return _value = new XDeferredAxis<XElement>((e, n) => n != null ? e.Elements(n) : e.Elements(), (component as XElement)!, null);
338XElement? e = sender as XElement;
345e = sender as XElement;
353e = sender as XElement;
370XElement? e = sender as XElement;
374e = sender as XElement;
381internal sealed class XElementValuePropertyDescriptor : XPropertyDescriptor<XElement, string>
383private XElement? _element;
396_element = component as XElement;
404_element = component as XElement;
418if (sender is XElement || sender is XText)
433internal sealed class XElementXmlPropertyDescriptor : XPropertyDescriptor<XElement, string>
435private XElement? _element;
443_element = component as XElement;
499private readonly Func<XElement, XName?, IEnumerable<T>> _func;
500internal XElement element;
503public XDeferredAxis(Func<XElement, XName?, IEnumerable<T>> func, XElement element, XName? name)
543private readonly Func<XElement, XName, T?> _func;
544internal XElement element;
547public XDeferredSingleton(Func<XElement, XName, T?> func, XElement element, XName? name)
System.Private.CoreLib.Generators (19)
NativeRuntimeEventSourceGenerator.cs (19)
46XElement? providerNode = manifest
132private static string GenerateEventSourceClass(XElement providerNode, string className, Dictionary<string, HashSet<string>> inclusionList)
159private static void GenerateKeywordsClass(XElement providerNode, StringWriter writer, Dictionary<string, HashSet<string>> inclusionList)
168XElement eventsNode = providerNode.Element(EventNs + "events");
174IEnumerable<XElement> eventNodes = eventsNode.Elements(EventNs + "event");
176foreach (XElement? eventNode in eventNodes)
195XElement? keywordsNode = providerNode.Element(EventNs + "keywords");
206foreach (XElement keywordNode in keywordsNode.Elements(EventNs + "keyword"))
222private static void GenerateEventMethods(XElement providerNode, StringWriter writer, Dictionary<string, HashSet<string>> inclusionList)
231XElement eventsNode = providerNode.Element(EventNs + "events");
238XElement templatesNode = providerNode.Element(EventNs + "templates");
239var templateDict = new Dictionary<string, XElement>();
242foreach (XElement? template in templatesNode.Elements(EventNs + "template"))
254foreach (XElement? eventNode in eventNodes)
274foreach (XElement? eventNode in eventNodes)
319&& templateDict.TryGetValue(templateValue, out XElement? template))
321IEnumerable<XElement> dataNodes = template.Elements(EventNs + "data").ToArray();
328foreach (XElement data in dataNodes)
345foreach (XElement data in dataNodes)
System.Private.DataContractSerialization (1)
System.Private.Xml.Linq (610)
System\Xml\Linq\Extensions.cs (126)
16/// Returns all of the <see cref="XAttribute"/>s for each <see cref="XElement"/> of
17/// this <see cref="IEnumerable"/> of <see cref="XElement"/>.
21/// Attributes for every <see cref="XElement"/> in the target <see cref="IEnumerable"/>
22/// of <see cref="XElement"/>.
24public static IEnumerable<XAttribute> Attributes(this IEnumerable<XElement?> source)
33/// <see cref="XElement"/>'s <see cref="XAttribute"/>s in the target <see cref="IEnumerable"/>
34/// of <see cref="XElement"/> are scanned for a matching <see cref="XName"/>.
38/// Attributes with a matching <see cref="XName"/> for every <see cref="XElement"/> in
39/// the target <see cref="IEnumerable"/> of <see cref="XElement"/>.
41public static IEnumerable<XAttribute> Attributes(this IEnumerable<XElement?> source, XName? name)
49/// Returns an <see cref="IEnumerable"/> of <see cref="XElement"/> containing the ancestors (parent
50/// and it's parent up to the root) of each of the <see cref="XElement"/>s in this
51/// <see cref="IEnumerable"/> of <see cref="XElement"/>.
54/// An <see cref="IEnumerable"/> of <see cref="XElement"/> containing the ancestors (parent
55/// and it's parent up to the root) of each of the <see cref="XElement"/>s in this
56/// <see cref="IEnumerable"/> of <see cref="XElement"/>.
58public static IEnumerable<XElement> Ancestors<T>(this IEnumerable<T?> source) where T : XNode
66/// Returns an <see cref="IEnumerable"/> of <see cref="XElement"/> containing the ancestors (parent
68/// <see cref="XElement"/> in this <see cref="IEnumerable"/> of <see cref="XElement"/>.
71/// An <see cref="IEnumerable"/> of <see cref="XElement"/> containing the ancestors (parent
73/// <see cref="XElement"/> in this <see cref="IEnumerable"/> of <see cref="XElement"/>.
75public static IEnumerable<XElement> Ancestors<T>(this IEnumerable<T?> source, XName? name) where T : XNode
79return name != null ? GetAncestors(source, name, false) : XElement.EmptySequence;
83/// Returns an <see cref="IEnumerable"/> of <see cref="XElement"/> containing the
84/// <see cref="XElement"/> and it's ancestors (parent and it's parent up to the root).
85/// This is done for each <see cref="XElement"/> in this <see cref="IEnumerable"/> of
86/// <see cref="XElement"/>.
89/// An <see cref="IEnumerable"/> of <see cref="XElement"/> containing the
90/// <see cref="XElement"/> and it's ancestors (parent and it's parent up to the root).
91/// This is done for each <see cref="XElement"/> in this <see cref="IEnumerable"/> of
92/// <see cref="XElement"/>.
94public static IEnumerable<XElement> AncestorsAndSelf(this IEnumerable<XElement?> source)
102/// Returns an <see cref="IEnumerable"/> of <see cref="XElement"/> containing the
103/// <see cref="XElement"/> and it's ancestors (parent and it's parent up to the root)
105/// <see cref="XElement"/> in this <see cref="IEnumerable"/> of <see cref="XElement"/>.
108/// An <see cref="IEnumerable"/> of <see cref="XElement"/> containing the
109/// <see cref="XElement"/> and it's ancestors (parent and it's parent up to the root)
111/// <see cref="XElement"/> in this <see cref="IEnumerable"/> of <see cref="XElement"/>.
113public static IEnumerable<XElement> AncestorsAndSelf(this IEnumerable<XElement?> source, XName? name)
117return name != null ? GetAncestors(source, name, true) : XElement.EmptySequence;
160/// Returns an <see cref="IEnumerable"/> of <see cref="XElement"/> containing the descendants (children
161/// and their children down to the leaf level). This is done for each <see cref="XElement"/> in
162/// this <see cref="IEnumerable"/> of <see cref="XElement"/>.
165/// An <see cref="IEnumerable"/> of <see cref="XElement"/> containing the descendants (children
166/// and their children down to the leaf level). This is done for each <see cref="XElement"/> in
167/// this <see cref="IEnumerable"/> of <see cref="XElement"/>.
169public static IEnumerable<XElement> Descendants<T>(this IEnumerable<T?> source) where T : XContainer
177/// Returns an <see cref="IEnumerable"/> of <see cref="XElement"/> containing the descendants (children
179/// for each <see cref="XElement"/> in the target <see cref="IEnumerable"/> of <see cref="XElement"/>.
182/// An <see cref="IEnumerable"/> of <see cref="XElement"/> containing the descendants (children
184/// for each <see cref="XElement"/> in this <see cref="IEnumerable"/> of <see cref="XElement"/>.
186public static IEnumerable<XElement> Descendants<T>(this IEnumerable<T?> source, XName? name) where T : XContainer
190return name != null ? GetDescendants(source, name, false) : XElement.EmptySequence;
194/// Returns an <see cref="IEnumerable"/> of <see cref="XElement"/> containing the
195/// <see cref="XElement"/> and it's descendants
197/// <see cref="XElement"/> in this <see cref="IEnumerable"/> of <see cref="XElement"/>.
200/// An <see cref="IEnumerable"/> of <see cref="XElement"/> containing the
201/// <see cref="XElement"/> and descendants.
203/// <see cref="XElement"/> in this <see cref="IEnumerable"/> of <see cref="XElement"/>.
205public static IEnumerable<XNode> DescendantNodesAndSelf(this IEnumerable<XElement?> source)
213/// Returns an <see cref="IEnumerable"/> of <see cref="XElement"/> containing the
214/// <see cref="XElement"/> and it's descendants (children and children's children down
215/// to the leaf nodes). This is done for each <see cref="XElement"/> in this <see cref="IEnumerable"/>
216/// of <see cref="XElement"/>.
219/// An <see cref="IEnumerable"/> of <see cref="XElement"/> containing the
220/// <see cref="XElement"/> and it's descendants (children and children's children down
221/// to the leaf nodes). This is done for each <see cref="XElement"/> in this <see cref="IEnumerable"/>
222/// of <see cref="XElement"/>.
224public static IEnumerable<XElement> DescendantsAndSelf(this IEnumerable<XElement?> source)
232/// Returns an <see cref="IEnumerable"/> of <see cref="XElement"/> containing the
233/// <see cref="XElement"/> and it's descendants (children and children's children down
235/// each <see cref="XElement"/> in this <see cref="IEnumerable"/> of <see cref="XElement"/>.
238/// An <see cref="IEnumerable"/> of <see cref="XElement"/> containing the
239/// <see cref="XElement"/> and it's descendants (children and children's children down
241/// each <see cref="XElement"/> in this <see cref="IEnumerable"/> of <see cref="XElement"/>.
243public static IEnumerable<XElement> DescendantsAndSelf(this IEnumerable<XElement?> source, XName? name)
247return name != null ? GetDescendants(source, name, true) : XElement.EmptySequence;
251/// Returns an <see cref="IEnumerable"/> of <see cref="XElement"/> containing the child elements
252/// for each <see cref="XElement"/> in this <see cref="IEnumerable"/> of <see cref="XElement"/>.
255/// An <see cref="IEnumerable"/> of <see cref="XElement"/> containing the child elements
256/// for each <see cref="XElement"/> in this <see cref="IEnumerable"/> of <see cref="XElement"/>.
258public static IEnumerable<XElement> Elements<T>(this IEnumerable<T?> source) where T : XContainer
266/// Returns an <see cref="IEnumerable"/> of <see cref="XElement"/> containing the child elements
267/// with a matching for each <see cref="XElement"/> in this <see cref="IEnumerable"/> of <see cref="XElement"/>.
270/// An <see cref="IEnumerable"/> of <see cref="XElement"/> containing the child elements
271/// for each <see cref="XElement"/> in this <see cref="IEnumerable"/> of <see cref="XElement"/>.
273public static IEnumerable<XElement> Elements<T>(this IEnumerable<T?> source, XName? name) where T : XContainer
277return name != null ? GetElements(source, name) : XElement.EmptySequence;
281/// Returns an <see cref="IEnumerable"/> of <see cref="XElement"/> containing the child elements
282/// with a matching for each <see cref="XElement"/> in this <see cref="IEnumerable"/> of <see cref="XElement"/>.
285/// An <see cref="IEnumerable"/> of <see cref="XElement"/> containing the child elements
286/// for each <see cref="XElement"/> in this <see cref="IEnumerable"/> of <see cref="XElement"/>.
341private static IEnumerable<XAttribute> GetAttributes(IEnumerable<XElement?> source, XName? name)
343foreach (XElement? e in source)
360private static IEnumerable<XElement> GetAncestors<T>(IEnumerable<T?> source, XName? name, bool self) where T : XNode
366XElement? e = (self ? node : node.parent) as XElement;
370e = e.parent as XElement;
404private static IEnumerable<XElement> GetDescendants<T>(IEnumerable<T?> source, XName? name, bool self) where T : XContainer
412XElement e = (XElement)root;
429XElement? e = n as XElement;
437private static IEnumerable<XElement> GetElements<T>(IEnumerable<T?> source, XName? name) where T : XContainer
449XElement? e = n as XElement;
System\Xml\Linq\XElement.cs (257)
26/// An <see cref="XElement"/> can contain the following types of content:
29/// <item><see cref="XElement"/></item>
41public static IEnumerable<XElement> EmptySequence
45return Array.Empty<XElement>();
106public XElement(XElement other)
162internal static async Task<XElement> CreateAsync(XmlReader r, CancellationToken cancellationToken)
164XElement xe = new XElement(default(AsyncConstructionSentry));
170/// Outputs this <see cref="XElement"/>'s underlying XML tree. The output can
175/// Output this <see cref="XElement"/> to a file.
180/// <see cref="XElement.Save(string, SaveOptions)"/>) enabling
194/// Output this <see cref="XElement"/> to a file.
240if (n is XElement) return true;
323/// Returns this <see cref="XElement"/> and all of it's ancestors up
329/// Returns this <see cref="XElement"/> and all of it's ancestors up to
334/// An <see cref="IEnumerable"/> of <see cref="XElement"/> containing all of
335/// this <see cref="XElement"/>'s ancestors up to the root node (including
336/// this <see cref="XElement"/>.
338public IEnumerable<XElement> AncestorsAndSelf()
344/// Returns the ancestor(s) of this <see cref="XElement"/> with the matching
345/// <see cref="XName"/>. If this <see cref="XElement"/>'s <see cref="XName"/>
347/// resulting <see cref="IEnumerable"/> or <see cref="XElement"/>.
354/// An <see cref="IEnumerable"/> of <see cref="XElement"/> containing the
355/// ancestors of this <see cref="XElement"/> with a matching <see cref="XName"/>.
357public IEnumerable<XElement> AncestorsAndSelf(XName? name)
359return name != null ? GetAncestors(name, true) : XElement.EmptySequence;
363/// Returns the <see cref="XAttribute"/> associated with this <see cref="XElement"/> that has this
388/// Returns the <see cref="XAttribute"/> associated with this <see cref="XElement"/>. Optionally
392/// Returns all of the <see cref="XAttribute"/>s associated with this <see cref="XElement"/>.
397/// associated with this <see cref="XElement"/>.
405/// Returns the <see cref="XAttribute"/>(s) associated with this <see cref="XElement"/> that has the passed
407/// <seealso cref="XElement.Attributes()"/>
421/// Get the self and descendant nodes for an <see cref="XElement"/>
430/// Returns this <see cref="XElement"/> and all of it's descendants. Overloads allow
432/// of a descendant <see cref="XElement"/> to match.
435/// Returns this <see cref="XElement"/> and all of it's descendant <see cref="XElement"/>s
436/// as an <see cref="IEnumerable"/> of <see cref="XElement"/>.
437/// <seealso cref="XElement.DescendantsAndSelf()"/>
440/// An <see cref="IEnumerable"/> of <see cref="XElement"/> containing this <see cref="XElement"/>
443public IEnumerable<XElement> DescendantsAndSelf()
449/// Returns the descendants of this <see cref="XElement"/> that have a matching <see cref="XName"/>
450/// to the one passed in, including, potentially, this <see cref="XElement"/>.
451/// <seealso cref="XElement.DescendantsAndSelf(XName)"/>
454/// The <see cref="XName"/> of the descendant <see cref="XElement"/> that is being targeted.
457/// An <see cref="IEnumerable"/> of <see cref="XElement"/> containing all of the descendant
458/// <see cref="XElement"/>s that have this <see cref="XName"/>.
460public IEnumerable<XElement> DescendantsAndSelf(XName? name)
462return name != null ? GetDescendants(name, true) : XElement.EmptySequence;
466/// Returns the default <see cref="XNamespace"/> of an <see cref="XElement"/>
475/// Get the namespace associated with a particular prefix for this <see cref="XElement"/>
501XElement? e = this;
528e = e.parent as XElement;
544/// <see cref="XElement"/> and initializing it from a data source containing
550/// <seealso cref="XElement.Parse(string)"/>
553/// Create a new <see cref="XElement"/> based on the contents of the file
555/// <see cref="XElement.Parse(string)"/> to create an <see cref="XElement"/> from
558/// <seealso cref="XElement.Parse(string)"/>
567/// A URI string referencing the file to load into a new <see cref="XElement"/>.
570/// An <see cref="XElement"/> initialized with the contents of the file referenced
573public static XElement Load([StringSyntax(StringSyntaxAttribute.Uri)] string uri)
579/// Create a new <see cref="XElement"/> based on the contents of the file
592/// A string representing the URI of the file to be loaded into a new <see cref="XElement"/>.
598/// An <see cref="XElement"/> initialized with the contents of the file referenced
602public static XElement Load([StringSyntax(StringSyntaxAttribute.Uri)] string uri, LoadOptions options)
612/// Create a new <see cref="XElement"/> and initialize its underlying XML tree using
617/// created <see cref="XElement"/>.
620/// A new <see cref="XElement"/> containing the contents of the passed in
623public static XElement Load(Stream stream)
629/// Create a new <see cref="XElement"/> and initialize its underlying XML tree using
640/// created <see cref="XElement"/>.
646/// A new <see cref="XElement"/> containing the contents of the passed in
649public static XElement Load(Stream stream, LoadOptions options)
659/// Create a new <see cref="XElement"/> and initialize its underlying XML tree using
670/// created <see cref="XElement"/>.
678/// A new <see cref="XElement"/> containing the contents of the passed in
681public static async Task<XElement> LoadAsync(Stream stream, LoadOptions options, CancellationToken cancellationToken)
694/// Create a new <see cref="XElement"/> and initialize its underlying XML tree using
699/// created <see cref="XElement"/>.
702/// A new <see cref="XElement"/> containing the contents of the passed in
705public static XElement Load(TextReader textReader)
711/// Create a new <see cref="XElement"/> and initialize its underlying XML tree using
722/// created <see cref="XElement"/>.
728/// A new <see cref="XElement"/> containing the contents of the passed in
731public static XElement Load(TextReader textReader, LoadOptions options)
741/// Create a new <see cref="XElement"/> and initialize its underlying XML tree using
752/// created <see cref="XElement"/>.
760/// A new <see cref="XElement"/> containing the contents of the passed in
763public static async Task<XElement> LoadAsync(TextReader textReader, LoadOptions options, CancellationToken cancellationToken)
776/// Create a new <see cref="XElement"/> containing the contents of the
781/// <see cref="XElement"/>.
784/// A new <see cref="XElement"/> containing the contents of the passed
787public static XElement Load(XmlReader reader)
793/// Create a new <see cref="XElement"/> containing the contents of the
798/// <see cref="XElement"/>.
804/// A new <see cref="XElement"/> containing the contents of the passed
807public static XElement Load(XmlReader reader, LoadOptions options)
812XElement e = new XElement(reader, options);
819/// Create a new <see cref="XElement"/> containing the contents of the
824/// <see cref="XElement"/>.
832/// A new <see cref="XElement"/> containing the contents of the passed
835public static Task<XElement> LoadAsync(XmlReader reader, LoadOptions options, CancellationToken cancellationToken)
840return Task.FromCanceled<XElement>(cancellationToken);
844private static async Task<XElement> LoadAsyncInternal(XmlReader reader, LoadOptions options, CancellationToken cancellationToken)
848XElement e = new XElement(default(AsyncConstructionSentry));
859/// Parses a string containing XML into an <see cref="XElement"/>. Optionally
863/// Parses a string containing XML into an <see cref="XElement"/>.
869/// A string containing the XML to parse into an <see cref="XElement"/>.
872/// An <see cref="XElement"/> created from the XML string passed in.
874public static XElement Parse(string text)
880/// Parses a string containing XML into an <see cref="XElement"/> and optionally
894/// A string containing the XML to parse into an <see cref="XElement"/>.
900/// An <see cref="XElement"/> created from the XML string passed in.
902public static XElement Parse(string text, LoadOptions options)
915/// Removes content and attributes from this <see cref="XElement"/>.
916/// <seealso cref="XElement.RemoveAttributes"/>
926/// Removes that attributes of this <see cref="XElement"/>.
927/// <seealso cref="XElement.RemoveAll"/>
928/// <seealso cref="XElement.RemoveAttributes"/>
1032/// Output this <see cref="XElement"/> to the passed in <see cref="Stream"/>.
1037/// <see cref="XElement.Save(Stream, SaveOptions)"/>) enabling
1043/// The <see cref="Stream"/> to output this <see cref="XElement"/> to.
1051/// Output this <see cref="XElement"/> to a <see cref="Stream"/>.
1070/// Output this <see cref="XElement"/> to a <see cref="Stream"/>.
1094/// Output this <see cref="XElement"/> to the passed in <see cref="TextWriter"/>.
1099/// <see cref="XElement.Save(TextWriter, SaveOptions)"/>) enabling
1105/// The <see cref="TextWriter"/> to output this <see cref="XElement"/> to.
1113/// Output this <see cref="XElement"/> to a <see cref="TextWriter"/>.
1132/// Output this <see cref="XElement"/> to a <see cref="TextWriter"/>.
1156/// Output this <see cref="XElement"/> to an <see cref="XmlWriter"/>.
1171/// Output this <see cref="XElement"/> to an <see cref="XmlWriter"/>.
1201/// <seealso cref="XElement.SetElementValue"/>
1202/// <seealso cref="XElement.SetValue"/>
1241/// <seealso cref="XElement.SetAttributeValue"/>
1242/// <seealso cref="XElement.SetValue"/>
1257XElement? e = Element(name);
1278/// <seealso cref="XElement.SetAttributeValue"/>
1279/// <seealso cref="XElement.SetElementValue"/>
1296/// Write this <see cref="XElement"/> to the passed in <see cref="XmlWriter"/>.
1299/// The <see cref="XmlWriter"/> to write this <see cref="XElement"/> to.
1309/// Write this <see cref="XElement"/> to the passed in <see cref="XmlTextWriter"/>.
1312/// The <see cref="XmlTextWriter"/> to write this <see cref="XElement"/> to.
1325/// Cast the value of this <see cref="XElement"/> to a <see cref="string"/>.
1328/// If the <see cref="XElement"/> is a subtree (an <see cref="XElement"/>
1329/// that has <see cref="XElement"/> children. The concatenated string
1330/// value of all of the <see cref="XElement"/>'s text and descendants
1334/// The <see cref="XElement"/> to cast to a string.
1337/// The content of this <see cref="XElement"/> as a <see cref="string"/>.
1341public static explicit operator string?(XElement? element)
1348/// Cast the value of this <see cref="XElement"/> to a <see cref="bool"/>.
1351/// The <see cref="XElement"/> to cast to <see cref="bool"/>.
1354/// The content of this <see cref="XElement"/> as a <see cref="bool"/>.
1363public static explicit operator bool(XElement element)
1371/// Cast the value of this <see cref="XElement"/> to a <see cref="bool"/>?.
1374/// The <see cref="XElement"/> to cast to <see cref="bool"/>?.
1377/// The content of this <see cref="XElement"/> as a <see cref="bool"/>?.
1384public static explicit operator bool?(XElement? element)
1391/// Cast the value of this <see cref="XElement"/> to an <see cref="int"/>.
1394/// The <see cref="XElement"/> to cast to <see cref="int"/>.
1397/// The content of this <see cref="XElement"/> as a <see cref="int"/>.
1406public static explicit operator int(XElement element)
1414/// Cast the value of this <see cref="XElement"/> to an <see cref="int"/>?.
1417/// The <see cref="XElement"/> to cast to <see cref="int"/>?.
1420/// The content of this <see cref="XElement"/> as a <see cref="int"/>?.
1427public static explicit operator int?(XElement? element)
1434/// Cast the value of this <see cref="XElement"/> to an <see cref="uint"/>.
1437/// The <see cref="XElement"/> to cast to <see cref="uint"/>.
1440/// The content of this <see cref="XElement"/> as a <see cref="uint"/>.
1449public static explicit operator uint(XElement element)
1457/// Cast the value of this <see cref="XElement"/> to an <see cref="uint"/>?.
1460/// The <see cref="XElement"/> to cast to <see cref="uint"/>?.
1463/// The content of this <see cref="XElement"/> as a <see cref="uint"/>?.
1470public static explicit operator uint?(XElement? element)
1477/// Cast the value of this <see cref="XElement"/> to a <see cref="long"/>.
1480/// The <see cref="XElement"/> to cast to <see cref="long"/>.
1483/// The content of this <see cref="XElement"/> as a <see cref="long"/>.
1492public static explicit operator long(XElement element)
1500/// Cast the value of this <see cref="XElement"/> to a <see cref="long"/>?.
1503/// The <see cref="XElement"/> to cast to <see cref="long"/>?.
1506/// The content of this <see cref="XElement"/> as a <see cref="long"/>?.
1513public static explicit operator long?(XElement? element)
1520/// Cast the value of this <see cref="XElement"/> to an <see cref="ulong"/>.
1523/// The <see cref="XElement"/> to cast to <see cref="ulong"/>.
1526/// The content of this <see cref="XElement"/> as a <see cref="ulong"/>.
1535public static explicit operator ulong(XElement element)
1543/// Cast the value of this <see cref="XElement"/> to an <see cref="ulong"/>?.
1546/// The <see cref="XElement"/> to cast to <see cref="ulong"/>?.
1549/// The content of this <see cref="XElement"/> as a <see cref="ulong"/>?.
1556public static explicit operator ulong?(XElement? element)
1563/// Cast the value of this <see cref="XElement"/> to a <see cref="float"/>.
1566/// The <see cref="XElement"/> to cast to <see cref="float"/>.
1569/// The content of this <see cref="XElement"/> as a <see cref="float"/>.
1578public static explicit operator float(XElement element)
1586/// Cast the value of this <see cref="XElement"/> to an <see cref="float"/>?.
1589/// The <see cref="XElement"/> to cast to <see cref="float"/>?.
1592/// The content of this <see cref="XElement"/> as a <see cref="float"/>?.
1599public static explicit operator float?(XElement? element)
1606/// Cast the value of this <see cref="XElement"/> to a <see cref="double"/>.
1609/// The <see cref="XElement"/> to cast to <see cref="double"/>.
1612/// The content of this <see cref="XElement"/> as a <see cref="double"/>.
1621public static explicit operator double(XElement element)
1629/// Cast the value of this <see cref="XElement"/> to an <see cref="double"/>?.
1632/// The <see cref="XElement"/> to cast to <see cref="double"/>?.
1635/// The content of this <see cref="XElement"/> as a <see cref="double"/>?.
1642public static explicit operator double?(XElement? element)
1649/// Cast the value of this <see cref="XElement"/> to a <see cref="decimal"/>.
1652/// The <see cref="XElement"/> to cast to <see cref="decimal"/>.
1655/// The content of this <see cref="XElement"/> as a <see cref="decimal"/>.
1664public static explicit operator decimal(XElement element)
1672/// Cast the value of this <see cref="XElement"/> to an <see cref="decimal"/>?.
1675/// The <see cref="XElement"/> to cast to <see cref="decimal"/>?.
1678/// The content of this <see cref="XElement"/> as a <see cref="decimal"/>?.
1685public static explicit operator decimal?(XElement? element)
1692/// Cast the value of this <see cref="XElement"/> to a <see cref="DateTime"/>.
1695/// The <see cref="XElement"/> to cast to <see cref="DateTime"/>.
1698/// The content of this <see cref="XElement"/> as a <see cref="DateTime"/>.
1707public static explicit operator DateTime(XElement element)
1715/// Cast the value of this <see cref="XElement"/> to an <see cref="DateTime"/>?.
1718/// The <see cref="XElement"/> to cast to <see cref="DateTime"/>?.
1721/// The content of this <see cref="XElement"/> as a <see cref="DateTime"/>?.
1728public static explicit operator DateTime?(XElement? element)
1735/// Cast the value of this <see cref="XElement"/> to a <see cref="DateTimeOffset"/>.
1738/// The <see cref="XElement"/> to cast to <see cref="DateTimeOffset"/>.
1741/// The content of this <see cref="XElement"/> as a <see cref="DateTimeOffset"/>.
1750public static explicit operator DateTimeOffset(XElement element)
1758/// Cast the value of this <see cref="XElement"/> to an <see cref="DateTimeOffset"/>?.
1761/// The <see cref="XElement"/> to cast to <see cref="DateTimeOffset"/>?.
1764/// The content of this <see cref="XElement"/> as a <see cref="DateTimeOffset"/>?.
1771public static explicit operator DateTimeOffset?(XElement? element)
1778/// Cast the value of this <see cref="XElement"/> to a <see cref="TimeSpan"/>.
1781/// The <see cref="XElement"/> to cast to <see cref="TimeSpan"/>.
1784/// The content of this <see cref="XElement"/> as a <see cref="TimeSpan"/>.
1793public static explicit operator TimeSpan(XElement element)
1801/// Cast the value of this <see cref="XElement"/> to an <see cref="TimeSpan"/>?.
1804/// The <see cref="XElement"/> to cast to <see cref="TimeSpan"/>?.
1807/// The content of this <see cref="XElement"/> as a <see cref="TimeSpan"/>?.
1814public static explicit operator TimeSpan?(XElement? element)
1821/// Cast the value of this <see cref="XElement"/> to a <see cref="Guid"/>.
1824/// The <see cref="XElement"/> to cast to <see cref="Guid"/>.
1827/// The content of this <see cref="XElement"/> as a <see cref="Guid"/>.
1836public static explicit operator Guid(XElement element)
1844/// Cast the value of this <see cref="XElement"/> to an <see cref="Guid"/>?.
1847/// The <see cref="XElement"/> to cast to <see cref="Guid"/>?.
1850/// The content of this <see cref="XElement"/> as a <see cref="Guid"/>?.
1857public static explicit operator Guid?(XElement? element)
1872/// Generates a <see cref="XElement"/> from its XML representation.
1875/// The <see cref="XmlReader"/> stream from which the <see cref="XElement"/>
1888/// Converts a <see cref="XElement"/> into its XML representation.
1891/// The <see cref="XmlWriter"/> stream to which the <see cref="XElement"/>
1936private bool AttributesEqual(XElement e)
1960XElement? e = node as XElement;
1977private string? GetNamespaceOfPrefixInScope(string prefix, XElement? outOfScope)
1979XElement? e = this;
1993e = e.parent as XElement;
System.Xml.Linq (1)
System.Xml.XDocument (1)