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

Commit90e1b93

Browse files
authored
Fix F# reference normalization (#4920)
* Fix F# reference normalization* Disable vside ubit tests'* Test desktop only* Feedback
1 parent369c538 commit90e1b93

File tree

12 files changed

+117
-46
lines changed

12 files changed

+117
-46
lines changed

‎build.cmd‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,9 @@ if NOT EXIST Proto\net40\bin\fsc.exe (
481481
setBUILD_PROTO=1
482482
)
483483

484+
rem turn off vs ide unit tests until they pass again
485+
setTEST_VS_IDEUNIT_SUITE=0
486+
484487
rem
485488
rem This stops the dotnet cli from hunting around and
486489
rem finding the highest possible dotnet sdk version to use.

‎src/absil/il.fs‎

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -354,37 +354,12 @@ type AssemblyRefData =
354354
/// Global state: table of all assembly references keyed by AssemblyRefData.
355355
letAssemblyRefUniqueStampGenerator=new UniqueStampGenerator<AssemblyRefData>()
356356

357-
letcompareVersions x y=
358-
match x, ywith
359-
| None, None->0
360-
| Some_, None->1
361-
| None, Some_->-1
362-
| Some(x1, x2, x3, x4), Some(y1, y2, y3, y4)->
363-
if y1>x1then1
364-
elif y1<x1then-1
365-
elif y2>x2then1
366-
elif y2<x1then-1
367-
elif y3>x3then1
368-
elif y3<x1then-1
369-
elif y4>x4then1
370-
elif y4<x1then-1
371-
else0
372-
373357
letisMscorlib data=
374358
if System.String.Compare(data.assemRefName,"mscorlib")=0thentrue
375359
elsefalse
376360

377-
letGetReferenceUnifiedVersion data=
378-
let mutablehighest= data.assemRefVersion
379-
ifnot(isMscorlib data)then
380-
for refin AssemblyRefUniqueStampGenerator.Tabledo
381-
if System.String.Compare(ref.assemRefName, data.assemRefName)=0&& highest< ref.assemRefVersionthen
382-
highest<- ref.assemRefVersion
383-
highest
384-
385361
[<Sealed>]
386-
typeILAssemblyRef(data)=
387-
362+
typeILAssemblyRef(data)=
388363
letuniqueStamp= AssemblyRefUniqueStampGenerator.Encode(data)
389364

390365
memberx.Name=data.assemRefName
@@ -395,7 +370,7 @@ type ILAssemblyRef(data) =
395370

396371
memberx.Retargetable=data.assemRefRetargetable
397372

398-
memberx.Version=GetReferenceUnifiedVersiondata
373+
memberx.Version=data.assemRefVersion
399374

400375
memberx.Locale=data.assemRefLocale
401376

@@ -416,7 +391,7 @@ type ILAssemblyRef(data) =
416391
assemRefRetargetable=retargetable
417392
assemRefVersion=version
418393
assemRefLocale=locale}
419-
394+
420395
static memberFromAssemblyName(aname:System.Reflection.AssemblyName)=
421396

422397
letlocale= None

‎src/absil/ilwrite.fs‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ type cenv =
587587
blobs:MetadataTable<byte[]>
588588
strings:MetadataTable<string>
589589
userStrings:MetadataTable<string>
590+
normalizeAssemblyRefs:ILAssemblyRef-> ILAssemblyRef
590591
}
591592
membercenv.GetTable(tab:TableName)= cenv.tables.[tab.Index]
592593

@@ -714,9 +715,9 @@ let rec GetAssemblyRefAsRow cenv (aref:ILAssemblyRef) =
714715
StringIndex(GetStringHeapIdx cenv aref.Name),
715716
StringIndex(match aref.Localewith None->0| Some s-> GetStringHeapIdx cenv s),
716717
BlobIndex(match aref.Hashwith None->0| Some s-> GetBytesAsBlobIdx cenv s))
717-
718+
718719
andGetAssemblyRefAsIdx cenv aref=
719-
FindOrAddSharedRow cenv TableNames.AssemblyRef(GetAssemblyRefAsRow cenv aref)
720+
FindOrAddSharedRow cenv TableNames.AssemblyRef(GetAssemblyRefAsRow cenv(cenv.normalizeAssemblyRefsaref))
720721

721722
andGetModuleRefAsRow cenv(mref:ILModuleRef)=
722723
SharedRow
@@ -2905,7 +2906,7 @@ let GenModule (cenv : cenv) (modul: ILModuleDef) =
29052906
GenTypeDefsPass4[] cenv tds
29062907
reportTime cenv.showTimes"Module Generation Pass 4"
29072908

2908-
letgenerateIL requiredDataFixups(desiredMetadataVersion,generatePdb,ilg:ILGlobals,emitTailcalls,deterministic,showTimes)(m:ILModuleDef)cilStartAddress=
2909+
letgenerateIL requiredDataFixups(desiredMetadataVersion,generatePdb,ilg:ILGlobals,emitTailcalls,deterministic,showTimes)(m:ILModuleDef)cilStartAddressnormalizeAssemblyRefs=
29092910
letisDll= m.IsDLL
29102911

