Конференция ".Net" » Исходники FCL
 
  • default © (27.08.06 02:01) [0]
    VCL можно исследовать в коде на Delphi и asm, а вот FCL можно исследовать в коде на C#?
    знаю, что C# лишь один из .NET совместимых языков, но слышал что FCL написана на C#
    не в IL-е же изучать FCL...хотя Рихтер так делает...
  • Lamer@fools.ua © (29.08.06 11:13) [1]
  • default © (29.08.06 13:33) [2]
    не знаю
    не увидел чтобы там что-то было то, что мне нужно
    хотя, например, тот же класс WeakReference в реализации на C# я себе не представляю, зная его внутреннее устройство, описанное у Рихтера
    а то плохо иногда без исходников
    вот, например, метод Array.Sort
    в описании не сказано как ведётся сортировка, отсюда и применение его в критических случаях сомнительно
  • Lamer@fools.ua © (29.08.06 14:27) [3]
    >хотя, например, тот же класс WeakReference в реализации на C# я себе не представляю, зная его внутреннее устройство, описанное у Рихтера

    // ==++==
    //
    //  
    //    Copyright (c) 2006 Microsoft Corporation.  All rights reserved.
    //  
    //    The use and distribution terms for this software are contained in the file
    //    named license.txt, which can be found in the root of this distribution.
    //    By using this software in any fashion, you are agreeing to be bound by the
    //    terms of this license.
    //  
    //    You must not remove this notice, or any other, from this software.
    //  
    //
    // ==--==
    /*============================================================
    **
    ** Class: WeakReference
    **
    ** Purpose: A wrapper for establishing a WeakReference to an Object.
    **
    ===========================================================*/
    namespace System {
       
       using System;
       using System.Runtime.Remoting;
       using System.Runtime.Serialization;
       using System.Security.Permissions;
       using System.Runtime.InteropServices;
       using System.Threading;
       [System.Runtime.InteropServices.ComVisible(true)]
       [SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags=SecurityPermissionFlag.UnmanagedCode)]
       [Serializable()] public class WeakReference : ISerializable {
           // Most methods using m_handle should use GC.KeepAlive(this)
           // to avoid potential handle recycling attacks.  The GC special
           // cases the finalizer for WeakReference & only clears them
           // when all threads are suspended, but you might still run into
           // problems if your code is at least partially interruptible.  
           // It's just too much complexity to think about.
           internal IntPtr m_handle;
           internal bool m_IsLongReference;
       
           // Creates a new WeakReference that keeps track of target.
           // Assumes a Short Weak Reference (ie TrackResurrection is false.)
           //
           public WeakReference(Object target)
               : this(target, false) {
           }

       
           //Creates a new WeakReference that keeps track of target.
           //
           public WeakReference(Object target, bool trackResurrection) {
               m_IsLongReference=trackResurrection;
               m_handle = GCHandle.InternalAlloc(target,
                               trackResurrection ? GCHandleType.WeakTrackResurrection : GCHandleType.Weak);
           }


           protected WeakReference(SerializationInfo info, StreamingContext context) {
               if (info==null) {
                   throw new ArgumentNullException(\"info\");
               }

               Object temp = info.GetValue(\"TrackedObject\",typeof(Object));
               m_IsLongReference = info.GetBoolean(\"TrackResurrection\");
               m_handle = GCHandle.InternalAlloc(temp,
                                                 m_IsLongReference ? GCHandleType.WeakTrackResurrection : GCHandleType.Weak);
           }
       
           //Determines whether or not this instance of WeakReference still refers to an object
           //that has not been collected.
           //
           public virtual bool IsAlive {
               get {
                   IntPtr h = m_handle;

                   // In determining whether it is valid to use this object, we need to at least expose this
                   // without throwing an exception.
                   if (IntPtr.Zero == h)
                       return false;

                   bool result = (GCHandle.InternalGet(h)!=null);

                   // This call to KeepAlive is necessary to prevent the WeakReference finalizer from being called before the result is computed
                   h = Thread.VolatileRead(ref m_handle);
                   GC.KeepAlive(this);
                   return (h == IntPtr.Zero) ? false : result;
               }

           }
       
           //Returns a boolean indicating whether or not we'
    re tracking objects until they're collected (true)
           //or just until they'
    re finalized (false).
           //
           public virtual bool TrackResurrection {
               get { return m_IsLongReference; }

           }
       
           //Gets the Object stored in the handle if it's accessible.
           // Or sets it.
           //
           public virtual Object Target {
               get {
                   IntPtr h = m_handle;
                   // Should only happen when used illegally, like using a
                   // WeakReference from a finalizer.
                   if (IntPtr.Zero == h)
                       return null;

                   Object o = GCHandle.InternalGet(h);

                   // Ensure this WeakReference doesn'
    t get finalized while we're
                   // in this method.
                   h = Thread.VolatileRead(ref m_handle);
                   GC.KeepAlive(this);
                   return (h == IntPtr.Zero) ? null : o;
               }

               set {
                   IntPtr h = m_handle;
                   if (h == IntPtr.Zero)
                       throw new InvalidOperationException(Environment.GetResourceString(\"InvalidOperation_Handle IsNotInitialized\"));

                   // There is a race w/ finalization where m_handle gets set to
                   // NULL and the WeakReference becomes invalid.  Here we have to
                   // do the following in order:
                   //
                   // 1.  Get the old object value
                   // 2.  Get m_handle
                   // 3.  HndInterlockedCompareExchange(m_handle, newValue, oldValue);
                   //
                   // If the interlocked-cmp-exchange fails, then either we lost a race
                   // with another updater, or we lost a race w/ the finalizer.  In
                   // either case, we can just let the other guy win.
                   Object oldValue = GCHandle.InternalGet(h);
                   h = m_handle;  
                   if (h == IntPtr.Zero)
                       throw new InvalidOperationException(Environment.GetResourceString(\"InvalidOperation_Handle IsNotInitialized\"));
                   GCHandle.InternalCompareExchange(h, value, oldValue, false /* isPinned */);

                   // Ensure we don'
    t have any handle recycling attacks in this
                   // method where the finalizer frees the handle.
                   GC.KeepAlive(this);
               }

           }
       
           // Free all system resources associated with this reference.
           //
           // Note: The WeakReference finalizer is not actually run, but
           // treated specially in gc.cpp's ScanForFinalization
           // This is needed for subclasses deriving from WeakReference, however.
           ~WeakReference() {
               IntPtr old_handle = m_handle;
               if (old_handle != IntPtr.Zero) {
                   if (old_handle == Interlocked.CompareExchange(ref m_handle, IntPtr.Zero, old_handle))
                       GCHandle.InternalFree(old_handle);
               }

           }
       
           public virtual void GetObjectData(SerializationInfo info, StreamingContext context) {
               if (info==null) {
                   throw new ArgumentNullException("info");
               }

               info.AddValue("TrackedObject", Target, typeof(Object));
               info.AddValue("TrackResurrection", m_IsLongReference);
           }
       
       }        

    }

  • Lamer@fools.ua © (29.08.06 14:27) [4]
    >вот, например, метод Array.Sort
    в описании не сказано как ведётся сортировка, отсюда и применение его в критических случаях сомнительно


    Array.Sort Method
    ..bla-bla-bla...
    Remarks
    Each element of array must implement the IComparable interface to be capable of comparisons with every other element in array.

    If the sort is not successfully completed, the results are undefined.

    This method uses the QuickSort algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal.

    On average, this method is an O(n log n) operation, where n is the Length of array; in the worst case it is an O(n ^ 2) operation.
    (c) http://msdn2.microsoft.com/en-us/library/6tf1f0bc.aspx
  • default © (29.08.06 15:11) [5]
    Lamer@fools.ua ©   (29.08.06 14:27) [4]
    хех в моём мсдн такого не написано...
    что блин всегда в инет за описанием лазить....
    Lamer@fools.ua ©   (29.08.06 14:27) [3]
    так значит в [1] исходники есть да?
  • Lamer@fools.ua © (29.08.06 15:40) [6]
    >хех в моём мсдн такого не написано...
    что блин всегда в инет за описанием лазить....


    У меня то, что выдрано для [4], есть и в локальном MSDN
    ( ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref2/html/M_System_Array_Sort_1_6f8a45d6.htm )
    Обновите, и будет счастье.

    >так значит в [1] исходники есть да?

    А почитать текст по ссылке?
    Brief Description
    The Shared Source CLI is a compressed archive of the source code to a working implementation of the ECMA CLI and the ECMA C# language specification. This implementation builds and runs on Windows XP.


    Само собой, что там не будет вещей специфичных для Windows, например, типов из пространства имён System.Windows.Forms, поскольку это CLI, а не конкретная реализация, каковой является .NET Framework для Windows.
  • default © (29.08.06 15:51) [7]
    Lamer@fools.ua ©   (29.08.06 15:40) [6]
    спасибо, завтра скачаю
  • Lamer@fools.ua © (29.08.06 15:55) [8]
    >>default ©   (29.08.06 15:51) [7]

    Могу выложить в виде solid rar'а. Тогда будет ~14-15 MB вместо ~21 MB. Аська в анкете.
  • default © (29.08.06 17:57) [9]
    Lamer@fools.ua ©   (29.08.06 15:55) [8]
    спасибо, завтра по асе свяжусь
  • Lamer@fools.ua © (06.09.06 15:17) [10]
    >>default ©

    [offtopic]


    Ну что, скачали?
    [/offtopic]

  • default © (07.09.06 14:21) [11]
    Lamer@fools.ua ©   (06.09.06 15:17) [10]
    скачал
    а куда ты выложил я так и не понял:)
  • Lamer@fools.ua © (08.09.06 07:37) [12]
    Та что ж тут непонятного? Написал же русским по белому в аське:

    >> 31.08.2006 13:01:34 Lamer@fools.ua wrote:
    >> Повторяю на всякий случай:
    >> http://www.mytempdir.com/897377
    >> http://vmcl.kiev.ua/files/temp/SharedSource_CLI-v2_2006-03-11.rar

    З.Ы. На темпдире ещё, наверное, осталось. А у себя я уже вытер.
    З.З.Ы. Ну да ладно.
  • default © (08.09.06 10:44) [13]
    Lamer@fools.ua ©   (08.09.06 07:37) [12]
    тогда пардон
    мне подобное сообщение не приходило:(
    (не мог же я его пропустить...)
  • Lamer@fools.ua © (08.09.06 23:30) [14]
    Хммм...

    Оффтопик. Ну ладно уже.
    Какой ICQ-клиент и версия?
  • default © (08.09.06 23:42) [15]
    Lamer@fools.ua ©   (08.09.06 23:30) [14]
    ICQ2003a
  • Lamer@fools.ua © (08.09.06 23:58) [16]
    У меня Miranda 0.5 Unicode и жалоб от других людей не поступало, что сообщения пропадали, не было. Странно...
  • Lamer@fools.ua © (08.09.06 23:59) [17]
    ", не было" - лишнее :-)
  • MeF Dei Corvi © (17.09.06 21:03) [18]
    Ради интереса занимался декомпилированием FCL, в частности Windows.Forms на C# - ИМХО код чем-то похож на VCL.
 
Конференция ".Net" » Исходники FCL
Есть новые Нет новых   [120157   +156][b:0][p:0.006]