Add a .gitattributes file to specify eol=LF (#1370)

* Add a .gitattributes file specifying LF-style line endings.

This is similar to [Rust's .gitattributes file] though simplified.
Most of our source and documentation files already used LF-style line
endings, including *.cs files, so this makes things more consistent.

[Rust's .gitattributes file]: https://github.com/rust-lang/rust/blob/master/.gitattributes

* Remove UTF-8 BOMs in *.cs files.

Most of our *.cs files don't have UTF-8 BOMs, so this makes things more
consistent.
This commit is contained in:
Dan Gohman
2020-03-20 18:36:13 -07:00
committed by GitHub
parent 815e340f85
commit c202a8eeaf
21 changed files with 1164 additions and 1157 deletions

View File

@@ -1,85 +1,85 @@
using System;
using System.Text;
using System.Runtime.InteropServices;
namespace Wasmtime
{
/// <summary>
/// Represents the Wasmtime engine.
/// </summary>
public class Engine : IDisposable
{
/// <summary>
/// Constructs a new <see cref="Engine" />.
/// </summary>
public Engine()
{
Handle = Interop.wasm_engine_new();
if (Handle.IsInvalid)
{
throw new WasmtimeException("Failed to create Wasmtime engine.");
}
}
internal Engine(Interop.WasmConfigHandle config)
{
Handle = Interop.wasm_engine_new_with_config(config);
config.SetHandleAsInvalid();
if (Handle.IsInvalid)
{
throw new WasmtimeException("Failed to create Wasmtime engine.");
}
}
/// <summary>
/// Creates a new Wasmtime <see cref="Store" />.
/// </summary>
/// <returns>Returns the new <see cref="Store" />.</returns>
public Store CreateStore()
{
return new Store(this);
}
/// <summary>
/// Converts the WebAssembly text format to the binary format
/// </summary>
/// <returns>Returns the binary-encoded wasm module.</returns>
public byte[] WatToWasm(string wat)
{
var watBytes = Encoding.UTF8.GetBytes(wat);
unsafe
{
fixed (byte *ptr = watBytes)
{
Interop.wasm_byte_vec_t watByteVec;
watByteVec.size = (UIntPtr)watBytes.Length;
watByteVec.data = ptr;
if (!Interop.wasmtime_wat2wasm(Handle, ref watByteVec, out var bytes, out var error)) {
var errorSpan = new ReadOnlySpan<byte>(error.data, checked((int)error.size));
var message = Encoding.UTF8.GetString(errorSpan);
Interop.wasm_byte_vec_delete(ref error);
throw new WasmtimeException("failed to parse input wat: " + message);
}
var byteSpan = new ReadOnlySpan<byte>(bytes.data, checked((int)bytes.size));
var ret = byteSpan.ToArray();
Interop.wasm_byte_vec_delete(ref bytes);
return ret;
}
}
}
/// <inheritdoc/>
public void Dispose()
{
if (!Handle.IsInvalid)
{
Handle.Dispose();
Handle.SetHandleAsInvalid();
}
}
internal Interop.EngineHandle Handle { get; private set; }
}
}
using System;
using System.Text;
using System.Runtime.InteropServices;
namespace Wasmtime
{
/// <summary>
/// Represents the Wasmtime engine.
/// </summary>
public class Engine : IDisposable
{
/// <summary>
/// Constructs a new <see cref="Engine" />.
/// </summary>
public Engine()
{
Handle = Interop.wasm_engine_new();
if (Handle.IsInvalid)
{
throw new WasmtimeException("Failed to create Wasmtime engine.");
}
}
internal Engine(Interop.WasmConfigHandle config)
{
Handle = Interop.wasm_engine_new_with_config(config);
config.SetHandleAsInvalid();
if (Handle.IsInvalid)
{
throw new WasmtimeException("Failed to create Wasmtime engine.");
}
}
/// <summary>
/// Creates a new Wasmtime <see cref="Store" />.
/// </summary>
/// <returns>Returns the new <see cref="Store" />.</returns>
public Store CreateStore()
{
return new Store(this);
}
/// <summary>
/// Converts the WebAssembly text format to the binary format
/// </summary>
/// <returns>Returns the binary-encoded wasm module.</returns>
public byte[] WatToWasm(string wat)
{
var watBytes = Encoding.UTF8.GetBytes(wat);
unsafe
{
fixed (byte *ptr = watBytes)
{
Interop.wasm_byte_vec_t watByteVec;
watByteVec.size = (UIntPtr)watBytes.Length;
watByteVec.data = ptr;
if (!Interop.wasmtime_wat2wasm(Handle, ref watByteVec, out var bytes, out var error)) {
var errorSpan = new ReadOnlySpan<byte>(error.data, checked((int)error.size));
var message = Encoding.UTF8.GetString(errorSpan);
Interop.wasm_byte_vec_delete(ref error);
throw new WasmtimeException("failed to parse input wat: " + message);
}
var byteSpan = new ReadOnlySpan<byte>(bytes.data, checked((int)bytes.size));
var ret = byteSpan.ToArray();
Interop.wasm_byte_vec_delete(ref bytes);
return ret;
}
}
}
/// <inheritdoc/>
public void Dispose()
{
if (!Handle.IsInvalid)
{
Handle.Dispose();
Handle.SetHandleAsInvalid();
}
}
internal Interop.EngineHandle Handle { get; private set; }
}
}

View File

@@ -1,77 +1,77 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.6.0" />
</ItemGroup>
<PropertyGroup>
<AssemblyName>Wasmtime.Dotnet</AssemblyName>
<PackageId>Wasmtime</PackageId>
<Version>$(WasmtimeVersion)-preview1</Version>
<Authors>Peter Huene</Authors>
<Owners>Peter Huene</Owners>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<RepositoryUrl>https://github.com/bytecodealliance/wasmtime</RepositoryUrl>
<PackageReleaseNotes>Initial release of Wasmtime for .NET.</PackageReleaseNotes>
<Summary>A .NET API for Wasmtime, a standalone WebAssembly runtime</Summary>
<PackageTags>webassembly, .net, wasm, wasmtime</PackageTags>
<Title>Wasmtime</Title>
<PackageDescription>
A .NET API for Wasmtime.
Wasmtime is a standalone runtime for WebAssembly, using the Cranelift JIT compiler.
Wasmtime for .NET enables .NET code to instantiate WebAssembly modules and to interact with them in-process.
</PackageDescription>
</PropertyGroup>
<Target Name="PackWasmtime" BeforeTargets="_GetPackageFiles">
<PropertyGroup>
<WasmtimeArchitecture>x86_64</WasmtimeArchitecture>
<ReleaseURLBase>https://github.com/bytecodealliance/wasmtime/releases/download/v$(WasmtimeVersion)/wasmtime-v$(WasmtimeVersion)-$(WasmtimeArchitecture)</ReleaseURLBase>
</PropertyGroup>
<ItemGroup>
<WasmtimeDownload Include="Linux">
<URL>$(ReleaseURLBase)-linux-c-api.tar.xz</URL>
<DownloadFolder>$(IntermediateOutputPath)wasmtime-linux</DownloadFolder>
<DownloadFilename>linux.tar.xz</DownloadFilename>
<WasmtimeLibraryFilename>libwasmtime.so</WasmtimeLibraryFilename>
<PackagePath>runtimes/linux-x64/native</PackagePath>
</WasmtimeDownload>
<WasmtimeDownload Include="macOS">
<URL>$(ReleaseURLBase)-macos-c-api.tar.xz</URL>
<DownloadFolder>$(IntermediateOutputPath)wasmtime-macos</DownloadFolder>
<DownloadFilename>macos.tar.xz</DownloadFilename>
<WasmtimeLibraryFilename>libwasmtime.dylib</WasmtimeLibraryFilename>
<PackagePath>runtimes/osx-x64/native</PackagePath>
</WasmtimeDownload>
<WasmtimeDownload Include="Windows">
<URL>$(ReleaseURLBase)-windows-c-api.zip</URL>
<DownloadFolder>$(IntermediateOutputPath)wasmtime-windows</DownloadFolder>
<DownloadFilename>windows.zip</DownloadFilename>
<WasmtimeLibraryFilename>wasmtime.dll</WasmtimeLibraryFilename>
<PackagePath>runtimes/win-x64/native</PackagePath>
</WasmtimeDownload>
</ItemGroup>
<Message Text="Downloading Wasmtime release." Importance="High" />
<DownloadFile SourceUrl="%(WasmtimeDownload.URL)" DestinationFolder="%(WasmtimeDownload.DownloadFolder)" DestinationFileName="%(WasmtimeDownload.DownloadFilename)" SkipUnchangedFiles="true" />
<Message Text="Decompressing Wasmtime release." Importance="High" />
<Exec Command="tar --strip-components 1 -xvzf %(WasmtimeDownload.DownloadFilename)" WorkingDirectory="%(WasmtimeDownload.DownloadFolder)" StandardOutputImportance="Low" StandardErrorImportance="Low" />
<ItemGroup>
<Content Include="%(WasmtimeDownload.DownloadFolder)/lib/%(WasmtimeDownload.WasmtimeLibraryFilename)" Link="%(WasmtimeDownload.PackagePath)/%(WasmtimeDownload.WasmtimeLibraryFilename)">
<PackagePath>%(WasmtimeDownload.PackagePath)</PackagePath>
</Content>
</ItemGroup>
</Target>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.6.0" />
</ItemGroup>
<PropertyGroup>
<AssemblyName>Wasmtime.Dotnet</AssemblyName>
<PackageId>Wasmtime</PackageId>
<Version>$(WasmtimeVersion)-preview1</Version>
<Authors>Peter Huene</Authors>
<Owners>Peter Huene</Owners>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<RepositoryUrl>https://github.com/bytecodealliance/wasmtime</RepositoryUrl>
<PackageReleaseNotes>Initial release of Wasmtime for .NET.</PackageReleaseNotes>
<Summary>A .NET API for Wasmtime, a standalone WebAssembly runtime</Summary>
<PackageTags>webassembly, .net, wasm, wasmtime</PackageTags>
<Title>Wasmtime</Title>
<PackageDescription>
A .NET API for Wasmtime.
Wasmtime is a standalone runtime for WebAssembly, using the Cranelift JIT compiler.
Wasmtime for .NET enables .NET code to instantiate WebAssembly modules and to interact with them in-process.
</PackageDescription>
</PropertyGroup>
<Target Name="PackWasmtime" BeforeTargets="_GetPackageFiles">
<PropertyGroup>
<WasmtimeArchitecture>x86_64</WasmtimeArchitecture>
<ReleaseURLBase>https://github.com/bytecodealliance/wasmtime/releases/download/v$(WasmtimeVersion)/wasmtime-v$(WasmtimeVersion)-$(WasmtimeArchitecture)</ReleaseURLBase>
</PropertyGroup>
<ItemGroup>
<WasmtimeDownload Include="Linux">
<URL>$(ReleaseURLBase)-linux-c-api.tar.xz</URL>
<DownloadFolder>$(IntermediateOutputPath)wasmtime-linux</DownloadFolder>
<DownloadFilename>linux.tar.xz</DownloadFilename>
<WasmtimeLibraryFilename>libwasmtime.so</WasmtimeLibraryFilename>
<PackagePath>runtimes/linux-x64/native</PackagePath>
</WasmtimeDownload>
<WasmtimeDownload Include="macOS">
<URL>$(ReleaseURLBase)-macos-c-api.tar.xz</URL>
<DownloadFolder>$(IntermediateOutputPath)wasmtime-macos</DownloadFolder>
<DownloadFilename>macos.tar.xz</DownloadFilename>
<WasmtimeLibraryFilename>libwasmtime.dylib</WasmtimeLibraryFilename>
<PackagePath>runtimes/osx-x64/native</PackagePath>
</WasmtimeDownload>
<WasmtimeDownload Include="Windows">
<URL>$(ReleaseURLBase)-windows-c-api.zip</URL>
<DownloadFolder>$(IntermediateOutputPath)wasmtime-windows</DownloadFolder>
<DownloadFilename>windows.zip</DownloadFilename>
<WasmtimeLibraryFilename>wasmtime.dll</WasmtimeLibraryFilename>
<PackagePath>runtimes/win-x64/native</PackagePath>
</WasmtimeDownload>
</ItemGroup>
<Message Text="Downloading Wasmtime release." Importance="High" />
<DownloadFile SourceUrl="%(WasmtimeDownload.URL)" DestinationFolder="%(WasmtimeDownload.DownloadFolder)" DestinationFileName="%(WasmtimeDownload.DownloadFilename)" SkipUnchangedFiles="true" />
<Message Text="Decompressing Wasmtime release." Importance="High" />
<Exec Command="tar --strip-components 1 -xvzf %(WasmtimeDownload.DownloadFilename)" WorkingDirectory="%(WasmtimeDownload.DownloadFolder)" StandardOutputImportance="Low" StandardErrorImportance="Low" />
<ItemGroup>
<Content Include="%(WasmtimeDownload.DownloadFolder)/lib/%(WasmtimeDownload.WasmtimeLibraryFilename)" Link="%(WasmtimeDownload.PackagePath)/%(WasmtimeDownload.WasmtimeLibraryFilename)">
<PackagePath>%(WasmtimeDownload.PackagePath)</PackagePath>
</Content>
</ItemGroup>
</Target>
</Project>