Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6f925b3

Browse files
author
Kevin Ransom
committed
Fix TypeProviders with managed resources
1 parentb648e19 commit6f925b3

File tree

5 files changed

+28
-31
lines changed

5 files changed

+28
-31
lines changed

‎src/absil/il.fs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2096,7 +2096,7 @@ type ILResourceAccess =
20962096

20972097
[<RequireQualifiedAccess>]
20982098
typeILResourceLocation=
2099-
| LocalInofstring*int*int
2099+
| LocalInofbyte[]
21002100
| LocalOutofbyte[]
21012101
| FileofILModuleRef*int32
21022102
| AssemblyofILAssemblyRef
@@ -2111,8 +2111,7 @@ type ILResource =
21112111
/// Read the bytes from a resource local to an assembly
21122112
memberr.GetBytes()=
21132113
match r.Locationwith
2114-
| ILResourceLocation.LocalIn(file, start, len)->
2115-
File.ReadBinaryChunk(file, start, len)
2114+
| ILResourceLocation.LocalIn bytes
21162115
| ILResourceLocation.LocalOut bytes-> bytes
21172116
|_-> failwith"GetBytes"
21182117

‎src/absil/il.fsi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,7 @@ type ILResourceAccess =
13811381
[<RequireQualifiedAccess>]
13821382
typeILResourceLocation=
13831383
/// Represents a manifest resource that can be read from within the PE file
1384-
| LocalInofstring*int*int
1384+
| LocalInofbyte[]
13851385

13861386
/// Represents a manifest resource that is due to be written to the output PE file
13871387
| LocalOutofbyte[]

‎src/absil/ilread.fs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3233,10 +3233,10 @@ and seekReadManifestResources (ctxt: ILMetadataReader) (mdv: BinaryView) (pectxt
32333233
letlocation=
32343234
match scorefwith
32353235
| ILScopeRef.Local->
3236-
letstart= pectxtEager.anyV2P("resource", offset+ pectxtEager.resourcesAddr)
3237-
letresourceLength= seekReadInt32 pevEager start
3238-
letoffsetOfBytesFromStartOfPhysicalPEFile= start+4
3239-
ILResourceLocation.LocalIn(ctxt.fileName, offsetOfBytesFromStartOfPhysicalPEFile, resourceLength)
3236+
letstart= pectxtEager.anyV2P("resource", offset+ pectxtEager.resourcesAddr)
3237+
letresourceLength= seekReadInt32 pevEager start
3238+
letoffsetOfBytesFromStartOfPhysicalPEFile= start+4
3239+
ILResourceLocation.LocalIn(seekReadBytes(pectxtEager.pefile.GetView()) offsetOfBytesFromStartOfPhysicalPEFile resourceLength)
32403240
| ILScopeRef.Module mref-> ILResourceLocation.File(mref, offset)
32413241
| ILScopeRef.Assembly aref-> ILResourceLocation.Assembly aref
32423242

‎src/absil/ilreflect.fs‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,12 +2036,9 @@ let buildModuleFragment cenv emEnv (asmB : AssemblyBuilder) (modB : ModuleBuilde
20362036
m.Resources.AsList|> List.iter(fun r->
20372037
letattribs=(match r.Accesswith ILResourceAccess.Public-> ResourceAttributes.Public| ILResourceAccess.Private-> ResourceAttributes.Private)
20382038
match r.Locationwith
2039-
| ILResourceLocation.LocalIn(file, start, len)->
2040-
letbytes= FileSystem.ReadAllBytesShim(file).[start.. start+ len-1]
2041-
modB.DefineManifestResourceAndLog(r.Name,new System.IO.MemoryStream(bytes), attribs)
2042-
| ILResourceLocation.LocalOut bytes->
2043-
modB.DefineManifestResourceAndLog(r.Name,new System.IO.MemoryStream(bytes), attribs)
2044-
| ILResourceLocation.File(mr,_)->
2039+
| ILResourceLocation.LocalIn bytes
2040+
| ILResourceLocation.LocalOut bytes-> modB.DefineManifestResourceAndLog(r.Name,new System.IO.MemoryStream(bytes), attribs)
2041+
| ILResourceLocation.File(mr,_)->
20452042
asmB.AddResourceFileAndLog(r.Name, mr.Name, attribs)
20462043
| ILResourceLocation.Assembly_->
20472044
failwith"references to resources other assemblies may not be emitted using System.Reflection");

‎src/absil/ilwrite.fs‎

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2681,23 +2681,24 @@ and GenEventPass3 cenv env (md: ILEventDef) =
26812681
// --------------------------------------------------------------------
26822682

26832683
let recGetResourceAsManifestResourceRow cenv r=
2684-
letdata,impl=
2685-
match r.Locationwith
2686-
| ILResourceLocation.LocalIn_
2687-
| ILResourceLocation.LocalOut_->
2688-
letbytes= r.GetBytes()
2689-
// Embedded managed resources must be word-aligned. However resource format is
2690-
// not specified in ECMA. Some mscorlib resources appear to be non-aligned - it seems it doesn't matter..
2691-
letoffset= cenv.resources.Position
2692-
letalignedOffset=(align0x8 offset)
2693-
letpad= alignedOffset- offset
2694-
letresourceSize= bytes.Length
2695-
cenv.resources.EmitPadding pad
2696-
cenv.resources.EmitInt32 resourceSize
2697-
cenv.resources.EmitBytes bytes
2698-
Data(alignedOffset,true),(i_File,0)
2699-
| ILResourceLocation.File(mref, offset)-> ULong offset,(i_File, GetModuleRefAsFileIdx cenv mref)
2700-
| ILResourceLocation.Assembly aref-> ULong0x0,(i_AssemblyRef, GetAssemblyRefAsIdx cenv aref)
2684+
letdata,impl=
2685+
letembedManagedResources(bytes:byte[])=
2686+
// Embedded managed resources must be word-aligned. However resource format is
2687+
// not specified in ECMA. Some mscorlib resources appear to be non-aligned - it seems it doesn't matter..
2688+
letoffset= cenv.resources.Position
2689+
letalignedOffset=(align0x8 offset)
2690+
letpad= alignedOffset- offset
2691+
letresourceSize= bytes.Length
2692+
cenv.resources.EmitPadding pad
2693+
cenv.resources.EmitInt32 resourceSize
2694+
cenv.resources.EmitBytes bytes
2695+
Data(alignedOffset,true),(i_File,0)
2696+
2697+
match r.Locationwith
2698+
| ILResourceLocation.LocalIn bytes
2699+
| ILResourceLocation.LocalOut bytes-> embedManagedResources bytes
2700+
| ILResourceLocation.File(mref, offset)-> ULong offset,(i_File, GetModuleRefAsFileIdx cenv mref)
2701+
| ILResourceLocation.Assembly aref-> ULong0x0,(i_AssemblyRef, GetAssemblyRefAsIdx cenv aref)
27012702
UnsharedRow
27022703
[| data
27032704
ULong(match r.Accesswith ILResourceAccess.Public->0x01| ILResourceAccess.Private->0x02)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp