Fix 82: Scope of types for named values in attributes #568
Closed
dsyme wants to merge 5 commits intodotnet:OOBfrom
Closed
Fix 82: Scope of types for named values in attributes #568dsyme wants to merge 5 commits intodotnet:OOBfrom
dsyme wants to merge 5 commits intodotnet:OOBfrom
Conversation
Contributor
Author
|
I've verified the fix against the @vladima test gist https://gist.github.com/vladima/4f1b6c248ec21ff45fa1 described here: #437 (comment) by hand. What I did: then compare for the modified client.fs below. The first @latkin yes, could you please add this as a test when you integrate. Thanks...!!! |
Contributor
|
When I try the test scenario, it works in F# 3.1, pre-fix 4.0, and post-fix 4.0. library.cs (note - needed to mark C 'public' or else all F# versions had runtime crash) using System;
using System.Net.Security;
using System.ServiceModel;
public class C {
[FaultContract(typeof(Exception), ProtectionLevel = ProtectionLevel.Sign)]
public static void Run() { Console.WriteLine("In run");}
}mirror.fs // compile as: fsc --target:library ProvidedTypes.fsi ProvidedTypes.fs Mirror.fs
namespace Repro
open System.IO
open System.Reflection
open ProviderImplementation.ProvidedTypes
open Microsoft.FSharp.Core.CompilerServices
[<assembly : TypeProviderAssembly>]
do()
[<TypeProvider>]
type Mirror() as this =
inherit TypeProviderForNamespaces()
let thisAssembly = typeof<Mirror>.Assembly
let topType = ProvidedTypeDefinition(thisAssembly, "Top", "Repro", Some typeof<obj>, IsErased = true)
let csAssembly =
let location = Path.GetDirectoryName(thisAssembly.Location)
System.Reflection.Assembly.LoadFrom(Path.Combine(location, "library.dll"))
do topType.AddAssemblyTypesAsNestedTypesDelayed(fun() -> csAssembly)
do this.AddNamespace("Top", [topType])client.fsx #r "./mirror.dll"
#r "System.ServiceModel.dll"
type T = Top.Repro.C
T.Run()
let attrs = typeof<T>.GetMethod("Run").GetCustomAttributes(false)
let attr = attrs.[0] :?> System.ServiceModel.FaultContractAttribute
printfn "%A" (attr.ProtectionLevel.ToString()) |
Contributor
|
Mmm ok repro only occurs in the context of an exe, it doesn't repro in FSI. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moving to OOB, see #437