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

Commitfa1c97f

Browse files
matthidKevinRansom
authored andcommitted
Fix #nowarn "2003" not working -dotnet#3139 (dotnet#4480)
* Fix issuedotnet#3139,- Make sure the warning is triggered always (not only when AssemblyVersionAttribute is present)- Make sure warning can be disabled via #nowarn 2003- Include the correct range of the problematic string* add missing test-files.* edit existing tests* do not use full-qualified type name when reporting errors (as it was previously).* use full name and wait for feedback* Add comments as suggested.* Change warning message slightly as suggested by@dsyme .* Fix english localization.* update test
1 parenta557fc3 commitfa1c97f

File tree

33 files changed

+202
-67
lines changed

33 files changed

+202
-67
lines changed

‎src/buildfromsource/FSharp.Compiler.Private/FSComp.resx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3379,7 +3379,7 @@
33793379
<value>No implementation files specified</value>
33803380
</data>
33813381
<dataname="fscBadAssemblyVersion"xml:space="preserve">
3382-
<value>An {0} specified version '{1}', but this value is invalid and has been ignored</value>
3382+
<value>The attribute {0} specified version '{1}', but this value is invalid and has been ignored</value>
33833383
</data>
33843384
<dataname="fscTwoResourceManifests"xml:space="preserve">
33853385
<value>Conflicting options specified: 'win32manifest' and 'win32res'. Only one of these can be used.</value>

‎src/fsharp/FSComp.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ lexIndentOffForML,"Consider using a file with extension '.ml' or '.mli' instead"
11131113
fscTooManyErrors,"Exiting - too many errors"
11141114
2001,docfileNoXmlSuffix,"The documentation file has no .xml suffix"
11151115
2002,fscNoImplementationFiles,"No implementation files specified"
1116-
2003,fscBadAssemblyVersion,"An %s specified version '%s', but this value is invalid and has been ignored"
1116+
2003,fscBadAssemblyVersion,"The attribute %s specified version '%s', but this value is invalid and has been ignored"
11171117
2004,fscTwoResourceManifests,"Conflicting options specified: 'win32manifest' and 'win32res'. Only one of these can be used."
11181118
2005,fscQuotationLiteralsStaticLinking,"The code in assembly '%s' makes uses of quotation literals. Static linking may not include components that make use of quotation literals unless all assemblies are compiled with at least F# 4.0."
11191119
2006,fscQuotationLiteralsStaticLinking0,"Code in this assembly makes uses of quotation literals. Static linking may not include components that make use of quotation literals unless all assemblies are compiled with at least F# 4.0."

‎src/fsharp/TypeChecker.fs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17168,6 +17168,21 @@ let TypeCheckOneImplFile
1716817168
errorRecovery e m
1716917169
false)
1717017170

17171+
// Warn on version attributes.
17172+
topAttrs.assemblyAttrs |> List.iter (function
17173+
| Attrib(tref, _, [ AttribExpr(Expr.Const (Const.String(version), range, _), _) ] , _, _, _, _) ->
17174+
let attrName = tref.CompiledRepresentationForNamedType.FullName
17175+
let isValid =
17176+
try IL.parseILVersion version |> ignore; true
17177+
with _ -> false
17178+
match attrName with
17179+
| "System.Reflection.AssemblyInformationalVersionAttribute"
17180+
| "System.Reflection.AssemblyFileVersionAttribute" //TODO compile error like c# compiler?
17181+
| "System.Reflection.AssemblyVersionAttribute" when not isValid ->
17182+
warning(Error(FSComp.SR.fscBadAssemblyVersion(attrName, version), range))
17183+
| _ -> ()
17184+
| _ -> ())
17185+
1717117186
let implFile = TImplFile(qualNameOfFile, scopedPragmas, implFileExprAfterSig, hasExplicitEntryPoint, isScript)
1717217187

1717317188
return (topAttrs, implFile, implFileTypePriorToSig, envAtEnd, cenv.createsGeneratedProvidedTypes)

‎src/fsharp/fsc.fs‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,8 @@ module AttributeHelpers =
707707
if deterministic&& versionString.Contains("*")then
708708
errorR(Error(FSComp.SR.fscAssemblyWildcardAndDeterminism(attribName, versionString), Range.rangeStartup))
709709
try Some(IL.parseILVersion versionString)
710-
with e->
711-
warning(Error(FSComp.SR.fscBadAssemblyVersion(attribName, versionString), Range.rangeStartup))
710+
with e->
711+
// Warning will be reported by TypeChecker.fs
712712
None
713713
|_-> None
714714

@@ -776,24 +776,23 @@ module MainModuleBuilder =
776776
Seq.toList
777777
| None->[]
778778

779-
letfileVersionwarnfindStringAttr(assemblyVersion:ILVersionInfo)=
779+
letfileVersion findStringAttr(assemblyVersion:ILVersionInfo)=
780780
letattrName="System.Reflection.AssemblyFileVersionAttribute"
781781
match findStringAttr attrNamewith
782782
| None-> assemblyVersion
783783
| Some(AttributeHelpers.ILVersion(v))-> v
784-
| Some v->
785-
warn(Error(FSComp.SR.fscBadAssemblyVersion(attrName, v), Range.rangeStartup))
786-
//TODO compile error like c# compiler?
784+
| Some_->
785+
// Warning will be reported by TypeChecker.fs
787786
assemblyVersion
788787

