public static WeakSet <ISymbol> GetUnrootedSymbols(Compilation compilation)
                {
                    var result = new WeakSet <ISymbol>();

                    var compAssembly = compilation.Assembly;

                    result.Add(compAssembly);

                    // The dynamic type is also unrooted (i.e. doesn't point back at the compilation or source
                    // assembly).  So we have to keep track of it so we can get back from it to a project in case the
                    // underlying compilation is GC'ed.
                    if (compilation.Language == LanguageNames.CSharp)
                    {
                        result.Add(compilation.DynamicType);
                    }

                    foreach (var reference in compilation.References)
                    {
                        var symbol = compilation.GetAssemblyOrModuleSymbol(reference);
                        if (symbol == null)
                        {
                            continue;
                        }

                        result.Add(symbol);
                    }

                    return(result);
                }
Example #2
0
        public void TestWeakSet()
        {
            var ws = new WeakSet <object>();

            var o = new Object();

            ws.Add(o);
            ws.Add(o);
            Assert.AreEqual(1, ws.Count);
            foreach (var item in ws)
            {
                Assert.AreEqual(item, o);
            }

            ws.Remove(o);
            Assert.AreEqual(0, ws.Count);

            AddObject(ws);
            AddObject(ws);
            Assert.AreEqual(2, ws.Count);
            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);

            int iC = 0;

            foreach (var item in ws)
            {
                iC++;
            }
            Assert.AreEqual(0, iC);
            Assert.AreEqual(2, ws.Count);

            ws.WeakCleanup();
            Assert.AreEqual(0, ws.Count);
        }
		public void TestWeakSet()
		{
			var ws = new WeakSet<object>();

			var o = new Object();
			ws.Add(o);
			ws.Add(o);
			Assert.AreEqual(1, ws.Count);
			foreach (var item in ws) Assert.AreEqual(item, o);

			ws.Remove(o);
			Assert.AreEqual(0, ws.Count);

			AddObject(ws);
			AddObject(ws);
			Assert.AreEqual(2, ws.Count);
			GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);

			int iC = 0;
			foreach (var item in ws) iC++;
			Assert.AreEqual(0, iC);
			Assert.AreEqual(2, ws.Count);

			ws.WeakCleanup();
			Assert.AreEqual(0, ws.Count);
		}
                public static UnrootedSymbolSet GetUnrootedSymbols(Compilation compilation)
                {
                    var primaryAssembly = new WeakReference <IAssemblySymbol>(compilation.Assembly);

                    // The dynamic type is also unrooted (i.e. doesn't point back at the compilation or source
                    // assembly).  So we have to keep track of it so we can get back from it to a project in case the
                    // underlying compilation is GC'ed.
                    var primaryDynamic = new WeakReference <ITypeSymbol?>(
                        compilation.Language == LanguageNames.CSharp ? compilation.DynamicType : null);

                    var secondarySymbols = new WeakSet <ISymbol>();

                    foreach (var reference in compilation.References)
                    {
                        var symbol = compilation.GetAssemblyOrModuleSymbol(reference);
                        if (symbol == null)
                        {
                            continue;
                        }

                        secondarySymbols.Add(symbol);
                    }

                    return(new UnrootedSymbolSet(primaryAssembly, primaryDynamic, secondarySymbols));
                }
Example #5
0
        internal FileLog(IMultiFileMuxer muxer, Func <FileLogSettings> settingsProvider)
        {
            this.settingsProvider = new SafeSettingsCache(settingsProvider);
            this.settingsProvider.Get();
            this.muxer = muxer;

            muxerHandle           = new object();
            muxerHandleRef        = new WeakReference(muxerHandle);
            muxerRegistrationLock = new object();
            eventsLost            = new AtomicLong(0);

            filePathProvider = new CachingTransform <FileLogSettings, FilePath>(
                settings => new FilePath(settings.FilePath),
                preventParallelProcessing: false);

            Instances.Add(this);
        }
Example #6
0
 void AddObject(WeakSet <object> ws)
 {
     ws.Add(new Object());
 }
		void AddObject(WeakSet<object> ws) { ws.Add(new Object()); }
Example #8
0
 public void Register(Controls.Menu.MenuRibbon mr)
 {
     menuRibbons.Add(mr);
 }