29112912
letcenv=
@@ -2953,7 +2954,8 @@ let generateIL requiredDataFixups (desiredMetadataVersion, generatePdb, ilg : IL
29532954
guids=MetadataTable<_>.New("guids", HashIdentity.Structural)
29542955
blobs= MetadataTable<_>.New("blobs", HashIdentity.Structural)
29552956
strings= MetadataTable<_>.New("strings", EqualityComparer.Default)
2956-
userStrings= MetadataTable<_>.New("user strings", EqualityComparer.Default)}
2957+
userStrings= MetadataTable<_>.New("user strings", EqualityComparer.Default)
2958+
normalizeAssemblyRefs= normalizeAssemblyRefs}
29572959

29582960
// Now the main compilation step
29592961
GenModule cenv m
@@ -3050,16 +3052,16 @@ module FileSystemUtilites =
30503052
#endif
30513053
()
30523054

3053-
letwriteILMetadataAndCode(generatePdb,desiredMetadataVersion,ilg,emitTailcalls,deterministic,showTimes)modul cilStartAddress=
3055+
letwriteILMetadataAndCode(generatePdb,desiredMetadataVersion,ilg,emitTailcalls,deterministic,showTimes)modul cilStartAddressnormalizeAssemblyRefs=
30543056

3055-
// When we know the real RVAs of the data section we fixup the references for the FieldRVA table.
3057+
// When we know the real RVAs of the data section we fixup the references for the FieldRVA table.
30563058
// These references are stored as offsets into the metadata we return from this function
30573059
letrequiredDataFixups= ref[]
30583060

30593061
letnext= cilStartAddress
30603062

30613063
letstrings,userStrings,blobs,guids,tables,entryPointToken,code,requiredStringFixups,data,resources,pdbData,mappings=
3062-
generateIL requiredDataFixups(desiredMetadataVersion, generatePdb, ilg, emitTailcalls, deterministic, showTimes) modul cilStartAddress
3064+
generateIL requiredDataFixups(desiredMetadataVersion, generatePdb, ilg, emitTailcalls, deterministic, showTimes) modul cilStartAddress normalizeAssemblyRefs
30633065

30643066
reportTime showTimes"Generated Tables and Code"
30653067
lettableSize(tab:TableName)= tables.[tab.Index].Count
@@ -3503,7 +3505,8 @@ let writeBytes (os: BinaryWriter) (chunk:byte[]) = os.Write(chunk, 0, chunk.Leng
35033505

35043506
letwriteBinaryAndReportMappings(outfile,
35053507
ilg:ILGlobals,pdbfile:string option,signer:ILStrongNameSigner option,portablePDB,embeddedPDB,
3506-
embedAllSource,embedSourceList,sourceLink,emitTailcalls,deterministic,showTimes,dumpDebugInfo)modul=
3508+
embedAllSource,embedSourceList,sourceLink,emitTailcalls,deterministic,showTimes,dumpDebugInfo)
3509+
modul normalizeAssemblyRefs=
35073510
// Store the public key from the signer into the manifest. This means it will be written
35083511
// to the binary and also acts as an indicator to leave space for delay sign
35093512

@@ -3620,7 +3623,7 @@ let writeBinaryAndReportMappings (outfile,
36203623
| None-> failwith"Expected msorlib to have a version number"
36213624

36223625
letentryPointToken,code,codePadding,metadata,data,resources,requiredDataFixups,pdbData,mappings,guidStart=
3623-
writeILMetadataAndCode((pdbfile<> None), desiredMetadataVersion, ilg, emitTailcalls, deterministic, showTimes) modul next
3626+
writeILMetadataAndCode((pdbfile<> None), desiredMetadataVersion, ilg, emitTailcalls, deterministic, showTimes) modul next normalizeAssemblyRefs
36243627

36253628
reportTime showTimes"Generated IL and metadata";
36263629
let_codeChunk,next= chunk code.Length next
@@ -4266,8 +4269,8 @@ type options =
42664269
showTimes:bool
42674270
dumpDebugInfo:bool}
42684271

4269-
letWriteILBinary(outfile,(args:options),modul)=
4272+
letWriteILBinary(outfile,(args:options),modul,normalizeAssemblyRefs)=
42704273
writeBinaryAndReportMappings(outfile,
42714274
args.ilg, args.pdbfile, args.signer, args.portablePDB, args.embeddedPDB, args.embedAllSource,
4272-
args.embedSourceList, args.sourceLink, args.emitTailcalls, args.deterministic, args.showTimes, args.dumpDebugInfo) modul
4275+
args.embedSourceList, args.sourceLink, args.emitTailcalls, args.deterministic, args.showTimes, args.dumpDebugInfo) modul normalizeAssemblyRefs
42734276
|> ignore

‎src/absil/ilwrite.fsi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ type options =
3030
dumpDebugInfo:bool}
3131

3232
/// Write a binary to the file system. Extra configuration parameters can also be specified.
33-
valWriteILBinary:filename:string* options: options* input: ILModuleDef-> unit
33+
valWriteILBinary:filename:string* options: options* input: ILModuleDef*(ILAssemblyRef-> ILAssemblyRef)-> unit

