File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 44using System . IO ;
55using System . Linq ;
66using System . Reflection ;
7+ using System . Reflection . Metadata ;
78using System . Runtime . Loader ;
89using System . Text ;
910using System . Text . RegularExpressions ;
@@ -161,7 +162,20 @@ private Assembly Compile(IEnumerable<string> sources)
161162 var references = AppDomain . CurrentDomain . GetAssemblies ( )
162163 . Concat ( new [ ] { Assembly . GetExecutingAssembly ( ) , } )
163164 . Where ( x => x . IsDynamic == false )
164- . Select ( x => MetadataReference . CreateFromFile ( x . Location ) ) ;
165+ . Select ( x => {
166+ if ( ! string . IsNullOrEmpty ( x . Location ) )
167+ {
168+ return MetadataReference . CreateFromFile ( x . Location ) ;
169+ }
170+ else
171+ {
172+ unsafe
173+ {
174+ x . TryGetRawMetadata ( out byte * blob , out int length ) ;
175+ return AssemblyMetadata . Create ( ModuleMetadata . CreateFromMetadata ( ( IntPtr ) blob , length ) ) . GetReference ( ) ;
176+ }
177+ }
178+ } ) ;
165179 var options = new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ;
166180 var compilation = CSharpCompilation . Create ( name )
167181 . WithOptions ( options )
Original file line number Diff line number Diff line change 2323 <Title >Virtual Desktop API for C#</Title >
2424 <RepositoryType >git</RepositoryType >
2525 <PackageReleaseNotes >$(PublishReleaseNotes)</PackageReleaseNotes >
26+ <AllowUnsafeBlocks >true</AllowUnsafeBlocks >
2627 </PropertyGroup >
2728
2829 <PropertyGroup Condition =" '$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-windows10.0.19041.0|AnyCPU'" >
You can’t perform that action at this time.
0 commit comments