Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional tests for refout. Additional argument check on IncludePrivateMembers #19478

Merged
merged 6 commits into from
May 19, 2017

Conversation

jcouv
Copy link
Member

@jcouv jcouv commented May 13, 2017

This is a follow-up on the ref assemblies feature, adding more tests that were not blockers (from the test plan, #18612).
Also, I realized there is one more combination of parameters that should be disallowed when emitting (IncludePrivateMembers=false, but neither EmitMetadataOnly or metadataPeStream are set).

Also tweaking an error message for deconstruction (to fix #16543). Notice that the designer file seemed out of date, so more changes got pulled in.

Risk
Performance impact
Low. This is mostly test changes and a very minor change to check arguments.

@dotnet/roslyn-compiler for review.

@jcouv jcouv added this to the 15.3 milestone May 13, 2017
@jcouv jcouv self-assigned this May 13, 2017
@jcouv
Copy link
Member Author

jcouv commented May 16, 2017

@dotnet/roslyn-compiler for review. Thanks
This is mostly adding tests, and small code changes (tweak error message, block a specific combination of parameters into Emit)

@jcouv
Copy link
Member Author

jcouv commented May 17, 2017

@dotnet/roslyn-compiler for review (15.3) please.

}
}",
comp => comp.VerifyDiagnostics(
// (7,16): error CS0266: Cannot implicitly convert type 'I<Base>' to 'I<Derived>'. An explicit conversion exists (are you missing a cast?)
Copy link
Member

@gafter gafter May 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like failure rather than success. Please either change out to in, or swap the argument and return types in M. #Resolved

a.M();
}
}",
comp => comp.VerifyDiagnostics());
Copy link
Member

@gafter gafter May 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This demonstrates that there is an [Optional] attribute, but not that the argument value is preserved. #Resolved

{
void M2()
{
System.Console.Write(A.number);
Copy link
Member

@gafter gafter May 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be run to verify that the value was preserved? #Resolved

@jcouv
Copy link
Member Author

jcouv commented May 17, 2017

@gafter I addressed your feedback.
@dotnet/roslyn-compiler for a second review please.

comp =>
{
comp.VerifyDiagnostics();
var verifier = CompileAndVerify(comp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

, expectedOutput: "42"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, unfortunately, we cannot execute scenarios with ref assemblies because ref assemblies won't be loaded by the runtime.
I could test the scenario: (1) compile client against ref assembly, (2) execute against the real thing, but I think the IL check achieves the confidence we want (ie the ref assembly still has the constant, so the client ends up inlining that value).

comp => comp.VerifyDiagnostics());
}

[Fact]
public void RefAssemblyClient_StructWithPrivateGenericField()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we testing that the field type is preserved if the type is private?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I find at least one test: RefAssembly_VerifyTypesAndMembersOnStruct.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, RefAssemblyClient_StructWithPrivateReferenceTypeField and RefAssemblyClient_StructWithPrivateGenericField, indirectly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do those tests test a type that is private to the reference assembly? For example:

struct S
{
    private class C { }
    private C F;
}

Assert.Equal("S.field As System.Int32", field.ToTestDisplayString())
End Sub

Private Sub RefAssemblyNoPiaReferenceFromMethodBody()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this method used?

Copy link
Member Author

@jcouv jcouv May 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing <Fact> :-s
Thanks

Dim [module] = DirectCast(referencedAssembly.Modules(0), PEModuleSymbol)

Dim itest1 = [module].GlobalNamespace.GetMember(Of NamedTypeSymbol)("ITest1")
Assert.NotNull(itest1.GetAttributes().Where(Function(a) a.IsTargetAttribute("System.Runtime.InteropServices", "TypeIdentifierAttribute")).First())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps use .Single() rather than .First() for these attribute checks.

' The ref assembly produced by refout has more types than that produced by refonly,
' because refout will bind the method bodies (and therefore populate more referenced types).
' This will be refined in the future. Follow-up issue: https://github.com/dotnet/roslyn/issues/19403
Private Sub RefAssemblyNoPiaReferenceFromMethodBody_verifyNoPia(image As ImmutableArray(Of Byte), expectMissing As Boolean)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uppercase v?

@cston
Copy link
Member

cston commented May 18, 2017

LGTM

Copy link
Member

@gafter gafter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jcouv
Copy link
Member Author

jcouv commented May 19, 2017

retest windows_debug_vs-integration_prtest please

@jcouv
Copy link
Member Author

jcouv commented May 19, 2017

retest windows_release_vs-integration_prtest please

@jcouv
Copy link
Member Author

jcouv commented May 19, 2017

@MeiChin-Tsai for ask-mode approval.
This is mostly adding tests, but also adding a check to disallow a certain combination of parameters related to ref assemblies (that combination does not make sense, so we produce now an error).

@jcouv
Copy link
Member Author

jcouv commented May 19, 2017

retest windows_release_vs-integration_prtest please

@jcouv jcouv merged commit ba3e095 into dotnet:master May 19, 2017
@jcouv jcouv deleted the refout-tests branch May 19, 2017 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unhelpful diagnostics for failed deconstruction
5 participants