‎src/fsharp/fsc.fs‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,12 +2010,12 @@ let main2b (tcImportsCapture,dynamicAssemblyCreator) (Args (ctok, tcConfig: TcCo
20102010
letilxMainModule= MainModuleBuilder.CreateMainModule(ctok, tcConfig, tcGlobals, tcImports, pdbfile, assemblyName, outfile, topAttrs, idata, optDataResources, codegenResults, assemVerFromAttrib, metadataVersion, secDecls)
20112011

20122012
AbortOnError(errorLogger, exiter)
2013-
2013+
20142014
// Pass on only the minimum information required for the next phase
2015-
Args(ctok, tcConfig, tcGlobals, errorLogger, staticLinker, outfile, pdbfile, ilxMainModule, signingInfo, exiter)
2015+
Args(ctok, tcConfig,tcImports,tcGlobals, errorLogger, staticLinker, outfile, pdbfile, ilxMainModule, signingInfo, exiter)
20162016

20172017
/// Phase 3: static linking
2018-
letmain3(Args(ctok,tcConfig,tcGlobals,errorLogger:ErrorLogger,staticLinker,outfile,pdbfile,ilxMainModule,signingInfo,exiter:Exiter))=
2018+
letmain3(Args(ctok,tcConfig,tcImports,tcGlobals,errorLogger:ErrorLogger,staticLinker,outfile,pdbfile,ilxMainModule,signingInfo,exiter:Exiter))=
20192019

20202020
use unwindBuildPhase= PushThreadBuildPhaseUntilUnwind BuildPhase.Output
20212021

@@ -2029,10 +2029,10 @@ let main3(Args (ctok, tcConfig, tcGlobals, errorLogger: ErrorLogger, staticLinke
20292029
AbortOnError(errorLogger, exiter)
20302030

20312031
// Pass on only the minimum information required for the next phase
2032-
Args(ctok, tcConfig,errorLogger, tcGlobals, ilxMainModule, outfile, pdbfile, signingInfo, exiter)
2032+
Args(ctok, tcConfig,tcImports, tcGlobals, errorLogger, ilxMainModule, outfile, pdbfile, signingInfo, exiter)
20332033

20342034
/// Phase 4: write the binaries
2035-
letmain4 dynamicAssemblyCreator(Args(ctok,tcConfig,errorLogger:ErrorLogger,tcGlobals:TcGlobals,ilxMainModule,outfile,pdbfile,signingInfo,exiter:Exiter))=
2035+
letmain4 dynamicAssemblyCreator(Args(ctok,tcConfig,tcImports:TcImports,tcGlobals:TcGlobals,errorLogger:ErrorLogger,ilxMainModule,outfile,pdbfile,signingInfo,exiter:Exiter))=
20362036
ReportTime tcConfig"Write .NET Binary"
20372037
use unwindBuildPhase= PushThreadBuildPhaseUntilUnwind BuildPhase.Output
20382038
letoutfile= tcConfig.MakePathAbsolute outfile
@@ -2041,6 +2041,14 @@ let main4 dynamicAssemblyCreator (Args (ctok, tcConfig, errorLogger: ErrorLogger
20412041

20422042
letpdbfile= pdbfile|> Option.map(tcConfig.MakePathAbsolute>> Path.GetFullPath)
20432043

2044+
letnormalizeAssemblyRefs(aref:ILAssemblyRef)=
2045+
match tcImports.TryFindDllInfo(ctok, Range.rangeStartup, aref.Name, lookupOnly=false)with
2046+
| Some dllInfo->
2047+
match dllInfo.ILScopeRefwith
2048+
| ILScopeRef.Assembly ref-> ref
2049+
|_-> aref
2050+
| None-> aref
2051+
20442052
match dynamicAssemblyCreatorwith
20452053
| None->
20462054
try
@@ -2059,7 +2067,9 @@ let main4 dynamicAssemblyCreator (Args (ctok, tcConfig, errorLogger: ErrorLogger
20592067
sourceLink= tcConfig.sourceLink
20602068
signer= GetStrongNameSigner signingInfo
20612069
dumpDebugInfo= tcConfig.dumpDebugInfo},
2062-
ilxMainModule)
2070+
ilxMainModule,
2071+
normalizeAssemblyRefs
2072+
)
20632073
with Failure msg->
20642074
error(Error(FSComp.SR.fscProblemWritingBinary(outfile, msg), rangeCmdArgs))
20652075
with e->

‎tests/fsharp/FSharp.Tests.FSharpSuite.fsproj‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<Link>NunitHelpers.fs</Link>
3535
</Compile>
3636
<CompileInclude="single-test.fs" />
37+
3738
<CompileInclude="TypeProviderTests.fs" />
3839
<CompileInclude="tests.fs" />
3940
<ContentInclude="packages.config" />
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
version1/
2+
version2/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespaceAscendentAssembly
2+
3+
moduleAscendent=
4+
5+
lethello()=
6+
DependentAssembly.Say.hello"Ascendent"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespaceDependentAssembly
2+
3+
moduleSay=
4+
5+
lethello name= printfn"Hello%s" name
596 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp