BADF00D / DisposableFixer

This is a Visual Studio Extension and NuGet package that should identify and fix problems as memleaks while using IDisposables.
Other
35 stars 7 forks source link

CompositeDisposable got disposed, but is marked as not Disposed in v0.11 #17

Closed dscopra closed 7 years ago

dscopra commented 7 years ago
internal class DataSourcePlayback : IDataSourcePlayback, IDisposable {
        private readonly ISchedulerService _schedulers;

        private readonly Subject<Data> _received_data_subject = new Subject<Data>();
        private readonly Subject<byte[]> _received_rawdata_subject = new Subject<byte[]>();
        private readonly Subject<byte[]> _send_rawdata_subject = new Subject<byte[]>();
        private readonly Subject<Unit> _restart_subject = new Subject<Unit>();

        public IObservable<Data> ReceivedData => _received_data_subject.AsObservable();
        public IObservable<byte[]> ReceivedRawData => _received_rawdata_subject.AsObservable();
        public IObservable<byte[]> SendRawData => _send_rawdata_subject.AsObservable();
        public IObservable<Unit> Restart => _restart_subject.AsObservable();

        private IDisposable _disposable;

        public DataSourcePlayback(ISchedulerService schedulers) {
            _schedulers = schedulers;
        }

        public void PlayFromNetworkStream() {
            _disposable?.Dispose();
            _restart_subject.OnNext(Unit.Default);

            var listerner = new TcpListener(IPAddress.Any, 4001);

            listerner.Start();
            var socket = listerner.AcceptSocket();

            var network_stream = new NetworkStream(socket);
            var observableStream = new ObservableStream(_schedulers, network_stream);

            _disposable = new CompositeDisposable(network_stream, observableStream);
        }

        public void Dispose() {
            _received_data_subject.Dispose();
            _received_rawdata_subject.Dispose();
            _send_rawdata_subject.Dispose();
            _restart_subject.Dispose();
            _disposable.Dispose();
        }
    }

image

dscopra commented 7 years ago

Furthermore some LocalDecalration of IDisposable are not disposed, but arn't marked:

image

dscopra commented 7 years ago

The problem seems to be connected with ObjectCreations, becauses MethodInvokationExpressions seems not to be affected: image