diff --git a/Content/UniversalEditor.Content.PlatformIndependent/Extensions/Microsoft/Extensions/Xaml/Associations/BAML.uexml b/Content/UniversalEditor.Content.PlatformIndependent/Extensions/Microsoft/Extensions/Xaml/Associations/BAML.uexml new file mode 100644 index 00000000..4b8cefd0 --- /dev/null +++ b/Content/UniversalEditor.Content.PlatformIndependent/Extensions/Microsoft/Extensions/Xaml/Associations/BAML.uexml @@ -0,0 +1,20 @@ + + + + + + + + *.baml + + + + + + + + + + + + \ No newline at end of file diff --git a/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj b/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj index 078e19b7..b6bfa20b 100644 --- a/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj +++ b/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj @@ -583,6 +583,7 @@ + @@ -654,6 +655,9 @@ + + + diff --git a/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/DataFormats/BAML/BAMLDataFormat.cs b/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/DataFormats/BAML/BAMLDataFormat.cs new file mode 100644 index 00000000..b95d9f2f --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/DataFormats/BAML/BAMLDataFormat.cs @@ -0,0 +1,125 @@ +// +// BAMLDataFormat.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2020 Mike Becker's Software +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +using System; +using UniversalEditor; +using UniversalEditor.IO; +using UniversalEditor.Plugins.Microsoft.Xaml.ObjectModels.XAML; + +namespace UniversalEditor.Plugins.Microsoft.Xaml.DataFormats.BAML +{ + public class BAMLDataFormat : DataFormat + { + private static DataFormatReference _dfr = null; + protected override DataFormatReference MakeReferenceInternal() + { + if (_dfr == null) + { + _dfr = base.MakeReferenceInternal(); + _dfr.Capabilities.Add(typeof(XAMLObjectModel), DataFormatCapabilities.All); + } + return _dfr; + } + + public string FeatureID { get; set; } = "MSBAML"; + + public Version ReaderVersion { get; set; } = new Version(0, 96); + public Version UpdaterVersion { get; set; } = new Version(0, 96); + public Version WriterVersion { get; set; } = new Version(0, 96); + + protected override void LoadInternal(ref ObjectModel objectModel) + { + Reader reader = Accessor.Reader; + + uint signatureLength = reader.ReadUInt32(); + byte[] signatureData = reader.ReadBytes(signatureLength); + string signature = System.Text.Encoding.Unicode.GetString(signatureData); + FeatureID = signature; + + ReaderVersion = Read2xUInt16Version(reader); + UpdaterVersion = Read2xUInt16Version(reader); + WriterVersion = Read2xUInt16Version(reader); + + while (!reader.EndOfStream) + { + BAMLRecordType recordType = (BAMLRecordType)reader.ReadByte(); + switch (recordType) + { + case BAMLRecordType.DocumentStart: + { + byte zero1 = reader.ReadByte(); + int neg1 = reader.ReadInt32(); + byte zero2 = reader.ReadByte(); + break; + } + case BAMLRecordType.AssemblyInfo: + { + ushort unknown4a = reader.ReadUInt16(); + byte unknown5a = reader.ReadByte(); + string assemblyName = reader.ReadLengthPrefixedString(); + Console.WriteLine("Assembly name: {0}", assemblyName); + break; + } + case BAMLRecordType.TypeInfo: + { + byte u = reader.ReadByte(); + uint unknown4 = reader.ReadUInt32(); + + string typename = reader.ReadLengthPrefixedString(); + Console.WriteLine("typename is {0}", typename); + break; + } + case BAMLRecordType.ElementStart: + { + byte u = reader.ReadByte(); + ushort u1 = reader.ReadUInt16(); + break; + } + } + } + } + + private Version Read2xUInt16Version(Reader reader) + { + ushort majorVer = reader.ReadUInt16(); + ushort minorVer = reader.ReadUInt16(); + return new Version(majorVer, minorVer); + } + private void Write2xUInt16Version(Writer writer, Version value) + { + writer.WriteUInt16((ushort)value.Major); + writer.WriteUInt16((ushort)value.Minor); + } + + protected override void SaveInternal(ObjectModel objectModel) + { + Writer writer = Accessor.Writer; + + string signature = FeatureID; + byte[] signatureData = System.Text.Encoding.Unicode.GetBytes(signature); + writer.WriteUInt32((uint)signatureData.Length); + + Write2xUInt16Version(writer, ReaderVersion); + Write2xUInt16Version(writer, UpdaterVersion); + Write2xUInt16Version(writer, WriterVersion); + } + } +} diff --git a/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/DataFormats/BAML/BAMLRecord.cs b/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/DataFormats/BAML/BAMLRecord.cs new file mode 100644 index 00000000..ed9224a3 --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/DataFormats/BAML/BAMLRecord.cs @@ -0,0 +1,28 @@ +// +// BAMLRecord.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2020 Mike Becker's Software +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +namespace UniversalEditor.Plugins.Microsoft.Xaml.DataFormats.BAML +{ + public abstract class BAMLRecord + { + public abstract BAMLRecordType RecordType { get; } + } +} diff --git a/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/DataFormats/BAML/BAMLRecordType.cs b/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/DataFormats/BAML/BAMLRecordType.cs new file mode 100644 index 00000000..083f58e5 --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/DataFormats/BAML/BAMLRecordType.cs @@ -0,0 +1,308 @@ +// +// BAMLRecord.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2020 Mike Becker's Software +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +namespace UniversalEditor.Plugins.Microsoft.Xaml.DataFormats.BAML +{ + public enum BAMLRecordType : byte + { + Unknown = 0, + DocumentStart = 1, + DocumentEnd = 2, + + /// + /// Start Element Node, which may be a CLR object or a DependencyObject + /// + ElementStart = 3, + ElementEnd = 4, + + /// + /// Property Node, which may be a CLR property or a DependencyProperty + /// + Property = 5, + + /// + /// Binary serialization of a property + /// + PropertyCustom = 6, + + /// + /// Complex Property Node + /// + PropertyComplexStart = 7, + + /// + /// End Complex Property Node + /// + PropertyComplexEnd = 8, + + /// + /// Start Array Property Node + /// + PropertyArrayStart = 9, + + /// + /// End Array Property Node + /// + PropertyArrayEnd = 10, + + /// + /// Star IList Property Node + /// + PropertyIListStart = 11, + + /// + /// End PropertyIListStart Node + /// + PropertyIListEnd = 12, + + /// + /// Start IDictionary Property Node + /// + PropertyIDictionaryStart = 13, + + /// + /// End IDictionary Property Node + /// + PropertyIDictionaryEnd = 14, + + /// + /// LiteralContent Node + /// + LiteralContent = 15, + + /// + /// Text Node + /// + Text = 16, + + /// + /// Text that has an associated custom typeconverter + /// + TextWithConverter = 17, + + /// + /// RoutedEventNode + /// + RoutedEvent = 18, + + /// + /// ClrEvent Node + /// + ClrEvent = 19, + + /// + /// XmlnsProperty Node + /// + XmlnsProperty = 20, + + /// + /// XmlAttribute Node + /// + XmlAttribute = 21, + + /// + /// Processing Intstruction Node + /// + ProcessingInstruction = 22, + + /// + /// Comment Node + /// + Comment = 23, + + /// + /// DefTag Node + /// + DefTag = 24, + + /// + /// x:name="value" attribute. One typical use of this + /// attribute is to define a key to use when inserting an item into an IDictionary + /// + DefAttribute = 25, + + /// + /// EndAttributes Node + /// + EndAttributes = 26, + + /// + /// PI xml - clr namespace mapping + /// + PIMapping = 27, + + /// + /// Assembly information + /// + AssemblyInfo = 28, + + /// + /// Type information + /// + TypeInfo = 29, + + /// + /// Type information for a Type that has an associated custom serializer + /// + TypeSerializerInfo = 30, + + /// + /// Attribute (eg - properties and events) information + /// + AttributeInfo = 31, + + /// + /// Resource information + /// + StringInfo = 32, + + /// + /// Property Resource Reference + /// + PropertyStringReference = 33, + + /// + /// Record for setting a property to a Type reference. This is used for + /// properties that are of type "Type" + /// + PropertyTypeReference = 34, + + /// + /// Property that has a simple MarkupExtension value. + /// + PropertyWithExtension = 35, // 35 + + /// + /// Property that has an associated custom typeconverter + /// + PropertyWithConverter = 36, + + /// + /// Start a deferable content block + /// + DeferableContentStart = 37, + + /// + /// x:name="value" attribute when used within a defer load + /// dictionary. These keys are hoisted to the front of the dictionary when + /// written to baml. + /// + DefAttributeKeyString = 38, + + /// + /// Implied key that is a Type attribute when used within a defer load + /// dictionary. These keys are hoisted to the front of the dictionary when + /// written to baml. + /// + DefAttributeKeyType = 39, + + /// + /// This marks the start of an element tree that is used as the key in + /// an IDictionary. + /// + KeyElementStart = 40, + + + /// + /// This marks the end of an element tree that is used as the key in + /// an IDictionary. + /// + KeyElementEnd = 41, + + /// + /// Record marks the start of a section containing constructor parameters + /// + ConstructorParametersStart = 42, + + /// + /// Record marks the end of a section containing constructor parameters + /// + ConstructorParametersEnd = 43, + + /// + /// Constructor parameter that has been resolved to a Type. + /// + ConstructorParameterType = 44, + + /// + /// Record that has info about which event or id to connect to in an object tree. + /// + ConnectionId = 45, + + /// + /// Record that set the conntent property context for the element + /// + ContentProperty = 46, + + /// + /// ElementStartRecord that also carries an element name. + /// + NamedElementStart = 47, + + /// + /// Start of StaticResourceExtension within the header of a deferred section. + /// + StaticResourceStart = 48, + + /// + /// End of a StaticResourceExtension within the header of a deferred section. + /// + StaticResourceEnd = 49, + + /// + /// BamlRecord that carries an identifier for a StaticResourceExtension + /// within the header of a deferred section. + /// + StaticResourceId = 50, + + /// + /// This is a TextRecord that holds an Id for the String value it represents. + /// + TextWithId = 51, + + /// + /// PresentationOptions:Freeze="value" attribute. Used for ignorable + /// WPF-specific parsing options + /// + PresentationOptionsAttribute = 52, + + /// + /// Debugging information record that holds the source XAML linenumber. + /// + LineNumberAndPosition = 53, + + /// + /// Debugging information record that holds the source XAML line position. + /// + LinePosition = 54, + + /// + /// OptimizedStaticResourceExtension within the header of a deferred section. + /// + OptimizedStaticResource = 55, + + /// + /// BamlPropertyRecord that carries an identifier for a StaticResourceExtension + /// within the header of a deferred section. + /// + PropertyWithStaticResourceId = 56 + } +} \ No newline at end of file diff --git a/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/DataFormats/BAML/Records/BAMLAssemblyInfoRecord.cs b/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/DataFormats/BAML/Records/BAMLAssemblyInfoRecord.cs new file mode 100644 index 00000000..d573e3d6 --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/DataFormats/BAML/Records/BAMLAssemblyInfoRecord.cs @@ -0,0 +1,29 @@ +// +// BAMLAssemblyInfoRecord.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2020 Mike Becker's Software +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +namespace UniversalEditor.Plugins.Microsoft.Xaml.DataFormats.BAML.Records +{ + public class BAMLAssemblyInfoRecord : BAMLRecord + { + public override BAMLRecordType RecordType => BAMLRecordType.AssemblyInfo; + + } +} diff --git a/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/ObjectModels/XAML/XAMLObjectModel.cs b/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/ObjectModels/XAML/XAMLObjectModel.cs new file mode 100644 index 00000000..5c15796c --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/ObjectModels/XAML/XAMLObjectModel.cs @@ -0,0 +1,34 @@ +// +// XamlObjectModel.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2020 Mike Becker's Software +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +namespace UniversalEditor.Plugins.Microsoft.Xaml.ObjectModels.XAML +{ + public class XAMLObjectModel : ObjectModel + { + public override void Clear() + { + } + + public override void CopyTo(ObjectModel where) + { + } + } +} diff --git a/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/Properties/AssemblyInfo.cs b/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..7ebbf638 --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/Properties/AssemblyInfo.cs @@ -0,0 +1,46 @@ +// +// AssemblyInfo.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2020 Mike Becker's Software +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("UniversalEditor.Plugins.Microsoft.Xaml")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Mike Becker's Software")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("Mike Becker's Software")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] diff --git a/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/UniversalEditor.Plugins.Microsoft.Xaml.csproj b/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/UniversalEditor.Plugins.Microsoft.Xaml.csproj new file mode 100644 index 00000000..af56ab21 --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Microsoft.Xaml/UniversalEditor.Plugins.Microsoft.Xaml.csproj @@ -0,0 +1,55 @@ + + + + Debug + AnyCPU + {71BA711E-BF60-4E5E-8E8D-14DCB6CE2AAF} + Library + UniversalEditor.Plugins.Microsoft.Xaml + UniversalEditor.Plugins.Microsoft.Xaml + v4.7 + 4.0.2019.12 + + + true + full + false + ..\..\Output\Debug\Plugins + DEBUG; + prompt + 4 + false + + + true + ..\..\Output\Release\Plugins + prompt + 4 + false + + + + + + + + + + + + + + + + + + + + + + {2D4737E6-6D95-408A-90DB-8DFF38147E85} + UniversalEditor.Core + + + + \ No newline at end of file