CodeSnippetSerializer.SaveToFile() something the matter

SyntaxEditor for WPF Forum

Posted 3 months ago by SPF - Appeon
Version: 22.1.2
Avatar
var serializer = new CodeSnippetSerializer();

            var path = Path.Combine(Path.GetDirectoryName(this.GetType().Assembly.Location)!, "cw.snippet");

            var streamReader = new StreamReader(path);

            var snippets = serializer.LoadFromStream(streamReader.BaseStream);

            serializer.SaveToFile(Path.Combine(Path.GetDirectoryName(this.GetType().Assembly.Location)!, "cw1.snippet"), snippets.ToArray());

            //The contents of the file "cw.snippet" and "cw1.snippet" are different

See my email for details.

cw.snippet

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>cw</Title>
			<Shortcut>cw</Shortcut>
			<Description>Console.WriteLine 的代码片段</Description>
			<Author>Microsoft Corporation</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal Editable="false">
					<ID>SystemConsole</ID>
					<Function>SimpleTypeName(global::System.Console)</Function>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[$SystemConsole$.WriteLine($end$);]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>

<Literal Editable="false">

<Literal IsEditable="False">

[Modified 3 months ago]

Comments (3)

Posted 3 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Thank you for reporting this.  We fixed it so "Editable" is output for the next maintenance release. 

The case on the boolean value doesn't make a difference though, since both value styles will load fine.

[Modified 3 months ago]


Actipro Software Support

Posted 3 months ago by SPF - Appeon
Avatar
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>cw</Title>
			<Shortcut>cw</Shortcut>
			<Description>Console.WriteLine 的代码片段</Description>
			<Author>Microsoft Corporation</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal Editable="false">
					<ID>SystemConsole</ID>
					<Defauld>Console</Defauld>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[$SystemConsole$.WriteLine($end$);]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>

In this file, the "console" part should not be selected and need not have a background color, but in our control, the "console" part will have a background color.

Posted 3 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

We have updated non-editable fields to not be tagged (and thus won't get a background color) for the next maintenance release.

In the future, kindly post unrelated issues in a new thread.  Thank you!


Actipro Software Support

The latest build of this product (v22.1.3) was released 23 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.