programing tip

Windows Phone의 반응성 확장 프로그램 버그

itbloger 2020. 7. 24. 07:52
반응형

Windows Phone의 반응성 확장 프로그램 버그


로 컴파일 하면 디버거가 연결되어 있지 않으면 VS 2012프로젝트 유형 WP 8.0으로 다음 코드가 실패합니다.

어떻게 든 디버거가 연결되어 있지 않으면 컴파일러 최적화는 내부 코드를 망칩니다 Crash()-코드의 주석을 참조하십시오.

Lumia 1520 (8.1)Lumia 630 (8.0) 에서 테스트되었습니다 .

왜 이런 일이 발생하는지 아이디어가 있습니까?

public partial class MainPage : PhoneApplicationPage
{
    public MainPage()
    {
        InitializeComponent();
        Button.Tap += (sender, args) => new A<B, string>(new B(), "string").Crash();
    }
}
public class B
{
    public void Foo<T>(T val) { }
}
public class A<T1, T2> where T1 : B
{
    private T1 _t1;
    private T2 _t2;
    public A(T1 t1, T2 t2)
    {
        _t2 = t2;
        _t1 = t1;
    }
    public void Crash()
    {
        var obs = Observable.Return(_t2);
        obs.Subscribe(result =>
        {
            //CLR is expecting T2 to be System.String here,
            //but somehow, after passing through Observable
            //T2 here is not a string, it's A<T1, T2>

            new List<T2>().Add(result);
        });
        //Will run normally if commented
        _t1.Foo(new object());
    }
}

 _t1.Foo<type>(type);

형식 선언이 없습니다. 컴파일러가 추측하고 있습니다. 엄격하게 모든 것을 입력하면 실행됩니다.

참고 URL : https://stackoverflow.com/questions/24610216/reactive-extensions-bug-on-windows-phone

반응형