Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lost xmlns #2052

Closed
CreateAndInject opened this issue Jun 27, 2020 · 8 comments
Closed

Lost xmlns #2052

CreateAndInject opened this issue Jun 27, 2020 · 8 comments
Labels
Bug Decompiler The decompiler engine itself XAML

Comments

@CreateAndInject
Copy link
Contributor

Original:
<Grid x:XmlAttributeProperties.XmlSpace="preserve"/>

ILSpy:
<Grid XmlAttributeProperties.XmlSpace="preserve"/>

VS can't build it without x:

@CreateAndInject
Copy link
Contributor Author

By the way, how can I decompile .baml to a string/Stream/Document?
I find BamlResourceFileHandler, but it save to a file.

@CreateAndInject
Copy link
Contributor Author

Another ILSpy output:
<GroupBox Grid.Row="1" xmlns="clr-namespace:DevExpress.Xpf.LayoutControl;assembly=DevExpress.Xpf.LayoutControl.v19.1">

dnSpy is right:

<Window .... xmlns:lay="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol">
<lay:GroupBox Grid.Row="1">

Here, GroupBox defined in DevExpress.Xpf.LayoutControl.v19.1, Grid defined in PresentationFramework, ILSpy doesn't add a prefix for GroupBox, VS think both GroupBox and Grid defined in DevExpress.Xpf.LayoutControl.v19.1, so build failed.

@siegfriedpammer
Copy link
Member

By the way, how can I decompile .baml to a string/Stream/Document?
I find BamlResourceFileHandler, but it save to a file.

Currently there are no plans to add the BAML decompiler to tools other than ILSpy. How would such an API look like?

@CreateAndInject
Copy link
Contributor Author

@siegfriedpammer Minimum change: make LoadIntoDocument as public, and add an optional parameter assemblyReferences

Others, make more types/members as public, such as: BamlDocument BamlReader XamlDecompiler......

@CreateAndInject
Copy link
Contributor Author

Can you expose assemblyReferences?

@siegfriedpammer siegfriedpammer added the Decompiler The decompiler engine itself label Aug 8, 2020
@CreateAndInject
Copy link
Contributor Author

@siegfriedpammer Can you expose assemblyReferences? So when we export to project, we can know which assemblies should be referenced.

@siegfriedpammer
Copy link
Member

I am not sure, what you are referring to. When exporting an assembly as project, ILSpy already generates a project file, which should contain all required references. Are you talking about single file XAML export?

@CreateAndInject
Copy link
Contributor Author

CreateAndInject commented Mar 9, 2021

@siegfriedpammer, My plugin need it. What you do is:

		internal static XDocument LoadIntoDocument(PEFile module, IAssemblyResolver assemblyResolver,
			Stream stream, CancellationToken cancellationToken)
		{
			cancellationToken.ThrowIfCancellationRequested();
			var document = BamlReader.ReadDocument(stream, cancellationToken);
			var xaml = new XamlDecompiler().Decompile(new BamlDecompilerTypeSystem(module, assemblyResolver), document, cancellationToken, new BamlDecompilerOptions(), null);
			return xaml;
		}

=>

		public static XDocument LoadIntoDocument(PEFile module, IAssemblyResolver assemblyResolver,
			Stream stream, CancellationToken cancellationToken, List<string> assemblyReferences = null)
		{
			cancellationToken.ThrowIfCancellationRequested();
			var document = BamlReader.ReadDocument(stream, cancellationToken);
			var xaml = new XamlDecompiler().Decompile(new BamlDecompilerTypeSystem(module, assemblyResolver), document, cancellationToken, new BamlDecompilerOptions(), assemblyReferences);
			return xaml;
		}

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Decompiler The decompiler engine itself XAML
Projects
None yet
Development

No branches or pull requests

2 participants