789-
letproductVersionwarnfindStringAttr(fileVersion:ILVersionInfo)=
788+
letproductVersion findStringAttr(fileVersion:ILVersionInfo)=
790789
letattrName="System.Reflection.AssemblyInformationalVersionAttribute"
791790
lettoDotted(v1,v2,v3,v4)= sprintf"%d.%d.%d.%d" v1 v2 v3 v4
792791
match findStringAttr attrNamewith
793792
| None| Some""-> fileVersion|> toDotted
794793
| Some(AttributeHelpers.ILVersion(v))-> v|> toDotted
795794
| Some v->
796-
warn(Error(FSComp.SR.fscBadAssemblyVersion(attrName, v), Range.rangeStartup))
795+
// Warning will be reported by TypeChecker.fs
797796
v
798797

799798
letproductVersionToILVersionInfo(version:string):ILVersionInfo=
@@ -935,9 +934,9 @@ module MainModuleBuilder =
935934
| Some text->[(key, text)]
936935
|_->[]
937936

938-
letfileVersionInfo= fileVersionwarningfindAttr assemblyVersion
937+
letfileVersionInfo= fileVersion findAttr assemblyVersion
939938

940-
letproductVersionString= productVersionwarningfindAttr fileVersionInfo
939+
letproductVersionString= productVersion findAttr fileVersionInfo
941940

942941
letstringFileInfo=
943942
// 000004b0:

‎src/fsharp/fsc.fsi‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@ type ConsoleLoggerProvider =
8787
// For unit testing
8888
moduleinternalMainModuleBuilder=
8989

90-
valfileVersion:warn:(exn-> unit)->findStringAttr:(string-> string option)->assemblyVersion:ILVersionInfo->ILVersionInfo
91-
valproductVersion:warn:(exn-> unit)->findStringAttr:(string-> string option)->fileVersion:ILVersionInfo->string
90+
valfileVersion:findStringAttr:(string-> string option)->assemblyVersion:ILVersionInfo->ILVersionInfo
91+
valproductVersion:findStringAttr:(string-> string option)->fileVersion:ILVersionInfo->string
9292
valproductVersionToILVersionInfo:string->ILVersionInfo

‎src/fsharp/xlf/FSComp.txt.cs.xlf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5438,7 +5438,7 @@
54385438
<note />
54395439
</trans-unit>
54405440
<trans-unitid="fscBadAssemblyVersion">
5441-
<source>An {0} specified version '{1}', but this value is invalid and has been ignored</source>
5441+
<source>The attribute {0} specified version '{1}', but this value is invalid and has been ignored</source>
54425442
<targetstate="translated">Třída {0} definovala verzi {1}, ale tato hodnota není platná a ignoruje se.</target>
54435443
<note />
54445444
</trans-unit>

‎src/fsharp/xlf/FSComp.txt.de.xlf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5438,7 +5438,7 @@
54385438
<note />
54395439
</trans-unit>
54405440
<trans-unitid="fscBadAssemblyVersion">
5441-
<source>An {0} specified version '{1}', but this value is invalid and has been ignored</source>
5441+
<source>The attribute {0} specified version '{1}', but this value is invalid and has been ignored</source>
54425442
<targetstate="translated">Ein {0} gab Version '{1}' an, dieser Wert ist jedoch ungültig und wurde ignoriert.</target>
54435443
<note />
54445444
</trans-unit>

‎src/fsharp/xlf/FSComp.txt.en.xlf‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5438,8 +5438,8 @@
54385438
<note />
54395439
</trans-unit>
54405440
<trans-unitid="fscBadAssemblyVersion">
5441-
<source>An {0} specified version '{1}', but this value is invalid and has been ignored</source>
5442-
<targetstate="new">An {0} specified version '{1}', but this value is invalid and has been ignored</target>
5441+
<source>The attribute {0} specified version '{1}', but this value is invalid and has been ignored</source>
5442+
<targetstate="new">The attribute {0} specified version '{1}', but this value is invalid and has been ignored</target>
54435443
<note />
54445444
</trans-unit>
54455445
<trans-unitid="fscTwoResourceManifests">
@@ -6989,4 +6989,4 @@
69896989
</trans-unit>
69906990
</body>
69916991
</file>
6992-
</xliff>
6992+
</xliff>

‎src/fsharp/xlf/FSComp.txt.es.xlf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5438,7 +5438,7 @@
54385438
<note />
54395439
</trans-unit>
54405440
<trans-unitid="fscBadAssemblyVersion">
5441-
<source>An {0} specified version '{1}', but this value is invalid and has been ignored</source>
5441+
<source>The attribute {0} specified version '{1}', but this value is invalid and has been ignored</source>
54425442
<targetstate="translated">Un {0} ha especificado la versión "{1}", pero este valor no es válido y se ha omitido</target>
54435443
<note />
54445444
</trans-unit>

‎src/fsharp/xlf/FSComp.txt.fr.xlf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5438,7 +5438,7 @@
54385438
<note />
54395439
</trans-unit>
54405440
<trans-unit id="fscBadAssemblyVersion">
5441-
<source>An {0} specified version '{1}', but this value is invalid and has been ignored</source>
5441+
<source>The attribute {0} specified version '{1}', but this value is invalid and has been ignored</source>
54425442
<target state="translated">Un {0} a spécifié la version '{1}', mais cette valeur n'est pas valide et a été ignorée</target>
54435443
<note />
54445444
</trans-unit>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp