Skip to content
| Marketplace
Sign in
Visual Studio>Tools>EmbeddedData
EmbeddedData

EmbeddedData

Stefan Stolz

|
774 installs
| (0) | Free
Creates Helper-Classes for EmbeddedResources
Download

EmbeddedData is a Visual Studio Extension that creates C#-Code to access EmbeddedResources.

Usage

Set the Build Action to Embedded Resource and Custom Tool to EmbeddedData.

usage.png

After attaching the EmbeddedData Custom Tool, Visual Studio will create the Code to access the Embedded Resource created.png

Currently the Extension creates 6 Methods.

Open returns a Stream containing the Data.

AsFile takes a delegate that is executed with the Name of the temporary generated File. The File is deleted after executing the delegate.

AsByte returns a byte-Array with the Data.

AsString returns the Content of Stream interpreted as UTF8 encoded String.

CopyTo copies the content of the EmbeddedResource as File into the specified Directory.

OpenFile returns an Instance of the inner class FileHandle. This class Has a Property with the Path of the File and a Delete Method. It also implements IDisposeable and deletes the File when Dispose() is called.

using System;
using System.IO;
using System.Text;
using System.Reflection;

#region Designer generated code namespace theprogram.logic.tests.testdata {


	public static partial class Files {
		public static partial class shibby {
			public const string FileName = "shibby.dll";
			public const string ResourceName = "theprogram.logic.tests.testdata.shibby.dll";
			public static Stream Open() {...
			}
			public static void AsFile(Action < string > workWithFile) {...
			}
			public static byte[] AsBytes() {...
			}
			public static string AsString() {...
			}
			public static string CopyTo(string destinationDirectory) {...
			}
			public static FileHandle OpenFile() {...
			}
		}
	}
}

#endregion

Configuration

The behaviour of the Extension can be configured with a Configuration file (embbeddata.config.json).

The Configuration file can be placed in the same directory as the Files to integrate or any directory up in the hierarchy.

EmbeddedData looks in every Directory and merges all files it finds.

config.png

{
   "UseResharperAnnotations":false,
   "ResharperAnnotationsNamespace":"Some.Namespace",
   "ClassNameWithExtension":false
}

UseResharperAnnotations: true to use Resharper Annotations in the generated Code, otherwiese false. The Default is false.

ResharperAnnotationsNamespace: The Namepsace of the Resharper Annnotations. The Default is Jetbrains.Annotations.

More about Resharper Annotations can be found here: https://blog.jetbrains.com/dotnet/2015/08/12/how-to-use-jetbrains-annotations-to-improve-resharper-inspections/

ClassNameWithExtension: true to add the file extension to the generated class name, otherwise false. The Default is false.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft